chiark / gitweb /
remove "udev_db" option from config file
[elogind.git] / docs / udev.xml
1 <?xml version='1.0'?>
2 <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3   "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4
5 <article>
6   <articleinfo>
7     <title>xmlto</title>
8     <author>
9       <firstname>Kay</firstname>
10       <surname>Sievers</surname>
11       <email>kay.sievers@vrfy.org</email>
12     </author>
13     <copyright>
14       <year>2005</year>
15       <holder>Kay Sievers</holder>
16     </copyright>
17   </articleinfo>
18
19   <section>
20     <title>udev</title>
21     <refentry>
22       <refentryinfo>
23         <title>udev</title>
24         <date>August 2005</date>
25         <productname>udev</productname>
26       </refentryinfo>
27
28       <refmeta>
29         <refentrytitle>udev</refentrytitle>
30         <manvolnum>8</manvolnum>
31       </refmeta>
32
33       <refnamediv>
34         <refname>udev</refname>
35         <refpurpose>dynamic device management</refpurpose>
36       </refnamediv>
37
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>
42
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. The program
46         <command>udev</command> itself may be used as an event handler in situations,
47         where running the daemon is not appropriate, like in initramfs.</para>
48
49         <para>If udev receives a device event, it matches its configured rules
50         against the available device attributes provided in sysfs to identify the device.
51         Rules that match, may provide additional device information or specify a device
52         node name and multiple symlink names and instruct udev to run additional programs
53         as part of the device event handling.</para>
54       </refsect1>
55
56       <refsect1><title>CONFIGURATION</title>
57         <para>All udev configuration files are placed in <filename>/etc/udev/*</filename>.
58         Every file consist of a set of lines of text. All empty lines or lines beginning
59         with '#' will be ignored.</para>
60
61         <refsect2><title>Configuration file</title>
62           <para>udev expects its main configuration file at <filename>/etc/udev/udev.conf</filename>.
63           It consists of a set of variables allowing the user to override default udev values.
64           The following variables can be set:</para>
65           <variablelist>
66             <varlistentry>
67               <term><option>udev_root</option></term>
68               <listitem>
69                 <para>Specifies where to place the device nodes in the filesystem.
70                 The default value is <filename>/dev</filename>.</para>
71               </listitem>
72             </varlistentry>
73
74             <varlistentry>
75               <term><option>udev_rules</option></term>
76               <listitem>
77                 <para>The name of the udev rules file or directory to look for files
78                 with the suffix <filename>.rules</filename>. Multiple rule files are
79                 read in lexical order. The default value is
80                 <filename>/etc/udev/rules.d</filename>.</para>
81               </listitem>
82             </varlistentry>
83
84             <varlistentry>
85               <term><option>udev_log</option></term>
86               <listitem>
87                 <para>The logging priority. Valid values are the numerical syslog priorities
88                 or their textual representations: <option>err</option>, <option>info</option>
89                 and <option>debug</option>.</para>
90               </listitem>
91             </varlistentry>
92           </variablelist>
93         </refsect2>
94
95         <refsect2><title>Rules files</title>
96           <para>The udev rules are read from the files located in the
97           <filename>/etc/udev/rules.d</filename> directory or at the location specified
98           value in the configuraton file. Every line in the rules file contains at least
99           one key value pair. There are two kind of keys, match and assignement keys.
100           If all match keys are matching against its value, the rule gets applied and the
101           assign keys get the specified value assigned. A matching rule may specify the
102           name of the device node, add a symlink pointing to the node, or run a specified
103           program as part of the event handling. If no matching rule is found, the default
104           device node name is used.</para>
105
106           <para>A rule may consists of a list of one or more key value pairs separated by
107           a comma. Each key has a distinct operation, depending on the used operator. Valid
108           operators are:</para>
109           <variablelist>
110             <varlistentry>
111               <term><option>==</option></term>
112               <listitem>
113                 <para>Compare for equality.</para>
114               </listitem>
115             </varlistentry>
116
117             <varlistentry>
118               <term><option>!=</option></term>
119               <listitem>
120                 <para>Compare for non-equality.</para>
121               </listitem>
122             </varlistentry>
123
124             <varlistentry>
125               <term><option>=</option></term>
126               <listitem>
127                 <para>Asign a value to a key. Keys that represent a list, are reset
128                 and only this single value is assigned.</para>
129               </listitem>
130             </varlistentry>
131
132             <varlistentry>
133               <term><option>+=</option></term>
134               <listitem>
135                 <para>Add the value to a key that holds a list of entries.</para>
136               </listitem>
137             </varlistentry>
138
139             <varlistentry>
140               <term><option>:=</option></term>
141               <listitem>
142                 <para>Assign  a  value  to  a key finally; disallow any later changes,
143                 which may be used to prevent changes by any later rules.</para>
144               </listitem>
145             </varlistentry>
146           </variablelist>
147
148           <para>The following key names can be used to match against device properties:</para>
149           <variablelist>
150             <varlistentry>
151               <term><option>ACTION</option></term>
152               <listitem>
153                 <para>Match the kernel action name.</para>
154               </listitem>
155             </varlistentry>
156
157             <varlistentry>
158               <term><option>KERNEL</option></term>
159               <listitem>
160                 <para>Match the kernel device name</para>
161               </listitem>
162             </varlistentry>
163
164             <varlistentry>
165               <term><option>DEVPATH</option></term>
166               <listitem>
167                 <para>Match the kernel devpath.</para>
168               </listitem>
169             </varlistentry>
170
171             <varlistentry>
172               <term><option>SUBSYSTEM</option></term>
173               <listitem>
174                 <para>Match the kernel subsystem name</para>
175               </listitem>
176             </varlistentry>
177
178             <varlistentry>
179               <term><option>BUS</option></term>
180               <listitem>
181                 <para>Match the typ of bus the device is connected to.</para>
182               </listitem>
183             </varlistentry>
184
185             <varlistentry>
186               <term><option>DRIVER</option></term>
187               <listitem>
188                 <para>Match the kernel driver name.</para>
189               </listitem>
190             </varlistentry>
191
192             <varlistentry>
193               <term><option>ID</option></term>
194               <listitem>
195                 <para>Match the device number on the bus.</para>
196               </listitem>
197             </varlistentry>
198
199             <varlistentry>
200               <term><option>ENV{<replaceable>key</replaceable>}</option></term>
201               <listitem>
202                 <para>Match against the value of an environment key. Depending on
203                 the specified operation, this key is also used as a assignment.</para>
204               </listitem>
205             </varlistentry>
206
207             <varlistentry>
208               <term><option>SYSFS{<replaceable>filename</replaceable>}</option></term>
209               <listitem>
210                 <para>Match the sysfs attribute value. Up to five values can be specified.
211                 Trailing whitespace is ignored, if the specified match value does not contain
212                 trailing whitespace itself.</para>
213               </listitem>
214             </varlistentry>
215
216             <varlistentry>
217               <term><option>PROGRAM</option></term>
218               <listitem>
219                 <para>Execute external program. The key is true, if the program returns
220                 without exit code zero. The whole event environment is available to the
221                 executed program. The program's output printed to stdout is available for
222                 the RESULT key.</para>
223               </listitem>
224             </varlistentry>
225
226             <varlistentry>
227               <term><option>RESULT</option></term>
228               <listitem>
229                 <para>Match the returned string of the last PROGRAM call. This key can
230                 be used in the same or in any later rule after a PROGRAM call.</para>
231               </listitem>
232             </varlistentry>
233           </variablelist>
234
235           <para>Most of the fields support a shell style pattern matching. The following
236           pattern characters are supported:</para>
237           <variablelist>
238             <varlistentry>
239               <term><option>*</option></term>
240               <listitem>
241                 <para>Matches zero, or any number of characters.</para>
242               </listitem>
243             </varlistentry>
244             <varlistentry>
245               <term><option>?</option></term>
246               <listitem>
247                 <para>Matches any single character.</para>
248               </listitem>
249             </varlistentry>
250             <varlistentry>
251               <term><option>[]</option></term>
252               <listitem>
253                 <para>Matches any single character specified within the brackets.
254                 example, the pattern string 'tty[SR]' would match either 'ttyS' or 'ttyR'.
255                 Ranges are also supported within this match with the '-' character.
256                 For example, to match on the range of all digits, the pattern [0-9] would
257                 be used. If the first character following the '[' is a '!', any characters
258                 not enclosed are matched.</para>
259               </listitem>
260             </varlistentry>
261           </variablelist>
262
263           <para>The following keys can get values assigned:</para>
264           <variablelist>
265             <varlistentry>
266               <term><option>NAME</option></term>
267               <listitem>
268                 <para>The name of the node to be created, or the name, the network interface
269                 should be renamed to. Only one rule can set the a name, all later rules with
270                 a NAME key will be ignored.</para>
271               </listitem>
272             </varlistentry>
273
274             <varlistentry>
275               <term><option>SYMLINK</option></term>
276               <listitem>
277                 <para>The name of a symlink targeting the node. Every matching rule can add
278                 this value to the list of symlinks to be created along with the device  node.
279                 Multiple symlinks may be specified by separating the names by the space
280                 character.</para>
281               </listitem>
282             </varlistentry>
283
284             <varlistentry>
285               <term><option>OWNER, GROUP, MODE</option></term>
286               <listitem>
287                 <para>The permissions for the device node. Every specified value over writes
288                 the compiled-in default value.</para>
289               </listitem>
290             </varlistentry>
291
292             <varlistentry>
293               <term><option>ENV{<replaceable>key</replaceable>}</option></term>
294               <listitem>
295                 <para>Export the key to the environment. Depending on the specified
296                 operation, this key is also used as a match.</para>
297               </listitem>
298             </varlistentry>
299
300             <varlistentry>
301               <term><option>RUN</option></term>
302               <listitem>
303                 <para>Add a program to the list of programs to be executed for a specific
304                 device.</para>
305               </listitem>
306             </varlistentry>
307
308             <varlistentry>
309               <term><option>LABEL</option></term>
310               <listitem>
311                 <para>Named label where a GOTO can jump to.</para>
312               </listitem>
313             </varlistentry>
314
315             <varlistentry>
316               <term><option>GOTO</option></term>
317               <listitem>
318                 <para>Jumps to the next LABEL with a matching gname</para>
319               </listitem>
320             </varlistentry>
321
322             <varlistentry>
323               <term><option>IMPORT{<replaceable>type</replaceable>}</option></term>
324               <listitem>
325                 <para>Import the printed result or the content of a file in environment key
326                 format into the event environment. <option>program</option> will execute an
327                 external program and read its output. <option>file</option> will inport a
328                 text file. If no option is given, udev will determine it from the  executable
329                 bit of of the file permissions.</para>
330               </listitem>
331             </varlistentry>
332
333             <varlistentry>
334               <term><option>WAIT_FOR_SYSFS</option></term>
335               <listitem>
336                 <para>Wait for the specified sysfs file of the device to be created. May be used
337                 to fight agains timing issues wth the kernel.</para>
338               </listitem>
339             </varlistentry>
340
341             <varlistentry>
342               <term><option>OPTIONS</option></term>
343               <listitem>
344                 <para><option>last_rule</option> stops further rules application. No later rules
345                 will have any effect.
346                 <option>ignore_device</option> will ignore this event completely.
347                 <option>ignore_remove</option> will ignore  any  later  remove  event  for  this
348                 device. This may be useful as a workaround for broken device drivers.
349                 <option>all_partitions</option> will create device nodes for all available partitions of
350                 a block device. This may be useful for removable media.</para>
351               </listitem>
352             </varlistentry>
353           </variablelist>
354
355           <para>The <option>NAME</option>, <option>SYMLINK</option>, <option>PROGRAM</option>,
356           <option>OWNER</option>  and  <option>GROUP</option>  fields  support  simple
357           printf-like string substitutions:</para>
358           <variablelist>
359             <varlistentry>
360               <term><option>%k</option>, <option>$kernel</option></term>
361               <listitem>
362                 <para>The kernel name for this device.</para>
363               </listitem>
364             </varlistentry>
365
366             <varlistentry>
367               <term><option>%b</option>, <option>$id</option></term>
368               <listitem>
369                 <para>The kernel bus id for this device.</para>
370               </listitem>
371             </varlistentry>
372
373             <varlistentry>
374               <term><option>%n</option>, <option>$number</option></term>
375               <listitem>
376                 <para>The kernel number for this device. For example, 'sda3' has
377                 kernel number of '3'</para>
378               </listitem>
379             </varlistentry>
380
381             <varlistentry>
382               <term><option>%p</option>, <option>$devpath</option></term>
383               <listitem>
384                 <para>The devpath of the device.</para>
385               </listitem>
386             </varlistentry>
387
388             <varlistentry>
389               <term><option>%s{<replaceable>file</replaceable>}</option>, <option>$sysfs{<replaceable>file</replaceable>}</option></term>
390               <listitem>
391                 <para>The content of a sysfs attribute.</para>
392               </listitem>
393             </varlistentry>
394
395             <varlistentry>
396               <term><option>%e{<replaceable>key</replaceable>}</option>, <option>$env{<replaceable>key</replaceable>}</option></term>
397               <listitem>
398                 <para>The value of an environment variable.</para>
399               </listitem>
400             </varlistentry>
401
402             <varlistentry>
403               <term><option>%m</option>, <option>$major</option></term>
404               <listitem>
405                 <para>The kernel major number for the device.</para>
406               </listitem>
407             </varlistentry>
408
409             <varlistentry>
410               <term><option>%M</option> <option>$minor</option></term>
411               <listitem>
412                 <para>The kernel minor number for the device.</para>
413               </listitem>
414             </varlistentry>
415
416             <varlistentry>
417               <term><option>%c</option>, <option>$result</option></term>
418               <listitem>
419                 <para>The string returned by the external program requested with PROGRAM.
420                 A single part of the string, separated by a space character may be selected
421                 by specifying the part number as an attribute: <option>%c{N}</option>.
422                 If the number is followed by the '+' char this part plus all remaining parts
423                 of the result string are substituted: <option>%c{N+}</option></para>
424               </listitem>
425             </varlistentry>
426
427             <varlistentry>
428               <term><option>%e</option>, <option>$enum</option></term>
429               <listitem>
430                 <para>If a device node already exists with the name, the smallest next free
431                 number is used. This  can be used to create compatibility symlinks and enumerate
432                 devices of the same type originating from different kernel subsystems.</para>
433                 <para>Note: The use of the enumeration facility is unreliable for events that
434                 request a number at the same time. The  use  of enumerations in todays setups
435                 where devices can come and go at any time is not recommended.</para>
436               </listitem>
437             </varlistentry>
438
439             <varlistentry>
440               <term><option>%P</option>, <option>$parent</option></term>
441               <listitem>
442                 <para>The node name of the parent device.</para>
443               </listitem>
444             </varlistentry>
445
446             <varlistentry>
447               <term><option>%r</option>, <option>$root</option></term>
448               <listitem>
449                 <para>The udev_root value.</para>
450               </listitem>
451             </varlistentry>
452
453             <varlistentry>
454               <term><option>%N</option>, <option>$tempnode</option></term>
455               <listitem>
456                 <para>The name of a created temporary device node to provide access to
457                 the device from a external program before the real node is created.</para>
458               </listitem>
459             </varlistentry>
460
461             <varlistentry>
462               <term><option>%%</option></term>
463               <listitem>
464               <para>The '%' character itself.</para>
465               </listitem>
466             </varlistentry>
467
468             <varlistentry>
469               <term><option>$$</option></term>
470               <listitem>
471               <para>The '$' character itself.</para>
472               </listitem>
473             </varlistentry>
474           </variablelist>
475           <para>The count of characters to be substituted may be limited by specifying
476           the format length value. For example, '%3s{file}' will only
477           insert the first three characters of the sysfs attribute</para>
478         </refsect2>
479       </refsect1>
480
481       <refsect1><title>ENVIRONMENT</title>
482         <variablelist>
483           <varlistentry>
484             <term><option>ACTION</option></term>
485             <listitem>
486               <para><replaceable>add</replaceable> or <replaceable>remove</replaceable> signifies
487               the addition or the removal of a device.</para>
488             </listitem>
489           </varlistentry>
490
491           <varlistentry>
492             <term><option>DEVPATH</option></term>
493             <listitem>
494               <para>The sysfs devpath without the mountpoint but a leading slash.</para>
495             </listitem>
496           </varlistentry>
497
498           <varlistentry>
499             <term><option>SUBSYSTEM</option></term>
500             <listitem>
501               <para>The kernel subsystem the device belongs to.</para>
502             </listitem>
503           </varlistentry>
504
505           <varlistentry>
506             <term><option>UDEV_LOG</option></term>
507             <listitem>
508               <para>Overrides the syslog priority specified in the config file.</para>
509             </listitem>
510           </varlistentry>
511         </variablelist>
512      </refsect1>
513
514       <refsect1><title>AUTHOR</title>
515         <para>Written by Greg Kroah-Hartman <email>greg@kroah.com</email> and
516         Kay Sievers <email>kay.sievers@vrfy.org</email>. With much help from
517         Dan  Stekloff <email>dsteklof@us.ibm.com</email> and many others.</para>
518       </refsect1>
519
520       <refsect1>
521         <title>SEE ALSO</title>
522         <para><citerefentry>
523             <refentrytitle>udev</refentrytitle><manvolnum>8</manvolnum>
524           </citerefentry>, 
525           <citerefentry>
526             <refentrytitle>udevinfo</refentrytitle><manvolnum>8</manvolnum>
527           </citerefentry>, 
528           <citerefentry>
529             <refentrytitle>udevd</refentrytitle><manvolnum>8</manvolnum>
530           </citerefentry>, 
531           <citerefentry>
532             <refentrytitle>udevmonitor</refentrytitle><manvolnum>8</manvolnum>
533         </citerefentry></para>
534       </refsect1>
535     </refentry>
536   </section>
537 </article>