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