2 <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
9 <firstname>Kay</firstname>
10 <surname>Sievers</surname>
11 <email>kay.sievers@vrfy.org</email>
15 <holder>Kay Sievers</holder>
24 <date>August 2005</date>
25 <productname>udev</productname>
29 <refentrytitle>udev</refentrytitle>
30 <manvolnum>8</manvolnum>
34 <refname>udev</refname>
35 <refpurpose>dynamic device management</refpurpose>
38 <refsect1><title>DESCRIPTION</title>
39 <para>udev provides a dynamic device directory containing only the files for
40 actually present devices. It creates or removes device node files in the
41 <filename>/dev</filename> directory, or it renames network interfaces.</para>
43 <para>Usually udev runs as <citerefentry><refentrytitle>udevd</refentrytitle>
44 <manvolnum>8</manvolnum></citerefentry> and receives uevents directly from the
45 kernel if a device is added or removed form the system.</para>
47 <para>If udev receives a device event, it matches its configured rules
48 against the available device attributes provided in sysfs to identify the device.
49 Rules that match, may provide additional device information or specify a device
50 node name and multiple symlink names and instruct udev to run additional programs
51 as part of the device event handling.</para>
54 <refsect1><title>CONFIGURATION</title>
55 <para>All udev configuration files are placed in <filename>/etc/udev/*</filename>.
56 Every file consists of a set of lines of text. All empty lines or lines beginning
57 with '#' will be ignored.</para>
59 <refsect2><title>Configuration file</title>
60 <para>udev expects its main configuration file at <filename>/etc/udev/udev.conf</filename>.
61 It consists of a set of variables allowing the user to override default udev values.
62 The following variables can be set:</para>
65 <term><option>udev_root</option></term>
67 <para>Specifies where to place the device nodes in the filesystem.
68 The default value is <filename>/dev</filename>.</para>
73 <term><option>udev_rules</option></term>
75 <para>The name of the udev rules file or directory to look for files
76 with the suffix <filename>.rules</filename>. Multiple rule files are
77 read in lexical order. The default value is
78 <filename>/etc/udev/rules.d</filename>.</para>
83 <term><option>udev_log</option></term>
85 <para>The logging priority. Valid values are the numerical syslog priorities
86 or their textual representations: <option>err</option>, <option>info</option>
87 and <option>debug</option>.</para>
93 <refsect2><title>Rules files</title>
94 <para>The udev rules are read from the files located in the
95 <filename>/etc/udev/rules.d</filename> directory or at the location specified
96 value in the configuraton file. Every line in the rules file contains at least
97 one key value pair. There are two kind of keys, match and assignement keys.
98 If all match keys are matching against its value, the rule gets applied and the
99 assign keys get the specified value assigned. A matching rule may specify the
100 name of the device node, add a symlink pointing to the node, or run a specified
101 program as part of the event handling. If no matching rule is found, the default
102 device node name is used.</para>
104 <para>A rule may consists of a list of one or more key value pairs separated by
105 a comma. Each key has a distinct operation, depending on the used operator. Valid
106 operators are:</para>
109 <term><option>==</option></term>
111 <para>Compare for equality.</para>
116 <term><option>!=</option></term>
118 <para>Compare for non-equality.</para>
123 <term><option>=</option></term>
125 <para>Asign a value to a key. Keys that represent a list, are reset
126 and only this single value is assigned.</para>
131 <term><option>+=</option></term>
133 <para>Add the value to a key that holds a list of entries.</para>
138 <term><option>:=</option></term>
140 <para>Assign a value to a key finally; disallow any later changes,
141 which may be used to prevent changes by any later rules.</para>
146 <para>The following key names can be used to match against device properties:</para>
149 <term><option>ACTION</option></term>
151 <para>Match the kernel action name.</para>
156 <term><option>KERNEL</option></term>
158 <para>Match the kernel device name</para>
163 <term><option>DEVPATH</option></term>
165 <para>Match the kernel devpath.</para>
170 <term><option>SUBSYSTEM</option></term>
172 <para>Match the kernel subsystem name</para>
177 <term><option>BUS</option></term>
179 <para>Match the type of bus the device is connected to.</para>
184 <term><option>DRIVER</option></term>
186 <para>Match the kernel driver name.</para>
191 <term><option>ID</option></term>
193 <para>Match the device number on the bus.</para>
198 <term><option>ENV{<replaceable>key</replaceable>}</option></term>
200 <para>Match against the value of an environment key. Depending on
201 the specified operation, this key is also used as an assignment.</para>
206 <term><option>SYSFS{<replaceable>filename</replaceable>}</option></term>
208 <para>Match the sysfs attribute value. Up to five values can be specified.
209 Trailing whitespace is ignored, if the specified match value does not contain
210 trailing whitespace itself.</para>
215 <term><option>PROGRAM</option></term>
217 <para>Execute external program. The key is true, if the program returns
218 without exit code zero. The whole event environment is available to the
219 executed program. The program's output printed to stdout is available for
220 the RESULT key.</para>
225 <term><option>RESULT</option></term>
227 <para>Match the returned string of the last PROGRAM call. This key can
228 be used in the same or in any later rule after a PROGRAM call.</para>
233 <para>Most of the fields support a shell style pattern matching. The following
234 pattern characters are supported:</para>
237 <term><option>*</option></term>
239 <para>Matches zero, or any number of characters.</para>
243 <term><option>?</option></term>
245 <para>Matches any single character.</para>
249 <term><option>[]</option></term>
251 <para>Matches any single character specified within the brackets.
252 example, the pattern string 'tty[SR]' would match either 'ttyS' or 'ttyR'.
253 Ranges are also supported within this match with the '-' character.
254 For example, to match on the range of all digits, the pattern [0-9] would
255 be used. If the first character following the '[' is a '!', any characters
256 not enclosed are matched.</para>
261 <para>The following keys can get values assigned:</para>
264 <term><option>NAME</option></term>
266 <para>The name of the node to be created, or the name the network interface
267 should be renamed to. Only one rule can set the node name, all later rules with
268 a NAME key will be ignored.</para>
273 <term><option>SYMLINK</option></term>
275 <para>The name of a symlink targeting the node. Every matching rule can add
276 this value to the list of symlinks to be created along with the device node.
277 Multiple symlinks may be specified by separating the names by the space
283 <term><option>OWNER, GROUP, MODE</option></term>
285 <para>The permissions for the device node. Every specified value overwrites
286 the compiled-in default value.</para>
291 <term><option>ENV{<replaceable>key</replaceable>}</option></term>
293 <para>Export the key to the environment. Depending on the specified
294 operation, this key is also used as a match.</para>
299 <term><option>RUN</option></term>
301 <para>Add a program to the list of programs to be executed for a specific
307 <term><option>LABEL</option></term>
309 <para>Named label where a GOTO can jump to.</para>
314 <term><option>GOTO</option></term>
316 <para>Jumps to the next LABEL with a matching gname</para>
321 <term><option>IMPORT{<replaceable>type</replaceable>}</option></term>
323 <para>Import the printed result or the content of a file in environment key
324 format into the event environment. <option>program</option> will execute an
325 external program and read its output. <option>file</option> will inport a
326 text file. If no option is given, udev will determine it from the executable
327 bit of of the file permissions.</para>
332 <term><option>WAIT_FOR_SYSFS</option></term>
334 <para>Wait for the specified sysfs file of the device to be created. May be used
335 to fight agains timing issues wth the kernel.</para>
340 <term><option>OPTIONS</option></term>
342 <para><option>last_rule</option> stops further rules application. No later rules
343 will have any effect.
344 <option>ignore_device</option> will ignore this event completely.
345 <option>ignore_remove</option> will ignore any later remove event for this
346 device. This may be useful as a workaround for broken device drivers.
347 <option>all_partitions</option> will create device nodes for all available partitions of
348 a block device. This may be useful for removable media.</para>
353 <para>The <option>NAME</option>, <option>SYMLINK</option>, <option>PROGRAM</option>,
354 <option>OWNER</option> and <option>GROUP</option> fields support simple
355 printf-like string substitutions:</para>
358 <term><option>%k</option>, <option>$kernel</option></term>
360 <para>The kernel name for this device.</para>
365 <term><option>%b</option>, <option>$id</option></term>
367 <para>The kernel bus id for this device.</para>
372 <term><option>%n</option>, <option>$number</option></term>
374 <para>The kernel number for this device. For example, 'sda3' has
375 kernel number of '3'</para>
380 <term><option>%p</option>, <option>$devpath</option></term>
382 <para>The devpath of the device.</para>
387 <term><option>%s{<replaceable>file</replaceable>}</option>, <option>$sysfs{<replaceable>file</replaceable>}</option></term>
389 <para>The content of a sysfs attribute.</para>
394 <term><option>%E{<replaceable>key</replaceable>}</option>, <option>$env{<replaceable>key</replaceable>}</option></term>
396 <para>The value of an environment variable.</para>
401 <term><option>%m</option>, <option>$major</option></term>
403 <para>The kernel major number for the device.</para>
408 <term><option>%M</option> <option>$minor</option></term>
410 <para>The kernel minor number for the device.</para>
415 <term><option>%c</option>, <option>$result</option></term>
417 <para>The string returned by the external program requested with PROGRAM.
418 A single part of the string, separated by a space character may be selected
419 by specifying the part number as an attribute: <option>%c{N}</option>.
420 If the number is followed by the '+' char this part plus all remaining parts
421 of the result string are substituted: <option>%c{N+}</option></para>
426 <term><option>%P</option>, <option>$parent</option></term>
428 <para>The node name of the parent device.</para>
433 <term><option>%r</option>, <option>$root</option></term>
435 <para>The udev_root value.</para>
440 <term><option>%N</option>, <option>$tempnode</option></term>
442 <para>The name of a created temporary device node to provide access to
443 the device from a external program before the real node is created.</para>
448 <term><option>%%</option></term>
450 <para>The '%' character itself.</para>
455 <term><option>$$</option></term>
457 <para>The '$' character itself.</para>
461 <para>The count of characters to be substituted may be limited by specifying
462 the format length value. For example, '%3s{file}' will only
463 insert the first three characters of the sysfs attribute</para>
467 <refsect1><title>ENVIRONMENT</title>
470 <term><option>ACTION</option></term>
472 <para><replaceable>add</replaceable> or <replaceable>remove</replaceable> signifies
473 the addition or the removal of a device.</para>
478 <term><option>DEVPATH</option></term>
480 <para>The sysfs devpath without the mountpoint but a leading slash.</para>
485 <term><option>SUBSYSTEM</option></term>
487 <para>The kernel subsystem the device belongs to.</para>
492 <term><option>UDEV_LOG</option></term>
494 <para>Overrides the syslog priority specified in the config file.</para>
500 <refsect1><title>AUTHOR</title>
501 <para>Written by Greg Kroah-Hartman <email>greg@kroah.com</email> and
502 Kay Sievers <email>kay.sievers@vrfy.org</email>. With much help from
503 Dan Stekloff <email>dsteklof@us.ibm.com</email> and many others.</para>
507 <title>SEE ALSO</title>
509 <refentrytitle>udev</refentrytitle><manvolnum>8</manvolnum>
512 <refentrytitle>udevinfo</refentrytitle><manvolnum>8</manvolnum>
515 <refentrytitle>udevd</refentrytitle><manvolnum>8</manvolnum>
518 <refentrytitle>udevmonitor</refentrytitle><manvolnum>8</manvolnum>
519 </citerefentry></para>