chiark / gitweb /
3527d6912f059d098108e9459c2556c5bb005a70
[elogind.git] / udev.8.in
1 .TH UDEV 8 "October 2003" "" "Linux Administrator's Manual"
2 .SH NAME
3 udev \- Linux configurable dynamic device naming support
4 .SH SYNOPSIS
5 .BI udev
6 .SH "DESCRIPTION"
7 .B udev
8 provides a dynamic device directory containing only the files for actually
9 present devices. It creates or removes device node files usually located in
10 the /dev directory, or it renames network interfaces.
11 .br
12 .P
13 As part of the
14 .B hotplug
15 subsystem,
16 .B udev
17 is executed if a kernel device is added or removed from the system.
18 On device creation,
19 .B udev
20 reads the sysfs directory of the given device to collect device attributes
21 like label, serial number or bus device number.
22 These attributes may be used as keys to determine a
23 unique name for the device.
24 .B udev
25 maintains a database for devices present on the system.
26 .br
27 On device removal,
28 .B udev
29 queries its database for the name of the device file to be deleted.
30 .SH "CONFIGURATION"
31 All
32 .B udev
33 configuration files consist of a set of lines of text. All empty
34 lines or lines beginning with '#' will be ignored.
35 .P
36 .B udev
37 expects its main configuration file at
38 .IR /etc/udev/udev.conf .
39 The file consists of a set of variables and values allowing the user to
40 override default udev values. The following variables can be overridden
41 in this file:
42 .TP
43 .B udev_root
44 Indicates where to place the device nodes in the filesystem. The default
45 value is
46 .IR @udevdir@/ .
47 .TP
48 .B udev_db
49 The name and location of the udev database. The default value is
50 .IR @udevdir@/.udevdb .
51 .TP
52 .B udev_rules
53 The name of the udev rules file or directory to look for files with the suffix
54 .IR .rules .
55 All rule files are read in lexical order. The default value is
56 .IR /etc/udev/rules.d/ .
57 .TP
58 .B udev_log
59 The logging priority which can be set to
60 .IR "err " , "info "
61 or the corresponding numerical
62 .BR syslog (3)
63 value.
64 The default value is
65 .IR err .
66 .P
67 .RI "A sample " udev.conf " file might look like this:
68 .sp
69 .nf
70 # Where in the filesystem to place the device nodes
71 udev_root="@udevdir@"
72
73 # The name and location of the udev database.
74 udev_db="@udevdir@/.udevdb"
75
76 # The name and location of the udev rules file(s).
77 udev_rules="@configdir@/rules.d"
78
79 # The syslog(3) priority: "err", "info", or the numerical value.
80 udev_log="err"
81 .fi
82 .P
83 The rules for device naming are read from the files located in the
84 .I /etc/udev/rules.d/
85 directory, or at the location specified by the
86 .I udev_rules
87 value in the
88 .I /etc/udev/udev.conf
89 file.
90 .br
91 Every line in the rules file defines the mapping between device attributes
92 and the device name. One or more keys are specified to match a rule with
93 the current device. If all keys are matching, the rule will be applied and
94 the name is used to name the device file or the network interface.
95 .br
96 If no matching rule is found, the default kernel device name is used.
97 .P
98 Every rule consists of a list of comma separated key value fields:
99 .sp
100 .IR "key " ,[ "key " ,...]
101 .P
102 The following key names can be used to match against device properties:
103 .TP
104 .B BUS
105 Match the bus type of the device.
106 (The sysfs device bus must be able to be determined by a "device" symlink.)
107 .TP
108 .B KERNEL
109 Match the kernel device name.
110 .TP
111 .B SUBSYSTEM
112 Match the kernel subsystem name.
113 .TP
114 .B ACTION
115 Match the kernel action name.
116 .TP
117 .B DRIVER
118 Match the kernel driver name.
119 .TP
120 .B ID
121 Match the device number on the bus, like PCI bus id.
122 .TP
123 .BI SYSFS{ filename }
124 Match sysfs device attribute like vendor and product id's, USB serial number
125 or the SCSI disk model number. Up to 5 different sysfs files can be checked,
126 with all of the values being required to match the rule.
127 .br
128 Trailing whitespace characters in the sysfs attribute value are ignored, if
129 the key doesn't have any trailing whitespace characters by itself.
130 .TP
131 .BI ENV{ variable }
132 Match an environment variable. Up to 5 different environment variables can be
133 checked, with all of the values being required to match the rule.
134 .TP
135 .B PROGRAM
136 Call external program. This key is valid if the program returns successful.
137 The environment variables of
138 .B udev
139 are also available to the program.
140 .br
141 The string returned by the program may be additionally matched with the
142 .B RESULT
143 key in the same or any later rule.
144 .TP
145 .B RESULT
146 Match the returned string of the last
147 .B PROGRAM
148 call. This key can be used in the same or in any later rule after a
149 .B PROGRAM
150 call.
151 .P
152 The following keys can get values assigned:
153 .TP
154 .B NAME
155 The name of the node to be created, or the name, the network interface
156 should be renamed to.
157 .TP
158 .B SYMLINK
159 The name of a symlink targeting the node. Multiple symlinks may be
160 specified by separating the names by the space character.
161 .br
162 If both the name and the symlink fields are omitted or its
163 values are empty, the device will be ignored and no node will be created.
164 .br
165 If only the symlink field is given and the name field is omitted,
166 the rule will not be applied immediately, but the symlink field is added
167 to the symlink list of the rule which will create the node.
168 This makes it possible to specify additional symlinks in a possibly
169 separate rules file, while the device nodes are maintained by the
170 distribution provided rules file.
171 .TP
172 .B OWNER, GROUP, MODE
173 The permissions for the device node. Every specified value overwrites the
174 compiled-in default value.
175 .TP
176 .B RUN
177 Add a program to the list of programs to be executed for a specific device.
178 .TP
179 .B OPTIONS
180 .B last_rule
181 will be the last rule applied. No later rules will have any effect.
182 .sp
183 .B ignore_device
184 will ignore this device. No node will be created.
185 .sp
186 .B ignore_remove
187 will ignore any later remove event for this device.
188 This may be useful as a workaround for broken device drivers.
189 .sp
190 .B all_partitions
191 will create device nodes for all available partitions of a blockdevice.
192 This may be useful for removable media devices which do not detect a media
193 change.
194 .sp
195 Multiple attributes may be separated by comma.
196 .P
197 .RB "The " NAME ", " SYMLINK ", " PROGRAM ", " OWNER " and " GROUP
198 fields support simple printf-like string substitutions:
199 .TP
200 .B %n
201 The "kernel number" of the device.
202 For example, 'sda3' has a "kernel number" of '3'.
203 .TP
204 .B %k
205 The "kernel name" for the device.
206 .TP
207 .B %p
208 The devpath for the device.
209 .TP
210 .B %M
211 The kernel major number for the device.
212 .TP
213 .B %m
214 The kernel minor number for the device.
215 .TP
216 .B %b
217 The bus id for the device.
218 .TP
219 .B %c
220 The string returned by the external program, specified in
221 .B PROGRAM
222 (This does not work within the
223 .B PROGRAM
224 field for the obvious reason.)
225 .br
226 A single part of the string, separated by a space character
227 may be selected by specifying the part number as an attribute:
228 .BI %c{ N }
229 If the number is followed by the + char this part plus
230 all remaining parts of the result string are substituted:
231 .BI %c{ N+ }
232 .TP
233 .B %N
234 The name of a created temporary device node to provide access to the
235 device from a external program.
236 .TP
237 .B %P
238 The node name of the parent device.
239 .TP
240 .BI %s{ filename }
241 The content of a sysfs attribute.
242 .TP
243 .B %r
244 The udev_root value.
245 .TP
246 .B %e
247 If a device node already exists with the name, the smallest positive
248 decimal integer N is substituted such that the resulting name doesn't
249 match an existing device node. Otherwise nothing is substituted. This
250 can be used to create compatibility symlinks and enumerate devices of
251 the same type originating from different kernel subsystems.
252 .sp
253 Note: The use of the enumeration facility is unreliable outside of
254 udevstart where the node creation is serialized and predictable.
255 The returned numbers rely on the order devices are probed on the
256 system. If more than one device requests an enumeration for the same
257 name at the same time, it may be possible that both requests receive the
258 same name back from the database. The use of enumerations in todays setups
259 where device can come and go at any time is not recomended.
260 .TP
261 .B %%
262 The '%' character itself.
263 .P
264 The count of charcters to insert may be limited by specifying
265 the format length value. For example, '%3s{file}' will only insert
266 the first three characters of the sysfs attribute.
267 .P
268 .RI "A sample " udev.rules " file might look like this:"
269 .sp
270 .nf
271 # if /sbin/scsi_id returns "OEM 0815", the device will be called disk1
272 BUS=="scsi", PROGRAM=="/sbin/scsi_id", RESULT=="OEM 0815", NAME="disk1"
273
274 # USB printer to be called lp_color
275 BUS=="usb", SYSFS{serial}=="W09090207101241330", NAME="lp_color"
276
277 # SCSI disk with a specific vendor and model number will be called boot
278 BUS=="scsi", SYSFS{vendor}=="IBM", SYSFS{model}=="ST336", NAME="boot%n"
279
280 # sound card with PCI bus id 00:0b.0 to be called dsp
281 BUS=="pci", ID=="00:0b.0", NAME="dsp"
282
283 # USB mouse at third port of the second hub to be called mouse1
284 BUS=="usb", ID=="2.3", NAME="mouse1"
285
286 # ttyUSB1 should always be called pda with two additional symlinks
287 KERNEL=="ttyUSB1", NAME="pda", SYMLINK="palmtop handheld"
288
289 # multiple USB webcams with symlinks to be called webcam0, webcam1, ...
290 BUS=="usb", SYSFS{model}=="XV3", NAME=="video%n", SYMLINK="webcam%n"
291 .fi
292 .P
293 A number of different fields in the above configuration files support a simple
294 form of shell style pattern matching. It supports the following pattern characters:
295 .TP
296 .B *
297 Matches zero, one, or more characters.
298 .TP
299 .B ?
300 Matches any single character, but does not match zero characters.
301 .TP
302 .B [ ]
303 Matches any single character specified within the brackets. For example, the
304 pattern string "tty[SR]" would match either "ttyS" or "ttyR". Ranges are also
305 supported within this match with the '\-' character. For example, to match on
306 the range of all digits, the pattern [0\-9] would be used. If the first character
307 following the '[' is a '!', any characters not enclosed are matched.
308 .P
309 After device node creation, removal, or network device renaming,
310 .B udev
311 executes the programs located in the directory tree under
312 .IR /etc/dev.d/ .
313 The name of a program must have the suffix
314 .I .dev
315 to be recognized.
316 .br
317 In addition to the kernel provided hotplug environment variables,
318 .B UDEV_LOG
319 is set and contains the numerical priority value, if udev is configured to use
320 .BR syslog (3).
321 Executed programs may want to follow that setting.
322 .B DEVNAME
323 is exported to make the name of the created node, or the name the network
324 device is renamed to, available to the executed program. The programs in every
325 directory are sorted in lexical order, while the directories are searched in
326 the following order:
327 .sp
328 .nf
329 /etc/dev.d/$(DEVNAME)/*.dev
330 /etc/dev.d/$(SUBSYSTEM)/*.dev
331 /etc/dev.d/default/*.dev
332 .fi
333 .SH "ENVIRONMENT"
334 .P
335 The following variables are read from the environment:
336 .TP
337 .B ACTION
338 .IR add " or " remove
339 signifies the addition or the removal of a device.
340 .TP
341 .B DEVPATH
342 The sysfs devpath of the device without the mountpoint but a leading slash.
343 .TP
344 .B SUBSYSTEM
345 The subsystem the device belongs to. Alternatively the subsystem may
346 be passed as the first argument.
347 .TP
348 .B UDEV_CONFIG_FILE
349 Overrides the default location of the
350 .B udev
351 config file.
352 .TP
353 .B UDEV_LOG
354 Overrides the log priority specified in the config file.
355 .TP
356 .B UDEV_RUN
357 If set to "0", it disables the execution of programs added by rules.
358 .TP
359 .B UDEV_NO_DEVD
360 The default behavior of
361 .B udev
362 is to execute programs in the
363 .I /etc/dev.d/
364 directory after device handling. If set,
365 .B udev
366 will skip this step.
367 .SH "FILES"
368 .nf
369 /sbin/udev                           udev program
370 /etc/udev/*                          udev config files
371 /etc/dev.d/*                         programs invoked by udev
372 .fi
373 .SH "SEE ALSO"
374 .BR udevinfo (8),
375 .BR udevd (8),
376 .BR hotplug (8)
377 .PP
378 .B Web resources:
379 .nf
380 .I http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html
381 .I http://linux\-hotplug.sourceforge.net/
382 .fi
383 .SH AUTHORS
384 .B udev
385 was developed by Greg Kroah-Hartman <greg@kroah.com> with much help from
386 Dan Stekloff <dsteklof@us.ibm.com>, Kay Sievers <kay.sievers@vrfy.org>, and
387 many others.