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