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