chiark / gitweb /
[PATCH] add documentation about the multiple sysfs values that are now allowed for...
[elogind.git] / udev.8
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 .SH "DESCRIPTION"
7 .B udev
8 creates or removes device node files usually located in the /dev directory.
9 Its goal is to provide a dynamic device directory that contains only the files
10 for devices that are actually present.
11 .P
12 As part of the
13 .B hotplug
14 subsystem,
15 .B udev
16 is executed if a kernel device is added or removed from the system.
17 On device creation,
18 .B udev
19 reads the sysfs directory of the given device to collect device attributes
20 like label, serial number or bus device number.
21 These attributes are treated as a key
22 to determine a unique name for device file creation.
23 .B udev
24 maintains a database for devices present on the system.
25 .br
26 On device removal,
27 .B udev
28 queries the internal database for the name of the device file to be deleted.
29 .SH "CONFIGURATION"
30 All
31 .B udev
32 configuration files consist of a set of lines of text.  All empty
33 lines, and lines beginning with a '#' will be ignored.
34 .P
35
36 .B udev
37 expects its main configuration file at
38 .I /etc/udev/udev.conf.
39 The file consists of a set of variables and values that allow the user to
40 override default udev values.  The current set of variables that can be
41 overridden in this file is:
42 .TP
43 .B udev_root
44 This is the where in the filesystem to place the device nodes.  The default
45 value for this is
46 .I /udev/
47 .TP
48 .B udev_db
49 The name and location of the udev database.  The default value for this is
50 .I /udev/.udev.tdb
51 .TP
52 .B udev_rules
53 This is the location of the udev rules file.  The default value for this is
54 .I /etc/udev/udev.rules
55 .TP
56 .B udev_permissions
57 This is the location of the udev permission file.  The default value for this is
58 .I /etc/udev/udev.permissions
59 .TP
60 .B default_mode
61 This is the default mode for all nodes that have no explicit match in the
62 permissions file.  The default value for this is
63 .I 0666
64 .br
65 .P
66 .RI "A sample " udev.conf " might look like this:
67 .sp
68 .nf
69 # udev_root - where in the filesystem to place the device nodes
70 udev_root="/udev/"
71
72 # udev_db - The name and location of the udev database.
73 udev_db="/udev/.udev.tdb"
74
75 # udev_rules - The name and location of the udev rules file
76 udev_rules="/etc/udev/udev.rules"
77
78 # udev_permissions - The name and location of the udev permission file
79 udev_permissions="/etc/udev/udev.permissions"
80
81 # default_mode - set the default mode for all nodes that have no 
82 #                explicit match in the permissions file
83 default_mode="0666"
84 .fi
85 .P
86 The rules for udev to use when naming devices may specified at
87 .I /etc/udev/udev.rules
88 or specified by the
89 .I udev_rules
90 value in the
91 .I /etc/udev/udev.conf
92 file.
93 .P
94 Every line in the rules file define the mapping between device attributes and
95 the device file name. It starts with a keyword defining the method used to
96 match, followed by one ore more keys to compare and the filename for the
97 device. One ore more optional symlinks targeting the node may be specified.
98 .br
99 If no matching configuration is found, the default kernel device name
100 is used.
101 .P
102 The line format is:
103 .sp
104 .I method, key,[key,...] name [, symlink]
105 .sp
106 where valid methods with corresponding keys are:
107 .TP
108 .B CALLOUT
109 calling external program, that returns a string to match
110 .br
111 .RB "keys: " BUS ", " PROGRAM ", " ID
112 .TP
113 .B LABEL
114 device label or serial number, like USB serial number, SCSI UUID or
115 file system label.  Up to 5 different sysfs files can be checked, with
116 all of the values being required in order to match the rule.
117 .br
118 .RB "keys: " BUS ", " SYSFS_
119 .TP
120 .B NUMBER
121 device number on the bus, like PCI bus id
122 .br
123 .RB "keys: " BUS ", " ID
124 .TP
125 .B TOPOLOGY
126 device position on bus, like physical port of USB device
127 .br
128 .RB "keys: " BUS ", " PLACE
129 .TP
130 .B REPLACE
131 string replacement of the kernel device name
132 .br
133 .RB "key: " KERNEL
134 .P
135 The methods are applied in the following order:
136 .BR CALLOUT ", " LABEL ", " NUMBER ", " TOPOLOGY ", " REPLACE "."
137 .P
138 .RB "The " NAME " ," SYMLINK " and " PROGRAM
139 fields support simple printf-like string substitution:
140 .TP
141 .B %n
142 The "kernel number" of the device.
143 for example, 'sda3' has a "kernel number" of '3'
144 .TP
145 .B %M
146 The kernel major number for the device.
147 .TP
148 .B %m
149 The kernel minor number for the device.
150 .TP
151 .B %b
152 The bus id for the device.
153 .TP
154 .B %c
155 The CALLOUT program returned string.
156 (This does not work within the PROGRAM field for the obvious reason.)
157 .TP
158 .B %D
159 Use the devfs style disk name for this device.
160 For partitions, this will result in 'part%n'
161 If this is not a partition, it will result in 'disc'.
162 .P
163 .RI "A sample " udev.rules " might look like this:"
164 .sp
165 .nf
166 # if /sbin/scsi_id returns "OEM 0815" device will be called disk1
167 CALLOUT, BUS="scsi", PROGRAM="/sbin/scsi_id", ID="OEM 0815", NAME="disk1"
168
169 # USB printer to be called lp_color
170 LABEL, BUS="usb", SYSFS_serial="W09090207101241330", NAME="lp_color"
171
172 # SCSI disk with a specific vendor and model number is to be called boot
173 LABEL, BUS="scsi", SYSFS_vendor="IBM", SYSFS_model="ST336", NAME="boot%n"
174
175 # sound card with PCI bus id 00:0b.0 to be called dsp
176 NUMBER, BUS="pci", ID="00:0b.0", NAME="dsp"
177
178 # USB mouse at third port of the second hub to be called mouse1
179 TOPOLOGY, BUS="usb", PLACE="2.3", NAME="mouse1"
180
181 # ttyUSB1 should always be called pda with two additional symlinks
182 REPLACE, KERNEL="ttyUSB1", NAME="pda", SYMLINK="palmtop handheld"
183
184 # multiple USB webcams with symlinks to be called webcam0, webcam1, ...
185 LABEL, BUS="usb", SYSFS_model="XV3", NAME="video%n", SYMLINK="webcam%n"
186 .fi
187 .P
188 Permissions and ownership for the created device files may specified at
189 .I /etc/udev/udev.permissions
190 or specified by the
191 .I udev_permission
192 value in the
193 .I /etc/udev/udev.conf
194 file.
195 .br
196 Every line lists a device name followed by owner, group and permission
197 mode. All values are separated by colons. The name field may contain a
198 pattern to apply the values to a whole class of devices.
199 .br
200 If
201 .B udev
202 was built using klibc or is used before the user database is accessible (e.g.
203 .BR initrd "(4)), only numeric owner and group values may be used."
204 .sp
205 .RI "A sample " udev.permissions " might look like this:"
206 .sp
207 .nf
208 #name:user:group:mode
209 input/*:root:root:644
210 ttyUSB1:0:8:0660
211 video*:root:video:0660
212 dsp1:::0666
213 .fi
214 .P
215 A number of different fields in the above configuration files support a simple
216 form of shell style pattern matching. It supports the following pattern characters:
217 .TP
218 .B *
219 Matches zero, one, or more characters.
220 .TP
221 .B ?
222 Matches any single character, but does not match zero characters.
223 .TP
224 .B [ ]
225 Matches any single character specified within the brackets. For example, the
226 pattern string "tty[SR]" would match either "ttyS" or "ttyR".  Ranges are also
227 supported within this match with the '-' character.  For example, to match on
228 the range of all digits, the pattern [0-9] would be used. If the first character
229 following the '[' is a '!' then any character not enclosed is matched.
230 .SH "FILES"
231 .nf
232 /sbin/udev                           udev program
233 /etc/udev/*                          udev config files
234 /etc/hotplug.d/default/udev.hotplug  hotplug symlink to udev program
235 .fi
236 .LP
237 .SH "SEE ALSO"
238 .BR hotplug (8)
239 .PP
240 The
241 .I http://linux-hotplug.sourceforge.net/
242 web site.
243 .SH AUTHORS
244 .B udev
245 was developed by Greg Kroah-Hartman <greg@kroah.com> with much help from
246 Dan Stekloff <dsteklof@us.ibm.com>, Kay Sievers <kay.sievers@vrfy.org>, and
247 many others.