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