chiark / gitweb /
d7999aadfd182a686e3c17a063c52530e1bdc8e6
[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 may used as keys to determine a
22 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 its 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 .IR /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 .IR /udev/ .
47 .TP
48 .B udev_db
49 The name and location of the udev database.  The default value for this is
50 .IR /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 .IR /etc/udev/udev.rules .
55 If a directory is specified, the whole directory is
56 scanned for files ending with
57 .I .rules
58 and all rule files are read in lexical order.
59 .TP
60 .B udev_permissions
61 This is the location of the udev permission file. The default value for this is
62 .IR /etc/udev/udev.permissions .
63 If a directory is specified, the whole directory is scanned for files ending with
64 .I .permissions
65 and all permission files are read in lexical order.
66 .TP
67 .B udev_log
68 If you want udev to log some information to the syslog for every node created or
69 removed. The default value for this is
70 .IR yes .
71 .TP
72 .B default_mode
73 This is the default mode for all nodes that have no explicit match in the
74 permissions file.  The default value for this is
75 .IR 0666 .
76 .TP
77 .B default_owner
78 This is the default owner for all nodes that have no explicit match in the
79 permissions file.  The default value for this is
80 .IR root .
81 .TP
82 .B default_group
83 This is the default group for all nodes that have no explicit match in the
84 permissions file.  The default value for this is
85 .IR root .
86 .br
87 .P
88 .RI "A sample " udev.conf " might look like this:
89 .sp
90 .nf
91 # udev_root - where in the filesystem to place the device nodes
92 udev_root="/udev/"
93
94 # udev_db - The name and location of the udev database.
95 udev_db="/udev/.udev.tdb"
96
97 # udev_rules - The location of the directory where to look for files
98                which names ending with .rules
99 udev_rules="/etc/udev/"
100
101 # udev_permissions - The name and location of the udev permission file
102 udev_permissions="/etc/udev/udev.permissions"
103
104 # udev_log - set to "yes" if you want logging, else "no"
105 udev_log="yes"
106
107 # default_mode - set the default mode for all nodes that have no
108 #                explicit match in the permissions file
109 default_mode="0666"
110
111 # default_owner - set the default owner for all nodes that have no
112 #                 explicit match in the permissions file
113 default_owner="root"
114
115 # default_group - set the default group for all nodes that have no
116 #                 explicit match in the permissions file
117 default_group="root"
118 .fi
119 .P
120 The rules for udev to use when naming devices may specified at
121 .I /etc/udev/udev.rules
122 or specified by the
123 .I udev_rules
124 value in the
125 .I /etc/udev/udev.conf
126 file.
127 .P
128 Every line in the rules file defines the mapping between device attributes
129 and the device file name. One ore more keys are specified to match a rule
130 with the current device. If all keys are matching, the rule will be applied
131 and the name is used for the device node. One or more optional symlinks
132 targeting the node may be specified.
133 .br
134 If no matching rule is found, the default kernel device name is used.
135 .P
136 The line format is:
137 .sp
138 .I key,[key,...] name [, symlink]
139 .sp
140 where keys are:
141 .TP
142 .B BUS
143 Match the bus type of the device.
144 (The sysfs device bus must be able to be determined by a "device" symlink.)
145 .TP
146 .B KERNEL
147 Match the kernel device name.
148 .TP
149 .B ID
150 Match the device number on the bus, like PCI bus id.
151 .TP
152 .B PLACE
153 Match the topological position on bus, like physical port of USB device
154 .TP
155 .BI SYSFS{ filename }
156 Match sysfs device attribute like label, vendor, USB serial number, SCSI UUID
157 or file system label.  Up to 5 different sysfs files can be checked, with
158 all of the values being required in order to match the rule.
159 .TP
160 .B PROGRAM
161 Call external program. This key is valid if the program returns successful.
162 The string returned by the program may additionally matched with the
163 .B RESULT
164 key.
165 .TP
166 .B RESULT
167 Match the returned string of the last
168 .B PROGRAM
169 call. This key may used in any following rule after a
170 .B PROGRAM
171 call.
172 .P
173 The
174 .B NAME
175 field given with the attribute
176 .BR NAME{ all_partitions }
177 will  create all 15 partitions of a blockdevice.
178 This may be useful for removable media devices.
179 .P
180 .RB "The " NAME " ," SYMLINK " and " PROGRAM
181 fields support simple printf-like string substitution:
182 .TP
183 .B %n
184 The "kernel number" of the device.
185 for example, 'sda3' has a "kernel number" of '3'
186 .TP
187 .B %k
188 The "kernel name" for the device.
189 .TP
190 .B %M
191 The kernel major number for the device.
192 .TP
193 .B %m
194 The kernel minor number for the device.
195 .TP
196 .B %b
197 The bus id for the device.
198 .TP
199 .B %c
200 The
201 .B PROGRAM
202 returned string.
203 (This does not work within the
204 .B PROGRAM
205 field for the obvious reason.)
206 .br
207 A single part of the string, separated by the space character
208 my be selected by specifying the part number as a attribute:
209 .BI %c{ part }
210 .TP
211 .BI %s{ filename }
212 The content of a sysfs attribute.
213 .TP
214 .B %%
215 The '%' char itself.
216 .P
217 .RI "A sample " udev.rules " might look like this:"
218 .sp
219 .nf
220 # if /sbin/scsi_id returns "OEM 0815" device will be called disk1
221 BUS="scsi", PROGRAM="/sbin/scsi_id", RESULT="OEM 0815", NAME="disk1"
222
223 # USB printer to be called lp_color
224 BUS="usb", SYSFS{serial}="W09090207101241330", NAME="lp_color"
225
226 # SCSI disk with a specific vendor and model number is to be called boot
227 BUS="scsi", SYSFS{vendor}="IBM", SYSFS{model}="ST336", NAME="boot%n"
228
229 # sound card with PCI bus id 00:0b.0 to be called dsp
230 BUS="pci", ID="00:0b.0", NAME="dsp"
231
232 # USB mouse at third port of the second hub to be called mouse1
233 BUS="usb", PLACE="2.3", NAME="mouse1"
234
235 # ttyUSB1 should always be called pda with two additional symlinks
236 KERNEL="ttyUSB1", NAME="pda", SYMLINK="palmtop handheld"
237
238 # multiple USB webcams with symlinks to be called webcam0, webcam1, ...
239 BUS="usb", SYSFS{model}="XV3", NAME="video%n", SYMLINK="webcam%n"
240 .fi
241 .P
242 Permissions and ownership for the created device files may specified at
243 .I /etc/udev/udev.permissions
244 or specified by the
245 .I udev_permission
246 value in the
247 .I /etc/udev/udev.conf
248 file.
249 .br
250 Every line lists a device name followed by owner, group and permission
251 mode. All values are separated by colons. The name field may contain a
252 pattern to apply the values to a whole class of devices.
253 .sp
254 .RI "A sample " udev.permissions " might look like this:"
255 .sp
256 .nf
257 #name:user:group:mode
258 input/*:root:root:644
259 ttyUSB1:0:8:0660
260 video*:root:video:0660
261 dsp1:::0666
262 .fi
263 .P
264 A number of different fields in the above configuration files support a simple
265 form of shell style pattern matching. It supports the following pattern characters:
266 .TP
267 .B *
268 Matches zero, one, or more characters.
269 .TP
270 .B ?
271 Matches any single character, but does not match zero characters.
272 .TP
273 .B [ ]
274 Matches any single character specified within the brackets. For example, the
275 pattern string "tty[SR]" would match either "ttyS" or "ttyR".  Ranges are also
276 supported within this match with the '-' character.  For example, to match on
277 the range of all digits, the pattern [0-9] would be used. If the first character
278 following the '[' is a '!' then any character not enclosed is matched.
279 .SH "FILES"
280 .nf
281 /sbin/udev                           udev program
282 /etc/udev/*                          udev config files
283 /etc/hotplug.d/default/udev.hotplug  hotplug symlink to udev program
284 .fi
285 .LP
286 .SH "SEE ALSO"
287 .BR udevinfo (8),
288 .BR hotplug (8)
289 .PP
290 The
291 .I http://linux-hotplug.sourceforge.net/
292 web site.
293 .SH AUTHORS
294 .B udev
295 was developed by Greg Kroah-Hartman <greg@kroah.com> with much help from
296 Dan Stekloff <dsteklof@us.ibm.com>, Kay Sievers <kay.sievers@vrfy.org>, and
297 many others.