]> git.ipfire.org Git - thirdparty/systemd.git/blame - udev.8.in
[PATCH] klibc: remove SCCS directories from the temporary klibc install
[thirdparty/systemd.git] / udev.8.in
CommitLineData
d3db5e5e 1.TH UDEV 8 "October 2003" "" "Linux Administrator's Manual"
04db8c9e 2.SH NAME
d3db5e5e 3udev \- Linux configurable dynamic device naming support
04db8c9e 4.SH SYNOPSIS
eb13ff87 5.BI udev " hotplug-subsystem"
04db8c9e
GKH
6.SH "DESCRIPTION"
7.B udev
fc238cff
KS
8provides a dynamic device directory containing only the files for actually
9present devices. It creates or removes device node files usually located in
10the /dev directory, or it renames network interfaces.
11.br
eb13ff87 12.P
d3db5e5e 13As part of the
14.B hotplug
15subsystem,
16.B udev
eb13ff87 17is executed if a kernel device is added or removed from the system.
d3db5e5e 18On device creation,
19.B udev
eb13ff87 20reads the sysfs directory of the given device to collect device attributes
d3db5e5e 21like label, serial number or bus device number.
b86f56ff 22These attributes may be used as keys to determine a
fc238cff 23unique name for the device.
da86c7f0
KS
24.B udev
25maintains a database for devices present on the system.
eb13ff87 26.br
d3db5e5e 27On device removal,
28.B udev
4bd46ac7 29queries its database for the name of the device file to be deleted.
eb13ff87 30.SH "CONFIGURATION"
83fa40fc
KS
31All
32.B udev
3ac03269 33configuration files consist of a set of lines of text. All empty
5bc597fe 34lines or lines beginning with '#' will be ignored.
4865de44 35.P
da86c7f0 36.B udev
4865de44 37expects its main configuration file at
167a27e7 38.IR /etc/udev/udev.conf .
b86f56ff
KS
39The file consists of a set of variables and values allowing the user to
40override default udev values. The following variables can be overridden
41in this file:
4865de44
GKH
42.TP
43.B udev_root
b86f56ff
KS
44Indicates where to place the device nodes in the filesystem. The default
45value is
aef6bb13 46.IR @udevdir@/ .
4865de44
GKH
47.TP
48.B udev_db
b86f56ff 49The name and location of the udev database. The default value is
2b41e68a 50.IR @udevdir@/.udevdb .
4865de44
GKH
51.TP
52.B udev_rules
a5327755
KS
53The name of the udev rules file or directory to look for files with the suffix
54.IR .rules .
55All rule files are read in lexical order. The default value is
aef6bb13 56.IR /etc/udev/rules.d/ .
4865de44 57.TP
0c040e8d 58.B udev_log
5bc597fe 59The switch to enable/disable logging of udev information
fc238cff 60The default value is
167a27e7 61.IR yes .
4865de44 62.P
3ac03269 63.RI "A sample " udev.conf " file might look like this:
4865de44
GKH
64.sp
65.nf
b86f56ff 66# udev_root - where to place the device nodes in the filesystem
aef6bb13 67udev_root="/udev"
4865de44 68
b86f56ff 69# udev_db - The name and location of the udev database
2b41e68a 70udev_db="/udev/.udevdb"
4865de44 71
a5327755
KS
72# udev_rules - The name of the udev rules file or directory to look
73 for files with the suffix .rules
74udev_rules="/etc/udev/rules.d/"
4865de44 75
0c040e8d
GKH
76# udev_log - set to "yes" if you want logging, else "no"
77udev_log="yes"
4865de44
GKH
78.fi
79.P
5bc597fe 80The rules for device naming are read from the files located in the
aef6bb13
KS
81.I /etc/udev/rules.d/
82directory, or at the location specified by the
4865de44 83.I udev_rules
d94df232 84value in the
4865de44
GKH
85.I /etc/udev/udev.conf
86file.
aef6bb13 87.br
4bd46ac7 88Every line in the rules file defines the mapping between device attributes
fc238cff
KS
89and the device name. One or more keys are specified to match a rule with
90the current device. If all keys are matching, the rule will be applied and
91the name is used to name the device file or the network interface.
c6c13c31 92.br
4bd46ac7 93If no matching rule is found, the default kernel device name is used.
3370fb21 94.P
28ce66de 95Every rule consists of a list of comma separated key value fields:
eb13ff87 96.sp
28ce66de
KS
97.IR "key " ,[ "key " ,...]
98.P
99The following key names can be used to match against device properties:
d3db5e5e 100.TP
e15b5ed5 101.B BUS
4bd46ac7
KS
102Match the bus type of the device.
103(The sysfs device bus must be able to be determined by a "device" symlink.)
104.TP
105.B KERNEL
106Match the kernel device name.
107.TP
6818c51d 108.B SUBSYSTEM
2092fbcd 109Match the kernel subsystem name.
6818c51d 110.TP
2092fbcd
KS
111.B DRIVER
112Match the kernel driver name.
6818c51d 113.TP
4bd46ac7
KS
114.B ID
115Match the device number on the bus, like PCI bus id.
116.TP
16378373 117.BI SYSFS{ filename }
3e5958de
KS
118Match sysfs device attribute like vendor and product id's, USB serial number
119or the SCSI disk model number. Up to 5 different sysfs files can be checked,
120with all of the values being required to match the rule.
d5f91372
KS
121.br
122Trailing whitespace characters in the sysfs attribute value are ignored, if
123the key doesn't have any trailing whitespace characters by itself.
4bd46ac7 124.TP
3e5958de
KS
125.BI ENV{ variable }
126Match an environment variable. Up to 5 different environment variables can be
127checked, with all of the values being required to match the rule.
128.TP
4bd46ac7
KS
129.B PROGRAM
130Call external program. This key is valid if the program returns successful.
dde05ccb 131The environment variables of
bef370d6 132.B udev
28ce66de 133are also available to the program.
bef370d6 134.br
b86f56ff 135The string returned by the program may be additionally matched with the
4bd46ac7 136.B RESULT
28ce66de 137key in the same or any later rule.
4bd46ac7
KS
138.TP
139.B RESULT
140Match the returned string of the last
141.B PROGRAM
28ce66de 142call. This key can be used in the same or in any later rule after a
4bd46ac7
KS
143.B PROGRAM
144call.
28ce66de
KS
145.P
146The following keys can get values assigned:
311e9ae6 147.TP
16378373 148.B NAME
fc238cff
KS
149The name of the node to be created, or the name, the network interface
150should be renamed to.
311e9ae6
KS
151.TP
152.B SYMLINK
153The name of a symlink targeting the node. Multiple symlinks may be
154specified by separating the names by the space character.
2bd07cf2
KS
155.br
156If both the name and the symlink fields are omitted or its
5bc597fe 157values are empty, the device will be ignored and no node will be created.
2bd07cf2
KS
158.br
159If only the symlink field is given and the name field is omitted,
5bc597fe 160the rule will not be applied immediately, but the symlink field is added
2bd07cf2
KS
161to the symlink list of the rule which will create the node.
162This makes it possible to specify additional symlinks in a possibly
163separate rules file, while the device nodes are maintained by the
164distribution provided rules file.
e41016d3
KS
165.TP
166.B OWNER, GROUP, MODE
9f8dfa19 167The permissions for the device node. Every specified value overwrites the
3908058c 168compiled-in default value.
fd9efc00
KS
169.TP
170.B OPTIONS
28ce66de
KS
171.B last_rule
172will be the last rule applied. No later rules will have any effect.
173.sp
174.B OPTIONS
fd9efc00
KS
175.B ignore_device
176will ignore this device. No node will be created.
177.sp
178.B ignore_remove
179will ignore any later remove event for this device.
180This may be useful as a workaround for broken device drivers.
181.sp
182.B all_partitions
183will create device nodes for all available partitions of a blockdevice.
184This may be useful for removable media devices which do not detect a media
185change.
186.sp
187Multiple attributes may be separated by comma.
16378373 188.P
9f8dfa19 189.RB "The " NAME ", " SYMLINK ", " PROGRAM ", " OWNER " and " GROUP
5bc597fe 190fields support simple printf-like string substitutions:
4b710f03
KS
191.TP
192.B %n
c6c13c31 193The "kernel number" of the device.
63ead27c 194For example, 'sda3' has a "kernel number" of '3'.
4b710f03 195.TP
170ae44e
GKH
196.B %k
197The "kernel name" for the device.
198.TP
c1ab0461
KS
199.B %p
200The devpath for the device.
201.TP
4b710f03 202.B %M
c6c13c31 203The kernel major number for the device.
4b710f03
KS
204.TP
205.B %m
c6c13c31 206The kernel minor number for the device.
4b710f03
KS
207.TP
208.B %b
c6c13c31 209The bus id for the device.
67922099
GKH
210.TP
211.B %c
5bc597fe 212The string returned by the external program, specified in
e68faf51 213.B PROGRAM
e68faf51
KS
214(This does not work within the
215.B PROGRAM
216field for the obvious reason.)
ad63031e 217.br
b86f56ff 218A single part of the string, separated by a space character
c5828665 219may be selected by specifying the part number as an attribute:
558f80ba
KS
220.BI %c{ N }
221If the number is followed by the + char this part plus
222all remaining parts of the result string are substituted:
223.BI %c{ N+ }
ad63031e 224.TP
c1ab0461
KS
225.B %N
226The name of a created temporary device node to provide access to the
227device from a external program.
228.TP
69aa6dfb
KS
229.B %P
230The node name of the parent device.
231.TP
ad63031e
KS
232.BI %s{ filename }
233The content of a sysfs attribute.
36043f84 234.TP
0a8dd7f3
DZ
235.B %e
236If a device node already exists with the name, the smallest positive
237decimal integer N is substituted such that the resulting name doesn't
238match an existing device node. Otherwise nothing is substituted. This
239can be used to create compatibility symlinks and enumerate devices of
240the same type originating from different kernel subsystems.
29e8ed4c
KS
241.sp
242Note: The use of the enumeration facility is unreliable outside of
243udevstart where the node creation is serialized and predictable.
244The returned numbers rely on the order devices are probed on the
245system. If more than one device requests an enumeration for the same
246name at the same time, it may be possible that both requests receive the
247same name back from the database. The use of enumerations in todays setups
248where device can come and go at any time is not recomended.
0a8dd7f3 249.TP
b6864b4b 250.B %%
63ead27c
KS
251The '%' character itself.
252.P
253The count of charcters to insert may be limited by specifying
254the format length value. For example, '%3s{file}' will only insert
255the first three characters of the sysfs attribute.
4b710f03 256.P
3ac03269 257.RI "A sample " udev.rules " file might look like this:"
eb13ff87 258.sp
d3db5e5e 259.nf
5bc597fe 260# if /sbin/scsi_id returns "OEM 0815", the device will be called disk1
28ce66de 261BUS=="scsi", PROGRAM=="/sbin/scsi_id", RESULT=="OEM 0815", NAME="disk1"
67922099 262
d3db5e5e 263# USB printer to be called lp_color
28ce66de 264BUS=="usb", SYSFS{serial}=="W09090207101241330", NAME="lp_color"
d3db5e5e 265
b86f56ff 266# SCSI disk with a specific vendor and model number will be called boot
28ce66de 267BUS=="scsi", SYSFS{vendor}=="IBM", SYSFS{model}=="ST336", NAME="boot%n"
aa9c2a1e 268
d3db5e5e 269# sound card with PCI bus id 00:0b.0 to be called dsp
28ce66de 270BUS=="pci", ID=="00:0b.0", NAME="dsp"
d3db5e5e 271
272# USB mouse at third port of the second hub to be called mouse1
28ce66de 273BUS=="usb", ID=="2.3", NAME="mouse1"
d3db5e5e 274
26004fcc 275# ttyUSB1 should always be called pda with two additional symlinks
28ce66de 276KERNEL=="ttyUSB1", NAME="pda", SYMLINK="palmtop handheld"
3370fb21 277
26004fcc 278# multiple USB webcams with symlinks to be called webcam0, webcam1, ...
28ce66de 279BUS=="usb", SYSFS{model}=="XV3", NAME=="video%n", SYMLINK="webcam%n"
0a8dd7f3
DZ
280
281# grouping of optical drives from multiple kernel subsystems
28ce66de
KS
282KERNEL=="sr*", NAME="%k", SYMLINK="cdrom%e"
283KERNEL=="scd*", NAME="%k", SYMLINK="cdrom%e"
284KERNEL=="pcd*", NAME="%k", SYMLINK="cdrom%e"
285KERNEL=="hd[a-z]", PROGRAM=="/bin/cat /proc/ide/%k/media", RESULT=="cdrom",
0a8dd7f3 286 NAME="%k", SYMLINK="cdrom%e"
d3db5e5e 287.fi
eb13ff87 288.P
07d7cfd1 289A number of different fields in the above configuration files support a simple
83fa40fc 290form of shell style pattern matching. It supports the following pattern characters:
07d7cfd1
GKH
291.TP
292.B *
293Matches zero, one, or more characters.
294.TP
295.B ?
296Matches any single character, but does not match zero characters.
297.TP
298.B [ ]
299Matches any single character specified within the brackets. For example, the
3ac03269
TK
300pattern string "tty[SR]" would match either "ttyS" or "ttyR". Ranges are also
301supported within this match with the '\-' character. For example, to match on
758f236f 302the range of all digits, the pattern [0\-9] would be used. If the first character
5bc597fe 303following the '[' is a '!', any characters not enclosed are matched.
fc238cff
KS
304.P
305After device node creation, removal, or network device renaming,
306.B udev
3ac03269 307executes the programs located in the directory tree under
fc238cff 308.IR /etc/dev.d/ .
5bc597fe 309The name of a program must have the suffix
fc238cff 310.I .dev
5bc597fe 311to be recognized.
fc238cff
KS
312.br
313In addition to the hotplug environment variables,
a0294b76
KS
314.B UDEV_LOG
315is set if udev is configured to use the syslog facility. Executed programs may
316want to follow that setting.
fc238cff
KS
317.B DEVNAME
318is exported to make the name of the created node, or the name the network
3ac03269 319device is renamed to, available to the executed program. The programs in every
fc238cff
KS
320directory are sorted in lexical order, while the directories are searched in
321the following order:
322.sp
323.nf
324/etc/dev.d/$(DEVNAME)/*.dev
325/etc/dev.d/$(SUBSYSTEM)/*.dev
326/etc/dev.d/default/*.dev
327.fi
3ac03269
TK
328.SH "ENVIRONMENT"
329.P
330The following variables are read from the environment:
331.TP
332.B ACTION
333.IR add " or " remove
334signifies the addition or the removal of a device.
335.TP
336.B DEVPATH
337The sysfs devpath of the device without the mountpoint but a leading slash.
338.TP
339.B SUBSYSTEM
340The subsystem the device belongs to. Alternatively the subsystem may
341be passed as the first argument.
342.TP
343.B UDEV_CONFIG_FILE
344Overrides the default location of the
345.B udev
346config file.
347.TP
348.B UDEV_NO_DEVD
349The default behavior of
350.B udev
351is to execute programs in the
352.I /etc/dev.d/
353directory after device handling. If set,
354.B udev
355will skip this step.
04db8c9e
GKH
356.SH "FILES"
357.nf
04db8c9e 358/sbin/udev udev program
4865de44 359/etc/udev/* udev config files
04db8c9e 360/etc/hotplug.d/default/udev.hotplug hotplug symlink to udev program
fc238cff 361/etc/dev.d/* programs invoked by udev
04db8c9e 362.fi
04db8c9e 363.SH "SEE ALSO"
05c0c9da 364.BR udevinfo (8),
bef370d6 365.BR udevd (8),
eb13ff87 366.BR hotplug (8)
04db8c9e 367.PP
3ac03269
TK
368.B Web resources:
369.nf
758f236f 370.I http://linux\-hotplug.sourceforge.net/
3ac03269
TK
371.I http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html
372.fi
04db8c9e 373.SH AUTHORS
da86c7f0
KS
374.B udev
375was developed by Greg Kroah-Hartman <greg@kroah.com> with much help from
fc1f0d43
GKH
376Dan Stekloff <dsteklof@us.ibm.com>, Kay Sievers <kay.sievers@vrfy.org>, and
377many others.