chiark / gitweb /
[PATCH] klibc: version 1.0.5
[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 DRIVER
115 Match the kernel driver name.
116 .TP
117 .B ID
118 Match the device number on the bus, like PCI bus id.
119 .TP
120 .BI SYSFS{ filename }
121 Match sysfs device attribute like vendor and product id's, USB serial number
122 or the SCSI disk model number. Up to 5 different sysfs files can be checked,
123 with all of the values being required to match the rule.
124 .br
125 Trailing whitespace characters in the sysfs attribute value are ignored, if
126 the key doesn't have any trailing whitespace characters by itself.
127 .TP
128 .BI ENV{ variable }
129 Match an environment variable. Up to 5 different environment variables can be
130 checked, with all of the values being required to match the rule.
131 .TP
132 .B PROGRAM
133 Call external program. This key is valid if the program returns successful.
134 The environment variables of
135 .B udev
136 are also available to the program.
137 .br
138 The string returned by the program may be additionally matched with the
139 .B RESULT
140 key in the same or any later rule.
141 .TP
142 .B RESULT
143 Match the returned string of the last
144 .B PROGRAM
145 call. This key can be used in the same or in any later rule after a
146 .B PROGRAM
147 call.
148 .P
149 The following keys can get values assigned:
150 .TP
151 .B NAME
152 The name of the node to be created, or the name, the network interface
153 should be renamed to.
154 .TP
155 .B SYMLINK
156 The name of a symlink targeting the node. Multiple symlinks may be
157 specified by separating the names by the space character.
158 .br
159 If both the name and the symlink fields are omitted or its
160 values are empty, the device will be ignored and no node will be created.
161 .br
162 If only the symlink field is given and the name field is omitted,
163 the rule will not be applied immediately, but the symlink field is added
164 to the symlink list of the rule which will create the node.
165 This makes it possible to specify additional symlinks in a possibly
166 separate rules file, while the device nodes are maintained by the
167 distribution provided rules file.
168 .TP
169 .B OWNER, GROUP, MODE
170 The permissions for the device node. Every specified value overwrites the
171 compiled-in default value.
172 .TP
173 .B OPTIONS
174 .B last_rule
175 will be the last rule applied. No later rules will have any effect.
176 .sp
177 .B ignore_device
178 will ignore this device. No node will be created.
179 .sp
180 .B ignore_remove
181 will ignore any later remove event for this device.
182 This may be useful as a workaround for broken device drivers.
183 .sp
184 .B all_partitions
185 will create device nodes for all available partitions of a blockdevice.
186 This may be useful for removable media devices which do not detect a media
187 change.
188 .sp
189 Multiple attributes may be separated by comma.
190 .P
191 .RB "The " NAME ", " SYMLINK ", " PROGRAM ", " OWNER " and " GROUP
192 fields support simple printf-like string substitutions:
193 .TP
194 .B %n
195 The "kernel number" of the device.
196 For example, 'sda3' has a "kernel number" of '3'.
197 .TP
198 .B %k
199 The "kernel name" for the device.
200 .TP
201 .B %p
202 The devpath for the device.
203 .TP
204 .B %M
205 The kernel major number for the device.
206 .TP
207 .B %m
208 The kernel minor number for the device.
209 .TP
210 .B %b
211 The bus id for the device.
212 .TP
213 .B %c
214 The string returned by the external program, specified in
215 .B PROGRAM
216 (This does not work within the
217 .B PROGRAM
218 field for the obvious reason.)
219 .br
220 A single part of the string, separated by a space character
221 may be selected by specifying the part number as an attribute:
222 .BI %c{ N }
223 If the number is followed by the + char this part plus
224 all remaining parts of the result string are substituted:
225 .BI %c{ N+ }
226 .TP
227 .B %N
228 The name of a created temporary device node to provide access to the
229 device from a external program.
230 .TP
231 .B %P
232 The node name of the parent device.
233 .TP
234 .BI %s{ filename }
235 The content of a sysfs attribute.
236 .TP
237 .B %e
238 If a device node already exists with the name, the smallest positive
239 decimal integer N is substituted such that the resulting name doesn't
240 match an existing device node. Otherwise nothing is substituted. This
241 can be used to create compatibility symlinks and enumerate devices of
242 the same type originating from different kernel subsystems.
243 .sp
244 Note: The use of the enumeration facility is unreliable outside of
245 udevstart where the node creation is serialized and predictable.
246 The returned numbers rely on the order devices are probed on the
247 system. If more than one device requests an enumeration for the same
248 name at the same time, it may be possible that both requests receive the
249 same name back from the database. The use of enumerations in todays setups
250 where device can come and go at any time is not recomended.
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", ID=="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 .fi
283 .P
284 A number of different fields in the above configuration files support a simple
285 form of shell style pattern matching. It supports the following pattern characters:
286 .TP
287 .B *
288 Matches zero, one, or more characters.
289 .TP
290 .B ?
291 Matches any single character, but does not match zero characters.
292 .TP
293 .B [ ]
294 Matches any single character specified within the brackets. For example, the
295 pattern string "tty[SR]" would match either "ttyS" or "ttyR". Ranges are also
296 supported within this match with the '\-' character. For example, to match on
297 the range of all digits, the pattern [0\-9] would be used. If the first character
298 following the '[' is a '!', any characters not enclosed are matched.
299 .P
300 After device node creation, removal, or network device renaming,
301 .B udev
302 executes the programs located in the directory tree under
303 .IR /etc/dev.d/ .
304 The name of a program must have the suffix
305 .I .dev
306 to be recognized.
307 .br
308 In addition to the hotplug environment variables,
309 .B UDEV_LOG
310 is set and contains the numerical priority value, if udev is configured to use
311 .BR syslog (3).
312 Executed programs may want to follow that setting.
313 .B DEVNAME
314 is exported to make the name of the created node, or the name the network
315 device is renamed to, available to the executed program. The programs in every
316 directory are sorted in lexical order, while the directories are searched in
317 the following order:
318 .sp
319 .nf
320 /etc/dev.d/$(DEVNAME)/*.dev
321 /etc/dev.d/$(SUBSYSTEM)/*.dev
322 /etc/dev.d/default/*.dev
323 .fi
324 .SH "ENVIRONMENT"
325 .P
326 The following variables are read from the environment:
327 .TP
328 .B ACTION
329 .IR add " or " remove
330 signifies the addition or the removal of a device.
331 .TP
332 .B DEVPATH
333 The sysfs devpath of the device without the mountpoint but a leading slash.
334 .TP
335 .B SUBSYSTEM
336 The subsystem the device belongs to. Alternatively the subsystem may
337 be passed as the first argument.
338 .TP
339 .B UDEV_CONFIG_FILE
340 Overrides the default location of the
341 .B udev
342 config file.
343 .TP
344 .B UDEV_LOG
345 Overrides the log priority specified in the config file.
346 .TP
347 .B UDEV_NO_DEVD
348 The default behavior of
349 .B udev
350 is to execute programs in the
351 .I /etc/dev.d/
352 directory after device handling. If set,
353 .B udev
354 will skip this step.
355 .SH "FILES"
356 .nf
357 /sbin/udev                           udev program
358 /etc/udev/*                          udev config files
359 /etc/hotplug.d/default/udev.hotplug  hotplug symlink to udev program
360 /etc/dev.d/*                         programs invoked by udev
361 .fi
362 .SH "SEE ALSO"
363 .BR udevinfo (8),
364 .BR udevd (8),
365 .BR hotplug (8)
366 .PP
367 .B Web resources:
368 .nf
369 .I http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html
370 .I http://linux\-hotplug.sourceforge.net/
371 .fi
372 .SH AUTHORS
373 .B udev
374 was developed by Greg Kroah-Hartman <greg@kroah.com> with much help from
375 Dan Stekloff <dsteklof@us.ibm.com>, Kay Sievers <kay.sievers@vrfy.org>, and
376 many others.