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 wait until all the sysfs files of the device chain are populated. If set
28 will continue, regardless of the state of the device representation.
31 creates or removes device node files usually located in the /dev directory.
32 It provides a dynamic device directory contaning only the files for
33 actually present devices.
39 is executed if a kernel device is added or removed from the system.
42 reads the sysfs directory of the given device to collect device attributes
43 like label, serial number or bus device number.
44 These attributes may be used as keys to determine a
45 unique name for device file creation.
47 maintains a database for devices present on the system.
51 queries its database for the name of the device file to be deleted.
55 configuration files consist of a set of lines of text. All empty
56 lines and lines beginning with a '#' will be ignored.
60 expects its main configuration file at
61 .IR /etc/udev/udev.conf .
62 The file consists of a set of variables and values allowing the user to
63 override default udev values. The following variables can be overridden
67 Indicates where to place the device nodes in the filesystem. The default
72 The name and location of the udev database. The default value is
76 This is the location of the udev rules file. The default value for this is
77 .IR /etc/udev/udev.rules .
78 If a directory is specified, the whole directory is
79 scanned for files ending with
81 and all rule files are read in lexical order.
84 This is the location of the udev permission file. The default value for this is
85 .IR /etc/udev/udev.permissions .
86 If a directory is specified, the whole directory is scanned for files ending with
88 and all permission files are read in lexical order.
91 If you want udev to log some information to the syslog for every node created or
92 removed. The default value is
96 This is the default mode for all nodes not explicitely matching in the
97 permissions file. The default value is
101 This is the default owner for all nodes not explicitely matching in the
102 permissions file. The default value is
106 This is the default group for all nodes not explicitely matching in the
107 permissions file. The default value is
111 .RI "A sample " udev.conf " might look like this:
114 # udev_root - where to place the device nodes in the filesystem
117 # udev_db - The name and location of the udev database
118 udev_db="/udev/.udev.tdb"
120 # udev_rules - The location of the directory where to look for files
121 which names ending with .rules
122 udev_rules="/etc/udev/"
124 # udev_permissions - The name and location of the udev permission file
125 udev_permissions="/etc/udev/udev.permissions"
127 # udev_log - set to "yes" if you want logging, else "no"
130 # default_mode - set the default mode for all nodes not
131 # explicitely matching in the permissions file
134 # default_owner - set the default owner for all nodes not
135 # explicitely matching in the permissions file
138 # default_group - set the default group for all nodes not
139 # explicitely matching in the permissions file
143 The rules for udev to use when naming devices may specified in
144 .I /etc/udev/udev.rules
148 .I /etc/udev/udev.conf
151 Every line in the rules file defines the mapping between device attributes
152 and the device file name. One or more keys are specified to match a rule
153 with the current device. If all keys are matching, the rule will be applied
154 and the name is used for the device node.
156 If no matching rule is found, the default kernel device name is used.
158 Every rule consists of a list of comma separated fields:
160 .IR "key " ,[ "key " ,...] " name " [, " symlink" ]
165 Match the bus type of the device.
166 (The sysfs device bus must be able to be determined by a "device" symlink.)
169 Match the kernel device name.
172 Match the device number on the bus, like PCI bus id.
175 Match the topological position on bus, like physical port of USB device
177 .BI SYSFS{ filename }
178 Match sysfs device attribute like label, vendor, USB serial number, SCSI UUID
179 or file system label. Up to 5 different sysfs files can be checked, with
180 all of the values being required to match the rule.
182 Trailing whitespace characters in the sysfs attribute value are ignored, if
183 the key doesn't have any trailing whitespace characters by itself.
186 Call external program. This key is valid if the program returns successful.
187 The environment variables of
189 are also available for the program.
191 The string returned by the program may be additionally matched with the
196 Match the returned string of the last
198 call. This key may be used in any following rule after a
203 The name of the node to be created.
205 If given with the attribute
206 .BR NAME{ all_partitions }
207 it will create all 15 partitions of a blockdevice.
208 This may be useful for removable media devices.
211 The name of a symlink targeting the node. Multiple symlinks may be
212 specified by separating the names by the space character.
214 If both the name and the symlink fields are omitted or its
215 values empty, the device will be ignored and no node will be created.
217 If only the symlink field is given and the name field is omitted,
218 the rule will not be applied immediatly, but the symlink field is added
219 to the symlink list of the rule which will create the node.
220 This makes it possible to specify additional symlinks in a possibly
221 separate rules file, while the device nodes are maintained by the
222 distribution provided rules file.
224 .B OWNER, GROUP, MODE
225 The permissions for this device. Every specified value overwrites the value
226 given in the permissions file.
228 .RB "The " NAME " ," SYMLINK " and " PROGRAM
229 fields support simple printf-like string substitution:
232 The "kernel number" of the device.
233 For example, 'sda3' has a "kernel number" of '3'.
236 The "kernel name" for the device.
239 The kernel major number for the device.
242 The kernel minor number for the device.
245 The bus id for the device.
248 The string returned from the execution of
250 (This does not work within the
252 field for the obvious reason.)
254 A single part of the string, separated by a space character
255 may be selected by specifying the part number as an attribute:
257 If the number is followed by the + char this part plus
258 all remaining parts of the result string are substituted:
262 The content of a sysfs attribute.
265 The '%' character itself.
267 The count of charcters to insert may be limited by specifying
268 the format length value. For example, '%3s{file}' will only insert
269 the first three characters of the sysfs attribute.
271 .RI "A sample " udev.rules " might look like this:"
274 # if /sbin/scsi_id returns "OEM 0815" device will be called disk1
275 BUS="scsi", PROGRAM="/sbin/scsi_id", RESULT="OEM 0815", NAME="disk1"
277 # USB printer to be called lp_color
278 BUS="usb", SYSFS{serial}="W09090207101241330", NAME="lp_color"
280 # SCSI disk with a specific vendor and model number will be called boot
281 BUS="scsi", SYSFS{vendor}="IBM", SYSFS{model}="ST336", NAME="boot%n"
283 # sound card with PCI bus id 00:0b.0 to be called dsp
284 BUS="pci", ID="00:0b.0", NAME="dsp"
286 # USB mouse at third port of the second hub to be called mouse1
287 BUS="usb", PLACE="2.3", NAME="mouse1"
289 # ttyUSB1 should always be called pda with two additional symlinks
290 KERNEL="ttyUSB1", NAME="pda", SYMLINK="palmtop handheld"
292 # multiple USB webcams with symlinks to be called webcam0, webcam1, ...
293 BUS="usb", SYSFS{model}="XV3", NAME="video%n", SYMLINK="webcam%n"
296 Permissions and ownership for the created device files may specified in
297 .I /etc/udev/udev.permissions
301 .I /etc/udev/udev.conf
304 Every line lists a device name followed by owner, group and permission
305 mode. All values are separated by colons. The name field may contain a
306 pattern to apply the values to a whole class of devices.
308 .RI "A sample " udev.permissions " might look like this:"
311 #name:user:group:mode
312 input/*:root:root:644
314 video*:root:video:0660
320 can be used instead of a specific username. In that case, udev will determine
321 the current local user at the time of device node creation and substitute
322 that username as the owner of the new device node. This is useful, for
323 example, to let hot-plugged devices, such as cameras, be owned by the user at
324 the current console. Note that if no user is currently logged in, or if udev
325 otherwise fails to determine a current user, the
327 value is used in lieu.
329 A number of different fields in the above configuration files support a simple
330 form of shell style pattern matching. It supports the following pattern characters:
333 Matches zero, one, or more characters.
336 Matches any single character, but does not match zero characters.
339 Matches any single character specified within the brackets. For example, the
340 pattern string "tty[SR]" would match either "ttyS" or "ttyR". Ranges are also
341 supported within this match with the '\-' character. For example, to match on
342 the range of all digits, the pattern [0\-9] would be used. If the first character
343 following the '[' is a '!', any character not enclosed is matched.
346 /sbin/udev udev program
347 /etc/udev/* udev config files
348 /etc/hotplug.d/default/udev.hotplug hotplug symlink to udev program
357 .I http://linux\-hotplug.sourceforge.net/
361 was developed by Greg Kroah-Hartman <greg@kroah.com> with much help from
362 Dan Stekloff <dsteklof@us.ibm.com>, Kay Sievers <kay.sievers@vrfy.org>, and