chiark / gitweb /
328f602e031708640023afbe938a4a39ce1b938b
[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 " hotplug-subsystem"
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_permissions
59 The name of the udev permission file or directory to look for files with the
60 suffix
61 .IR .permissions .
62 All permission files are read in lexical order. The default value is
63 .IR /etc/udev/permissions.d/ .
64 .TP
65 .B udev_log
66 The switch to enable/disable logging of udev information
67 The default value is
68 .IR yes .
69 .TP
70 .B default_mode
71 The default mode for all nodes not explicitly matching in the permissions
72 file. The default value is
73 .IR 0666 .
74 .TP
75 .B default_owner
76 The default owner for all nodes not explicitly matching in the permissions
77 file. The default value is
78 .IR root .
79 .TP
80 .B default_group
81 The default group for all nodes not explicitly matching in the permissions
82 file. The default value is
83 .IR root .
84 .br
85 .P
86 .RI "A sample " udev.conf " file might look like this:
87 .sp
88 .nf
89 # udev_root - where to place the device nodes in the filesystem
90 udev_root="/udev"
91
92 # udev_db - The name and location of the udev database
93 udev_db="/udev/.udevdb"
94
95 # udev_rules - The name of the udev rules file or directory to look
96                for files with the suffix .rules
97 udev_rules="/etc/udev/rules.d/"
98
99 # udev_permissions - The name of the udev permission file or directory
100                      to look for files with the suffix .permissions
101 udev_permissions="/etc/udev/udev.permissions"
102
103 # udev_log - set to "yes" if you want logging, else "no"
104 udev_log="yes"
105
106 # default_mode - set the default mode for all nodes not
107 #                explicitly matching in the permissions file
108 default_mode="0666"
109
110 # default_owner - set the default owner for all nodes not
111 #                 explicitly matching in the permissions file
112 default_owner="root"
113
114 # default_group - set the default group for all nodes not
115 #                 explicitly matching in the permissions file
116 default_group="root"
117 .fi
118 .P
119 The rules for device naming are read from the files located in the
120 .I /etc/udev/rules.d/
121 directory, or at the location specified by the
122 .I udev_rules
123 value in the
124 .I /etc/udev/udev.conf
125 file.
126 .br
127 Every line in the rules file defines the mapping between device attributes
128 and the device name. One or more keys are specified to match a rule with
129 the current device. If all keys are matching, the rule will be applied and
130 the name is used to name the device file or the network interface.
131 .br
132 If no matching rule is found, the default kernel device name is used.
133 .P
134 Every rule consists of a list of comma separated fields:
135 .sp
136 .IR "key " ,[ "key " ,...] " name " [, " symlink" ]
137 .sp
138 where fields are:
139 .TP
140 .B BUS
141 Match the bus type of the device.
142 (The sysfs device bus must be able to be determined by a "device" symlink.)
143 .TP
144 .B KERNEL
145 Match the kernel device name.
146 .TP
147 .B SUBSYSTEM
148 Match the kernel subsystem name.
149 .TP
150 .B DRIVER
151 Match the kernel driver name.
152 .TP
153 .B ID
154 Match the device number on the bus, like PCI bus id.
155 .TP
156 .B PLACE
157 Match the topological position on bus, like physical port of USB device
158 .TP
159 .BI SYSFS{ filename }
160 Match sysfs device attribute like label, vendor, USB serial number, SCSI UUID
161 or file system label. Up to 5 different sysfs files can be checked, with
162 all of the values being required to match the rule.
163 .br
164 Trailing whitespace characters in the sysfs attribute value are ignored, if
165 the key doesn't have any trailing whitespace characters by itself.
166 .TP
167 .B PROGRAM
168 Call external program. This key is valid if the program returns successful.
169 The environment variables of
170 .B udev
171 are also available for the program.
172 .br
173 The string returned by the program may be additionally matched with the
174 .B RESULT
175 key.
176 .TP
177 .B RESULT
178 Match the returned string of the last
179 .B PROGRAM
180 call. This key may be used in any following rule after a
181 .B PROGRAM
182 call.
183 .TP
184 .B NAME
185 The name of the node to be created, or the name, the network interface
186 should be renamed to.
187 .br
188 If given with the attribute
189 .BR NAME{ all_partitions }
190 .B udev
191 will create device nodes for all 15 partitions of a blockdevice.
192 This may be useful for removable media devices.
193 .br
194 If given with the attribute
195 .BR NAME{ ignore_remove }
196 .B udev
197 will ignore any later remove event for this device.
198 This may be useful as a workaround for broken device drivers.
199 .sp
200 Multiple attributes may be separated by comma.
201 .TP
202 .B SYMLINK
203 The name of a symlink targeting the node. Multiple symlinks may be
204 specified by separating the names by the space character.
205 .br
206 If both the name and the symlink fields are omitted or its
207 values are empty, the device will be ignored and no node will be created.
208 .br
209 If only the symlink field is given and the name field is omitted,
210 the rule will not be applied immediately, but the symlink field is added
211 to the symlink list of the rule which will create the node.
212 This makes it possible to specify additional symlinks in a possibly
213 separate rules file, while the device nodes are maintained by the
214 distribution provided rules file.
215 .TP
216 .B OWNER, GROUP, MODE
217 The permissions for this device. Every specified value overwrites the value
218 given in the permissions file.
219 .P
220 .RB "The " NAME " ," SYMLINK " and " PROGRAM
221 fields support simple printf-like string substitutions:
222 .TP
223 .B %n
224 The "kernel number" of the device.
225 For example, 'sda3' has a "kernel number" of '3'.
226 .TP
227 .B %k
228 The "kernel name" for the device.
229 .TP
230 .B %M
231 The kernel major number for the device.
232 .TP
233 .B %m
234 The kernel minor number for the device.
235 .TP
236 .B %b
237 The bus id for the device.
238 .TP
239 .B %c
240 The string returned by the external program, specified in
241 .B PROGRAM
242 (This does not work within the
243 .B PROGRAM
244 field for the obvious reason.)
245 .br
246 A single part of the string, separated by a space character
247 may be selected by specifying the part number as an attribute:
248 .BI %c{ N }
249 If the number is followed by the + char this part plus
250 all remaining parts of the result string are substituted:
251 .BI %c{ N+ }
252 .TP
253 .BI %s{ filename }
254 The content of a sysfs attribute.
255 .TP
256 .B %e
257 If a device node already exists with the name, the smallest positive
258 decimal integer N is substituted such that the resulting name doesn't
259 match an existing device node. Otherwise nothing is substituted. This
260 can be used to create compatibility symlinks and enumerate devices of
261 the same type originating from different kernel subsystems.
262 .TP
263 .B %%
264 The '%' character itself.
265 .P
266 The count of charcters to insert may be limited by specifying
267 the format length value. For example, '%3s{file}' will only insert
268 the first three characters of the sysfs attribute.
269 .P
270 .RI "A sample " udev.rules " file might look like this:"
271 .sp
272 .nf
273 # if /sbin/scsi_id returns "OEM 0815", the device will be called disk1
274 BUS="scsi", PROGRAM="/sbin/scsi_id", RESULT="OEM 0815", NAME="disk1"
275
276 # USB printer to be called lp_color
277 BUS="usb", SYSFS{serial}="W09090207101241330", NAME="lp_color"
278
279 # SCSI disk with a specific vendor and model number will be called boot
280 BUS="scsi", SYSFS{vendor}="IBM", SYSFS{model}="ST336", NAME="boot%n"
281
282 # sound card with PCI bus id 00:0b.0 to be called dsp
283 BUS="pci", ID="00:0b.0", NAME="dsp"
284
285 # USB mouse at third port of the second hub to be called mouse1
286 BUS="usb", PLACE="2.3", NAME="mouse1"
287
288 # ttyUSB1 should always be called pda with two additional symlinks
289 KERNEL="ttyUSB1", NAME="pda", SYMLINK="palmtop handheld"
290
291 # multiple USB webcams with symlinks to be called webcam0, webcam1, ...
292 BUS="usb", SYSFS{model}="XV3", NAME="video%n", SYMLINK="webcam%n"
293
294 # grouping of optical drives from multiple kernel subsystems
295 KERNEL="sr*", NAME="%k", SYMLINK="cdrom%e"
296 KERNEL="scd*", NAME="%k", SYMLINK="cdrom%e"
297 KERNEL="pcd*", NAME="%k", SYMLINK="cdrom%e"
298 KERNEL="hd[a-z]", PROGRAM="/bin/cat /proc/ide/%k/media", RESULT="cdrom",
299   NAME="%k", SYMLINK="cdrom%e"
300 .fi
301 .P
302 The permissions and ownership of the created device file are read from
303 the files located in the
304 .I /etc/udev/permissions.d/
305 directory, or at the location specified by the
306 .I udev_permission
307 value in the
308 .I /etc/udev/udev.conf
309 file.
310 .br
311 Every line lists a device name followed by owner, group and permission
312 mode. All values are separated by colons. The name field may contain a
313 pattern to apply the values to a whole class of devices.
314 .sp
315 .RI "A sample " udev.permissions " file might look like this:"
316 .sp
317 .nf
318 #name:user:group:mode
319 input/*:root:root:644
320 ttyUSB1:0:8:0660
321 video*:root:video:0660
322 dsp1:::0666
323 .fi
324 .P
325 A number of different fields in the above configuration files support a simple
326 form of shell style pattern matching. It supports the following pattern characters:
327 .TP
328 .B *
329 Matches zero, one, or more characters.
330 .TP
331 .B ?
332 Matches any single character, but does not match zero characters.
333 .TP
334 .B [ ]
335 Matches any single character specified within the brackets. For example, the
336 pattern string "tty[SR]" would match either "ttyS" or "ttyR". Ranges are also
337 supported within this match with the '\-' character. For example, to match on
338 the range of all digits, the pattern [0\-9] would be used. If the first character
339 following the '[' is a '!', any characters not enclosed are matched.
340 .P
341 After device node creation, removal, or network device renaming,
342 .B udev
343 executes the programs located in the directory tree under
344 .IR /etc/dev.d/ .
345 The name of a program must have the suffix
346 .I .dev
347 to be recognized.
348 .br
349 In addition to the hotplug environment variables,
350 .B UDEV_LOG
351 is set if udev is configured to use the syslog facility. Executed programs may
352 want to follow that setting.
353 .B DEVNAME
354 is exported to make the name of the created node, or the name the network
355 device is renamed to, available to the executed program. The programs in every
356 directory are sorted in lexical order, while the directories are searched in
357 the following order:
358 .sp
359 .nf
360 /etc/dev.d/$(DEVNAME)/*.dev
361 /etc/dev.d/$(SUBSYSTEM)/*.dev
362 /etc/dev.d/default/*.dev
363 .fi
364 .SH "ENVIRONMENT"
365 .P
366 The following variables are read from the environment:
367 .TP
368 .B ACTION
369 .IR add " or " remove
370 signifies the addition or the removal of a device.
371 .TP
372 .B DEVPATH
373 The sysfs devpath of the device without the mountpoint but a leading slash.
374 .TP
375 .B SUBSYSTEM
376 The subsystem the device belongs to. Alternatively the subsystem may
377 be passed as the first argument.
378 .TP
379 .B UDEV_CONFIG_FILE
380 Overrides the default location of the
381 .B udev
382 config file.
383 .TP
384 .B UDEV_NO_DEVD
385 The default behavior of
386 .B udev
387 is to execute programs in the
388 .I /etc/dev.d/
389 directory after device handling. If set,
390 .B udev
391 will skip this step.
392 .SH "FILES"
393 .nf
394 /sbin/udev                           udev program
395 /etc/udev/*                          udev config files
396 /etc/hotplug.d/default/udev.hotplug  hotplug symlink to udev program
397 /etc/dev.d/*                         programs invoked by udev
398 .fi
399 .SH "SEE ALSO"
400 .BR udevinfo (8),
401 .BR udevd (8),
402 .BR hotplug (8)
403 .PP
404 .B Web resources:
405 .nf
406 .I http://linux\-hotplug.sourceforge.net/
407 .I http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html
408 .fi
409 .SH AUTHORS
410 .B udev
411 was developed by Greg Kroah-Hartman <greg@kroah.com> with much help from
412 Dan Stekloff <dsteklof@us.ibm.com>, Kay Sievers <kay.sievers@vrfy.org>, and
413 many others.