1 .TH UDEV 8 "October 2003" "" "Linux Administrator's Manual"
3 udev \- Linux configurable dynamic device naming support
5 .BI udev " hotplug-subsystem"
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.
17 is executed if a kernel device is added or removed from the system.
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.
25 maintains a database for devices present on the system.
29 queries its database for the name of the device file to be deleted.
33 configuration files consist of a set of lines of text. All empty
34 lines or lines beginning with '#' will be ignored.
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
44 Indicates where to place the device nodes in the filesystem. The default
49 The name and location of the udev database. The default value is
50 .IR @udevdir@/.udevdb .
53 The name of the udev rules file or directory to look for files with the suffix
55 All rule files are read in lexical order. The default value is
56 .IR /etc/udev/rules.d/ .
59 The switch to enable/disable logging of udev information
63 .RI "A sample " udev.conf " file might look like this:
66 # udev_root - where to place the device nodes in the filesystem
69 # udev_db - The name and location of the udev database
70 udev_db="/udev/.udevdb"
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/"
76 # udev_log - set to "yes" if you want logging, else "no"
80 The rules for device naming are read from the files located in the
82 directory, or at the location specified by the
85 .I /etc/udev/udev.conf
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.
93 If no matching rule is found, the default kernel device name is used.
95 Every rule consists of a list of comma separated key value fields:
97 .IR "key " ,[ "key " ,...]
99 The following key names can be used to match against device properties:
102 Match the bus type of the device.
103 (The sysfs device bus must be able to be determined by a "device" symlink.)
106 Match the kernel device name.
109 Match the kernel subsystem name.
112 Match the kernel driver name.
115 Match the device number on the bus, like PCI bus id.
117 .BI SYSFS{ filename }
118 Match sysfs device attribute like vendor and product id's, USB serial number
119 or the SCSI disk model number. Up to 5 different sysfs files can be checked,
120 with all of the values being required to match the rule.
122 Trailing whitespace characters in the sysfs attribute value are ignored, if
123 the key doesn't have any trailing whitespace characters by itself.
126 Match an environment variable. Up to 5 different environment variables can be
127 checked, with all of the values being required to match the rule.
130 Call external program. This key is valid if the program returns successful.
131 The environment variables of
133 are also available to the program.
135 The string returned by the program may be additionally matched with the
137 key in the same or any later rule.
140 Match the returned string of the last
142 call. This key can be used in the same or in any later rule after a
146 The following keys can get values assigned:
149 The name of the node to be created, or the name, the network interface
150 should be renamed to.
153 The name of a symlink targeting the node. Multiple symlinks may be
154 specified by separating the names by the space character.
156 If both the name and the symlink fields are omitted or its
157 values are empty, the device will be ignored and no node will be created.
159 If only the symlink field is given and the name field is omitted,
160 the rule will not be applied immediately, but the symlink field is added
161 to the symlink list of the rule which will create the node.
162 This makes it possible to specify additional symlinks in a possibly
163 separate rules file, while the device nodes are maintained by the
164 distribution provided rules file.
166 .B OWNER, GROUP, MODE
167 The permissions for the device node. Every specified value overwrites the
168 compiled-in default value.
172 will be the last rule applied. No later rules will have any effect.
176 will ignore this device. No node will be created.
179 will ignore any later remove event for this device.
180 This may be useful as a workaround for broken device drivers.
183 will create device nodes for all available partitions of a blockdevice.
184 This may be useful for removable media devices which do not detect a media
187 Multiple attributes may be separated by comma.
189 .RB "The " NAME ", " SYMLINK ", " PROGRAM ", " OWNER " and " GROUP
190 fields support simple printf-like string substitutions:
193 The "kernel number" of the device.
194 For example, 'sda3' has a "kernel number" of '3'.
197 The "kernel name" for the device.
200 The devpath for the device.
203 The kernel major number for the device.
206 The kernel minor number for the device.
209 The bus id for the device.
212 The string returned by the external program, specified in
214 (This does not work within the
216 field for the obvious reason.)
218 A single part of the string, separated by a space character
219 may be selected by specifying the part number as an attribute:
221 If the number is followed by the + char this part plus
222 all remaining parts of the result string are substituted:
226 The name of a created temporary device node to provide access to the
227 device from a external program.
230 The node name of the parent device.
233 The content of a sysfs attribute.
236 If a device node already exists with the name, the smallest positive
237 decimal integer N is substituted such that the resulting name doesn't
238 match an existing device node. Otherwise nothing is substituted. This
239 can be used to create compatibility symlinks and enumerate devices of
240 the same type originating from different kernel subsystems.
242 Note: The use of the enumeration facility is unreliable outside of
243 udevstart where the node creation is serialized and predictable.
244 The returned numbers rely on the order devices are probed on the
245 system. If more than one device requests an enumeration for the same
246 name at the same time, it may be possible that both requests receive the
247 same name back from the database. The use of enumerations in todays setups
248 where device can come and go at any time is not recomended.
251 The '%' character itself.
253 The count of charcters to insert may be limited by specifying
254 the format length value. For example, '%3s{file}' will only insert
255 the first three characters of the sysfs attribute.
257 .RI "A sample " udev.rules " file might look like this:"
260 # if /sbin/scsi_id returns "OEM 0815", the device will be called disk1
261 BUS=="scsi", PROGRAM=="/sbin/scsi_id", RESULT=="OEM 0815", NAME="disk1"
263 # USB printer to be called lp_color
264 BUS=="usb", SYSFS{serial}=="W09090207101241330", NAME="lp_color"
266 # SCSI disk with a specific vendor and model number will be called boot
267 BUS=="scsi", SYSFS{vendor}=="IBM", SYSFS{model}=="ST336", NAME="boot%n"
269 # sound card with PCI bus id 00:0b.0 to be called dsp
270 BUS=="pci", ID=="00:0b.0", NAME="dsp"
272 # USB mouse at third port of the second hub to be called mouse1
273 BUS=="usb", ID=="2.3", NAME="mouse1"
275 # ttyUSB1 should always be called pda with two additional symlinks
276 KERNEL=="ttyUSB1", NAME="pda", SYMLINK="palmtop handheld"
278 # multiple USB webcams with symlinks to be called webcam0, webcam1, ...
279 BUS=="usb", SYSFS{model}=="XV3", NAME=="video%n", SYMLINK="webcam%n"
281 # grouping of optical drives from multiple kernel subsystems
282 KERNEL=="sr*", NAME="%k", SYMLINK="cdrom%e"
283 KERNEL=="scd*", NAME="%k", SYMLINK="cdrom%e"
284 KERNEL=="pcd*", NAME="%k", SYMLINK="cdrom%e"
285 KERNEL=="hd[a-z]", PROGRAM=="/bin/cat /proc/ide/%k/media", RESULT=="cdrom",
286 NAME="%k", SYMLINK="cdrom%e"
289 A number of different fields in the above configuration files support a simple
290 form of shell style pattern matching. It supports the following pattern characters:
293 Matches zero, one, or more characters.
296 Matches any single character, but does not match zero characters.
299 Matches any single character specified within the brackets. For example, the
300 pattern string "tty[SR]" would match either "ttyS" or "ttyR". Ranges are also
301 supported within this match with the '\-' character. For example, to match on
302 the range of all digits, the pattern [0\-9] would be used. If the first character
303 following the '[' is a '!', any characters not enclosed are matched.
305 After device node creation, removal, or network device renaming,
307 executes the programs located in the directory tree under
309 The name of a program must have the suffix
313 In addition to the hotplug environment variables,
315 is set if udev is configured to use the syslog facility. Executed programs may
316 want to follow that setting.
318 is exported to make the name of the created node, or the name the network
319 device is renamed to, available to the executed program. The programs in every
320 directory are sorted in lexical order, while the directories are searched in
324 /etc/dev.d/$(DEVNAME)/*.dev
325 /etc/dev.d/$(SUBSYSTEM)/*.dev
326 /etc/dev.d/default/*.dev
330 The following variables are read from the environment:
333 .IR add " or " remove
334 signifies the addition or the removal of a device.
337 The sysfs devpath of the device without the mountpoint but a leading slash.
340 The subsystem the device belongs to. Alternatively the subsystem may
341 be passed as the first argument.
344 Overrides the default location of the
349 The default behavior of
351 is to execute programs in the
353 directory after device handling. If set,
358 /sbin/udev udev program
359 /etc/udev/* udev config files
360 /etc/hotplug.d/default/udev.hotplug hotplug symlink to udev program
361 /etc/dev.d/* programs invoked by udev
370 .I http://linux\-hotplug.sourceforge.net/
371 .I http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html
375 was developed by Greg Kroah-Hartman <greg@kroah.com> with much help from
376 Dan Stekloff <dsteklof@us.ibm.com>, Kay Sievers <kay.sievers@vrfy.org>, and