]>
Commit | Line | Data |
---|---|---|
d3db5e5e | 1 | .TH UDEV 8 "October 2003" "" "Linux Administrator's Manual" |
04db8c9e | 2 | .SH NAME |
d3db5e5e | 3 | udev \- Linux configurable dynamic device naming support |
04db8c9e | 4 | .SH SYNOPSIS |
eb13ff87 | 5 | .BI udev " hotplug-subsystem" |
bef370d6 KS |
6 | .P |
7 | The environment must provide the following variables: | |
8 | .TP | |
9 | .B ACTION | |
10 | .IR add " or " remove | |
11 | signifies the connection or disconnection of a device. | |
12 | .TP | |
13 | .B DEVPATH | |
14 | The sysfs devpath of the device without the mountpoint but a leading slash. | |
15 | .P | |
b86f56ff | 16 | Additional optional environment variables: |
bef370d6 KS |
17 | .TP |
18 | .B UDEV_CONFIG_FILE | |
19 | Overrides the default location of the | |
20 | .B udev | |
21 | config file. | |
22 | .TP | |
23 | .B UDEV_NO_SLEEP | |
24 | The default behavior of | |
25 | .B udev | |
fc238cff | 26 | is to wait until all the sysfs files of the device chain are populated. If set, |
bef370d6 | 27 | .B udev |
a3fa7908 | 28 | will continue, regardless of the state of the device representation. |
fc238cff KS |
29 | .TP |
30 | .B UDEV_NO_DEVD | |
31 | The default behavior of | |
32 | .B udev | |
33 | is to execute programs in the | |
34 | .I /etc/dev.d/ | |
35 | directory after device handling. If set, | |
36 | .B udev | |
37 | will skip this step. | |
04db8c9e GKH |
38 | .SH "DESCRIPTION" |
39 | .B udev | |
fc238cff KS |
40 | provides a dynamic device directory containing only the files for actually |
41 | present devices. It creates or removes device node files usually located in | |
42 | the /dev directory, or it renames network interfaces. | |
43 | .br | |
44 | ||
eb13ff87 | 45 | .P |
d3db5e5e | 46 | As part of the |
47 | .B hotplug | |
48 | subsystem, | |
49 | .B udev | |
eb13ff87 | 50 | is executed if a kernel device is added or removed from the system. |
d3db5e5e | 51 | On device creation, |
52 | .B udev | |
eb13ff87 | 53 | reads the sysfs directory of the given device to collect device attributes |
d3db5e5e | 54 | like label, serial number or bus device number. |
b86f56ff | 55 | These attributes may be used as keys to determine a |
fc238cff | 56 | unique name for the device. |
da86c7f0 KS |
57 | .B udev |
58 | maintains a database for devices present on the system. | |
eb13ff87 | 59 | .br |
d3db5e5e | 60 | On device removal, |
61 | .B udev | |
4bd46ac7 | 62 | queries its database for the name of the device file to be deleted. |
eb13ff87 | 63 | .SH "CONFIGURATION" |
83fa40fc KS |
64 | All |
65 | .B udev | |
66 | configuration files consist of a set of lines of text. All empty | |
b86f56ff | 67 | lines and lines beginning with a '#' will be ignored. |
4865de44 GKH |
68 | .P |
69 | ||
da86c7f0 | 70 | .B udev |
4865de44 | 71 | expects its main configuration file at |
167a27e7 | 72 | .IR /etc/udev/udev.conf . |
b86f56ff KS |
73 | The file consists of a set of variables and values allowing the user to |
74 | override default udev values. The following variables can be overridden | |
75 | in this file: | |
4865de44 GKH |
76 | .TP |
77 | .B udev_root | |
b86f56ff KS |
78 | Indicates where to place the device nodes in the filesystem. The default |
79 | value is | |
326e0876 | 80 | .IR @udevdir@ . |
4865de44 GKH |
81 | .TP |
82 | .B udev_db | |
b86f56ff | 83 | The name and location of the udev database. The default value is |
326e0876 | 84 | .IR @udevdir@/.udev.tdb . |
4865de44 GKH |
85 | .TP |
86 | .B udev_rules | |
b86f56ff | 87 | This is the location of the udev rules file. The default value for this is |
167a27e7 KS |
88 | .IR /etc/udev/udev.rules . |
89 | If a directory is specified, the whole directory is | |
90 | scanned for files ending with | |
91 | .I .rules | |
92 | and all rule files are read in lexical order. | |
4865de44 GKH |
93 | .TP |
94 | .B udev_permissions | |
167a27e7 KS |
95 | This is the location of the udev permission file. The default value for this is |
96 | .IR /etc/udev/udev.permissions . | |
97 | If a directory is specified, the whole directory is scanned for files ending with | |
98 | .I .permissions | |
99 | and all permission files are read in lexical order. | |
4865de44 | 100 | .TP |
0c040e8d | 101 | .B udev_log |
fc238cff KS |
102 | If you want udev to log some information to the syslog for every device handled. |
103 | The default value is | |
167a27e7 | 104 | .IR yes . |
0c040e8d | 105 | .TP |
4865de44 | 106 | .B default_mode |
b86f56ff KS |
107 | This is the default mode for all nodes not explicitely matching in the |
108 | permissions file. The default value is | |
167a27e7 | 109 | .IR 0666 . |
765cbd97 KS |
110 | .TP |
111 | .B default_owner | |
b86f56ff KS |
112 | This is the default owner for all nodes not explicitely matching in the |
113 | permissions file. The default value is | |
167a27e7 | 114 | .IR root . |
765cbd97 KS |
115 | .TP |
116 | .B default_group | |
b86f56ff KS |
117 | This is the default group for all nodes not explicitely matching in the |
118 | permissions file. The default value is | |
167a27e7 | 119 | .IR root . |
d3db5e5e | 120 | .br |
4865de44 | 121 | .P |
c6c13c31 | 122 | .RI "A sample " udev.conf " might look like this: |
4865de44 GKH |
123 | .sp |
124 | .nf | |
b86f56ff | 125 | # udev_root - where to place the device nodes in the filesystem |
326e0876 | 126 | udev_root="@udevdir@" |
4865de44 | 127 | |
b86f56ff | 128 | # udev_db - The name and location of the udev database |
326e0876 | 129 | udev_db="@udevdir@/.udev.tdb" |
4865de44 | 130 | |
167a27e7 KS |
131 | # udev_rules - The location of the directory where to look for files |
132 | which names ending with .rules | |
133 | udev_rules="/etc/udev/" | |
4865de44 GKH |
134 | |
135 | # udev_permissions - The name and location of the udev permission file | |
136 | udev_permissions="/etc/udev/udev.permissions" | |
137 | ||
0c040e8d GKH |
138 | # udev_log - set to "yes" if you want logging, else "no" |
139 | udev_log="yes" | |
140 | ||
b86f56ff KS |
141 | # default_mode - set the default mode for all nodes not |
142 | # explicitely matching in the permissions file | |
4865de44 | 143 | default_mode="0666" |
765cbd97 | 144 | |
b86f56ff KS |
145 | # default_owner - set the default owner for all nodes not |
146 | # explicitely matching in the permissions file | |
765cbd97 KS |
147 | default_owner="root" |
148 | ||
b86f56ff KS |
149 | # default_group - set the default group for all nodes not |
150 | # explicitely matching in the permissions file | |
765cbd97 | 151 | default_group="root" |
4865de44 GKH |
152 | .fi |
153 | .P | |
b86f56ff | 154 | The rules for udev to use when naming devices may specified in |
4865de44 | 155 | .I /etc/udev/udev.rules |
b86f56ff | 156 | or by the |
4865de44 | 157 | .I udev_rules |
d94df232 | 158 | value in the |
4865de44 GKH |
159 | .I /etc/udev/udev.conf |
160 | file. | |
161 | .P | |
4bd46ac7 | 162 | Every line in the rules file defines the mapping between device attributes |
fc238cff KS |
163 | and the device name. One or more keys are specified to match a rule with |
164 | the current device. If all keys are matching, the rule will be applied and | |
165 | the name is used to name the device file or the network interface. | |
c6c13c31 | 166 | .br |
4bd46ac7 | 167 | If no matching rule is found, the default kernel device name is used. |
3370fb21 | 168 | .P |
c5828665 | 169 | Every rule consists of a list of comma separated fields: |
eb13ff87 | 170 | .sp |
311e9ae6 | 171 | .IR "key " ,[ "key " ,...] " name " [, " symlink" ] |
eb13ff87 | 172 | .sp |
b86f56ff | 173 | where fields are: |
d3db5e5e | 174 | .TP |
e15b5ed5 | 175 | .B BUS |
4bd46ac7 KS |
176 | Match the bus type of the device. |
177 | (The sysfs device bus must be able to be determined by a "device" symlink.) | |
178 | .TP | |
179 | .B KERNEL | |
180 | Match the kernel device name. | |
181 | .TP | |
182 | .B ID | |
183 | Match the device number on the bus, like PCI bus id. | |
184 | .TP | |
185 | .B PLACE | |
186 | Match the topological position on bus, like physical port of USB device | |
187 | .TP | |
16378373 | 188 | .BI SYSFS{ filename } |
4bd46ac7 KS |
189 | Match sysfs device attribute like label, vendor, USB serial number, SCSI UUID |
190 | or file system label. Up to 5 different sysfs files can be checked, with | |
b86f56ff | 191 | all of the values being required to match the rule. |
d5f91372 KS |
192 | .br |
193 | Trailing whitespace characters in the sysfs attribute value are ignored, if | |
194 | the key doesn't have any trailing whitespace characters by itself. | |
4bd46ac7 KS |
195 | .TP |
196 | .B PROGRAM | |
197 | Call external program. This key is valid if the program returns successful. | |
dde05ccb | 198 | The environment variables of |
bef370d6 KS |
199 | .B udev |
200 | are also available for the program. | |
201 | .br | |
b86f56ff | 202 | The string returned by the program may be additionally matched with the |
4bd46ac7 KS |
203 | .B RESULT |
204 | key. | |
205 | .TP | |
206 | .B RESULT | |
207 | Match the returned string of the last | |
208 | .B PROGRAM | |
b86f56ff | 209 | call. This key may be used in any following rule after a |
4bd46ac7 KS |
210 | .B PROGRAM |
211 | call. | |
311e9ae6 | 212 | .TP |
16378373 | 213 | .B NAME |
fc238cff KS |
214 | The name of the node to be created, or the name, the network interface |
215 | should be renamed to. | |
311e9ae6 KS |
216 | .br |
217 | If given with the attribute | |
16378373 | 218 | .BR NAME{ all_partitions } |
311e9ae6 | 219 | it will create all 15 partitions of a blockdevice. |
16378373 | 220 | This may be useful for removable media devices. |
311e9ae6 KS |
221 | .TP |
222 | .B SYMLINK | |
223 | The name of a symlink targeting the node. Multiple symlinks may be | |
224 | specified by separating the names by the space character. | |
2bd07cf2 KS |
225 | .br |
226 | If both the name and the symlink fields are omitted or its | |
227 | values empty, the device will be ignored and no node will be created. | |
228 | .br | |
229 | If only the symlink field is given and the name field is omitted, | |
230 | the rule will not be applied immediatly, but the symlink field is added | |
231 | to the symlink list of the rule which will create the node. | |
232 | This makes it possible to specify additional symlinks in a possibly | |
233 | separate rules file, while the device nodes are maintained by the | |
234 | distribution provided rules file. | |
e41016d3 KS |
235 | .TP |
236 | .B OWNER, GROUP, MODE | |
237 | The permissions for this device. Every specified value overwrites the value | |
238 | given in the permissions file. | |
16378373 | 239 | .P |
c6c13c31 | 240 | .RB "The " NAME " ," SYMLINK " and " PROGRAM |
83fa40fc | 241 | fields support simple printf-like string substitution: |
4b710f03 KS |
242 | .TP |
243 | .B %n | |
c6c13c31 | 244 | The "kernel number" of the device. |
63ead27c | 245 | For example, 'sda3' has a "kernel number" of '3'. |
4b710f03 | 246 | .TP |
170ae44e GKH |
247 | .B %k |
248 | The "kernel name" for the device. | |
249 | .TP | |
4b710f03 | 250 | .B %M |
c6c13c31 | 251 | The kernel major number for the device. |
4b710f03 KS |
252 | .TP |
253 | .B %m | |
c6c13c31 | 254 | The kernel minor number for the device. |
4b710f03 KS |
255 | .TP |
256 | .B %b | |
c6c13c31 | 257 | The bus id for the device. |
67922099 GKH |
258 | .TP |
259 | .B %c | |
b86f56ff | 260 | The string returned from the execution of |
e68faf51 | 261 | .B PROGRAM |
e68faf51 KS |
262 | (This does not work within the |
263 | .B PROGRAM | |
264 | field for the obvious reason.) | |
ad63031e | 265 | .br |
b86f56ff | 266 | A single part of the string, separated by a space character |
c5828665 | 267 | may be selected by specifying the part number as an attribute: |
558f80ba KS |
268 | .BI %c{ N } |
269 | If the number is followed by the + char this part plus | |
270 | all remaining parts of the result string are substituted: | |
271 | .BI %c{ N+ } | |
ad63031e KS |
272 | .TP |
273 | .BI %s{ filename } | |
274 | The content of a sysfs attribute. | |
36043f84 | 275 | .TP |
b6864b4b | 276 | .B %% |
63ead27c KS |
277 | The '%' character itself. |
278 | .P | |
279 | The count of charcters to insert may be limited by specifying | |
280 | the format length value. For example, '%3s{file}' will only insert | |
281 | the first three characters of the sysfs attribute. | |
4b710f03 | 282 | .P |
c6c13c31 | 283 | .RI "A sample " udev.rules " might look like this:" |
eb13ff87 | 284 | .sp |
d3db5e5e | 285 | .nf |
67922099 | 286 | # if /sbin/scsi_id returns "OEM 0815" device will be called disk1 |
4bd46ac7 | 287 | BUS="scsi", PROGRAM="/sbin/scsi_id", RESULT="OEM 0815", NAME="disk1" |
67922099 | 288 | |
d3db5e5e | 289 | # USB printer to be called lp_color |
16378373 | 290 | BUS="usb", SYSFS{serial}="W09090207101241330", NAME="lp_color" |
d3db5e5e | 291 | |
b86f56ff | 292 | # SCSI disk with a specific vendor and model number will be called boot |
16378373 | 293 | BUS="scsi", SYSFS{vendor}="IBM", SYSFS{model}="ST336", NAME="boot%n" |
aa9c2a1e | 294 | |
d3db5e5e | 295 | # sound card with PCI bus id 00:0b.0 to be called dsp |
4bd46ac7 | 296 | BUS="pci", ID="00:0b.0", NAME="dsp" |
d3db5e5e | 297 | |
298 | # USB mouse at third port of the second hub to be called mouse1 | |
4bd46ac7 | 299 | BUS="usb", PLACE="2.3", NAME="mouse1" |
d3db5e5e | 300 | |
26004fcc | 301 | # ttyUSB1 should always be called pda with two additional symlinks |
4bd46ac7 | 302 | KERNEL="ttyUSB1", NAME="pda", SYMLINK="palmtop handheld" |
3370fb21 | 303 | |
26004fcc | 304 | # multiple USB webcams with symlinks to be called webcam0, webcam1, ... |
16378373 | 305 | BUS="usb", SYSFS{model}="XV3", NAME="video%n", SYMLINK="webcam%n" |
d3db5e5e | 306 | .fi |
eb13ff87 | 307 | .P |
b86f56ff | 308 | Permissions and ownership for the created device files may specified in |
4865de44 | 309 | .I /etc/udev/udev.permissions |
b86f56ff | 310 | or by the |
4865de44 | 311 | .I udev_permission |
c6c13c31 | 312 | value in the |
4865de44 GKH |
313 | .I /etc/udev/udev.conf |
314 | file. | |
eb13ff87 | 315 | .br |
5b8ba50a | 316 | Every line lists a device name followed by owner, group and permission |
07d7cfd1 | 317 | mode. All values are separated by colons. The name field may contain a |
83fa40fc | 318 | pattern to apply the values to a whole class of devices. |
eb13ff87 | 319 | .sp |
c6c13c31 | 320 | .RI "A sample " udev.permissions " might look like this:" |
eb13ff87 KS |
321 | .sp |
322 | .nf | |
323 | #name:user:group:mode | |
5b8ba50a | 324 | input/*:root:root:644 |
d0a4a110 | 325 | ttyUSB1:0:8:0660 |
5b8ba50a | 326 | video*:root:video:0660 |
eb13ff87 KS |
327 | dsp1:::0666 |
328 | .fi | |
07d7cfd1 | 329 | .P |
a6f01502 | 330 | The value |
331 | .I $local | |
b86f56ff | 332 | can be used instead of a specific username. In that case, udev will determine |
a6f01502 | 333 | the current local user at the time of device node creation and substitute |
334 | that username as the owner of the new device node. This is useful, for | |
335 | example, to let hot-plugged devices, such as cameras, be owned by the user at | |
336 | the current console. Note that if no user is currently logged in, or if udev | |
337 | otherwise fails to determine a current user, the | |
338 | .I default_owner | |
339 | value is used in lieu. | |
340 | .P | |
07d7cfd1 | 341 | A number of different fields in the above configuration files support a simple |
83fa40fc | 342 | form of shell style pattern matching. It supports the following pattern characters: |
07d7cfd1 GKH |
343 | .TP |
344 | .B * | |
345 | Matches zero, one, or more characters. | |
346 | .TP | |
347 | .B ? | |
348 | Matches any single character, but does not match zero characters. | |
349 | .TP | |
350 | .B [ ] | |
351 | Matches any single character specified within the brackets. For example, the | |
352 | pattern string "tty[SR]" would match either "ttyS" or "ttyR". Ranges are also | |
758f236f MI |
353 | supported within this match with the '\-' character. For example, to match on |
354 | the range of all digits, the pattern [0\-9] would be used. If the first character | |
b86f56ff | 355 | following the '[' is a '!', any character not enclosed is matched. |
fc238cff KS |
356 | .P |
357 | After device node creation, removal, or network device renaming, | |
358 | .B udev | |
359 | executes the programs in the directory tree under | |
360 | .IR /etc/dev.d/ . | |
361 | The name of a program must end with | |
362 | .I .dev | |
363 | suffix, to be recognized. | |
364 | .br | |
365 | In addition to the hotplug environment variables, | |
366 | .B DEVNAME | |
367 | is exported to make the name of the created node, or the name the network | |
368 | device is renamed to, available to the executed program. The programs in every | |
369 | directory are sorted in lexical order, while the directories are searched in | |
370 | the following order: | |
371 | .sp | |
372 | .nf | |
373 | /etc/dev.d/$(DEVNAME)/*.dev | |
374 | /etc/dev.d/$(SUBSYSTEM)/*.dev | |
375 | /etc/dev.d/default/*.dev | |
376 | .fi | |
04db8c9e GKH |
377 | .SH "FILES" |
378 | .nf | |
04db8c9e | 379 | /sbin/udev udev program |
4865de44 | 380 | /etc/udev/* udev config files |
04db8c9e | 381 | /etc/hotplug.d/default/udev.hotplug hotplug symlink to udev program |
fc238cff | 382 | /etc/dev.d/* programs invoked by udev |
04db8c9e GKH |
383 | .fi |
384 | .LP | |
385 | .SH "SEE ALSO" | |
05c0c9da | 386 | .BR udevinfo (8), |
bef370d6 | 387 | .BR udevd (8), |
eb13ff87 | 388 | .BR hotplug (8) |
04db8c9e GKH |
389 | .PP |
390 | The | |
758f236f | 391 | .I http://linux\-hotplug.sourceforge.net/ |
04db8c9e GKH |
392 | web site. |
393 | .SH AUTHORS | |
da86c7f0 KS |
394 | .B udev |
395 | was developed by Greg Kroah-Hartman <greg@kroah.com> with much help from | |
fc1f0d43 GKH |
396 | Dan Stekloff <dsteklof@us.ibm.com>, Kay Sievers <kay.sievers@vrfy.org>, and |
397 | many others. |