1 .TH UDEV 8 "October 2003" "" "Linux Administrator's Manual"
3 udev \- Linux configurable dynamic device naming support
5 .BI udev " hotplug-subsystem"
7 The environment must provide the following variables:
11 signifies the connection or disconnection of a device.
14 The sysfs devpath of the device without the mountpoint but a leading slash.
16 Additional optional environment variables:
19 Overrides the default location of the
24 The default behavior of
26 is to execute programs in the
28 directory after device handling. If set,
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.
43 is executed if a kernel device is added or removed from the system.
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.
51 maintains a database for devices present on the system.
55 queries its database for the name of the device file to be deleted.
59 configuration files consist of a set of lines of text. All empty
60 lines and lines beginning with a '#' will be ignored.
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
71 Indicates where to place the device nodes in the filesystem. The default
76 The name and location of the udev database. The default value is
77 .IR @udevdir@/.udevdb .
80 The name of the udev rules file or directory to look for files with the suffix
82 All rule files are read in lexical order. The default value is
83 .IR /etc/udev/rules.d/ .
86 The name of the udev permission file or directory to look for files with the
89 All permission files are read in lexical order. The default value is
90 .IR /etc/udev/permissions.d/ .
93 The switch, if udev logs some information for every device handled.
98 The default mode for all nodes not explicitely matching in the permissions
99 file. The default value is
103 The default owner for all nodes not explicitely matching in the permissions
104 file. The default value is
108 The default group for all nodes not explicitely matching in the permissions
109 file. The default value is
113 .RI "A sample " udev.conf " might look like this:
116 # udev_root - where to place the device nodes in the filesystem
119 # udev_db - The name and location of the udev database
120 udev_db="/udev/.udevdb"
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/"
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"
130 # udev_log - set to "yes" if you want logging, else "no"
133 # default_mode - set the default mode for all nodes not
134 # explicitely matching in the permissions file
137 # default_owner - set the default owner for all nodes not
138 # explicitely matching in the permissions file
141 # default_group - set the default group for all nodes not
142 # explicitely matching in the permissions file
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
151 .I /etc/udev/udev.conf
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.
159 If no matching rule is found, the default kernel device name is used.
161 Every rule consists of a list of comma separated fields:
163 .IR "key " ,[ "key " ,...] " name " [, " symlink" ]
168 Match the bus type of the device.
169 (The sysfs device bus must be able to be determined by a "device" symlink.)
172 Match the kernel device name.
175 Match the kernel's subsystem name.
179 Match the device number on the bus, like PCI bus id.
182 Match the topological position on bus, like physical port of USB device
184 .BI SYSFS{ filename }
185 Match sysfs device attribute like label, vendor, USB serial number, SCSI UUID
186 or file system label. Up to 5 different sysfs files can be checked, with
187 all of the values being required to match the rule.
189 Trailing whitespace characters in the sysfs attribute value are ignored, if
190 the key doesn't have any trailing whitespace characters by itself.
193 Call external program. This key is valid if the program returns successful.
194 The environment variables of
196 are also available for the program.
198 The string returned by the program may be additionally matched with the
203 Match the returned string of the last
205 call. This key may be used in any following rule after a
210 The name of the node to be created, or the name, the network interface
211 should be renamed to.
213 If given with the attribute
214 .BR NAME{ all_partitions }
215 it will create all 15 partitions of a blockdevice.
216 This may be useful for removable media devices.
219 The name of a symlink targeting the node. Multiple symlinks may be
220 specified by separating the names by the space character.
222 If both the name and the symlink fields are omitted or its
223 values empty, the device will be ignored and no node will be created.
225 If only the symlink field is given and the name field is omitted,
226 the rule will not be applied immediatly, but the symlink field is added
227 to the symlink list of the rule which will create the node.
228 This makes it possible to specify additional symlinks in a possibly
229 separate rules file, while the device nodes are maintained by the
230 distribution provided rules file.
232 .B OWNER, GROUP, MODE
233 The permissions for this device. Every specified value overwrites the value
234 given in the permissions file.
236 .RB "The " NAME " ," SYMLINK " and " PROGRAM
237 fields support simple printf-like string substitution:
240 The "kernel number" of the device.
241 For example, 'sda3' has a "kernel number" of '3'.
244 The "kernel name" for the device.
247 The kernel major number for the device.
250 The kernel minor number for the device.
253 The bus id for the device.
256 The string returned from the execution of
258 (This does not work within the
260 field for the obvious reason.)
262 A single part of the string, separated by a space character
263 may be selected by specifying the part number as an attribute:
265 If the number is followed by the + char this part plus
266 all remaining parts of the result string are substituted:
270 The content of a sysfs attribute.
273 If a device node already exists with the name, the smallest positive
274 decimal integer N is substituted such that the resulting name doesn't
275 match an existing device node. Otherwise nothing is substituted. This
276 can be used to create compatibility symlinks and enumerate devices of
277 the same type originating from different kernel subsystems.
280 The '%' character itself.
282 The count of charcters to insert may be limited by specifying
283 the format length value. For example, '%3s{file}' will only insert
284 the first three characters of the sysfs attribute.
286 .RI "A sample " udev.rules " might look like this:"
289 # if /sbin/scsi_id returns "OEM 0815" device will be called disk1
290 BUS="scsi", PROGRAM="/sbin/scsi_id", RESULT="OEM 0815", NAME="disk1"
292 # USB printer to be called lp_color
293 BUS="usb", SYSFS{serial}="W09090207101241330", NAME="lp_color"
295 # SCSI disk with a specific vendor and model number will be called boot
296 BUS="scsi", SYSFS{vendor}="IBM", SYSFS{model}="ST336", NAME="boot%n"
298 # sound card with PCI bus id 00:0b.0 to be called dsp
299 BUS="pci", ID="00:0b.0", NAME="dsp"
301 # USB mouse at third port of the second hub to be called mouse1
302 BUS="usb", PLACE="2.3", NAME="mouse1"
304 # ttyUSB1 should always be called pda with two additional symlinks
305 KERNEL="ttyUSB1", NAME="pda", SYMLINK="palmtop handheld"
307 # multiple USB webcams with symlinks to be called webcam0, webcam1, ...
308 BUS="usb", SYSFS{model}="XV3", NAME="video%n", SYMLINK="webcam%n"
310 # grouping of optical drives from multiple kernel subsystems
311 KERNEL="sr*", NAME="%k", SYMLINK="cdrom%e"
312 KERNEL="scd*", NAME="%k", SYMLINK="cdrom%e"
313 KERNEL="pcd*", NAME="%k", SYMLINK="cdrom%e"
314 KERNEL="hd[a-z]", PROGRAM="/bin/cat /proc/ide/%k/media", RESULT="cdrom",
315 NAME="%k", SYMLINK="cdrom%e"
319 The permissions and ownership of the created device file is read from
320 the files located in the
321 .I /etc/udev/permissions.d/
322 directory, or at the location specified by the
325 .I /etc/udev/udev.conf
328 Every line lists a device name followed by owner, group and permission
329 mode. All values are separated by colons. The name field may contain a
330 pattern to apply the values to a whole class of devices.
332 .RI "A sample " udev.permissions " might look like this:"
335 #name:user:group:mode
336 input/*:root:root:644
338 video*:root:video:0660
342 A number of different fields in the above configuration files support a simple
343 form of shell style pattern matching. It supports the following pattern characters:
346 Matches zero, one, or more characters.
349 Matches any single character, but does not match zero characters.
352 Matches any single character specified within the brackets. For example, the
353 pattern string "tty[SR]" would match either "ttyS" or "ttyR". Ranges are also
354 supported within this match with the '\-' character. For example, to match on
355 the range of all digits, the pattern [0\-9] would be used. If the first character
356 following the '[' is a '!', any character not enclosed is matched.
358 After device node creation, removal, or network device renaming,
360 executes the programs in the directory tree under
362 The name of a program must end with
364 suffix, to be recognized.
366 In addition to the hotplug environment variables,
368 is exported to make the name of the created node, or the name the network
369 device is renamed to, available to the executed program. The programs in every
370 directory are sorted in lexical order, while the directories are searched in
374 /etc/dev.d/$(DEVNAME)/*.dev
375 /etc/dev.d/$(SUBSYSTEM)/*.dev
376 /etc/dev.d/default/*.dev
380 /sbin/udev udev program
381 /etc/udev/* udev config files
382 /etc/hotplug.d/default/udev.hotplug hotplug symlink to udev program
383 /etc/dev.d/* programs invoked by udev
392 .I http://linux\-hotplug.sourceforge.net/
396 was developed by Greg Kroah-Hartman <greg@kroah.com> with much help from
397 Dan Stekloff <dsteklof@us.ibm.com>, Kay Sievers <kay.sievers@vrfy.org>, and