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