]> git.ipfire.org Git - thirdparty/systemd.git/blame - udev.8
[PATCH] change devfs disk name rule from 'disk' to 'disc'
[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.
d4112087
GKH
21These attributes are treated as a key
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
GKH
89.I udev_rules
90value in the
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
115file system label
3370fb21 116.br
c6c13c31
KS
117.RB "keys: " BUS ", "
118.I sysfs_attribute
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
c6c13c31 133.RB "key: " KERNEL_NAME
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
145.B %M
c6c13c31 146The kernel major number for the device.
4b710f03
KS
147.TP
148.B %m
c6c13c31 149The kernel minor number for the device.
4b710f03
KS
150.TP
151.B %b
c6c13c31 152The bus id for the device.
67922099
GKH
153.TP
154.B %c
c6c13c31
KS
155The CALLOUT program returned string.
156(This does not work within the PROGRAM field for the obvious reason.)
36043f84
GKH
157.TP
158.B %D
159Use the devfs style disk name for this device.
160For partitions, this will result in 'part%n'
525d07e7 161If this is not a partition, it will result in 'disc'.
4b710f03 162.P
c6c13c31 163.RI "A sample " udev.rules " might look like this:"
eb13ff87 164.sp
d3db5e5e 165.nf
67922099
GKH
166# if /sbin/scsi_id returns "OEM 0815" device will be called disk1
167CALLOUT, BUS="scsi", PROGRAM="/sbin/scsi_id", ID="OEM 0815", NAME="disk1"
168
d3db5e5e 169# USB printer to be called lp_color
170LABEL, BUS="usb", serial="W09090207101241330", NAME="lp_color"
171
172# sound card with PCI bus id 00:0b.0 to be called dsp
3370fb21 173NUMBER, BUS="pci", ID="00:0b.0", NAME="dsp"
d3db5e5e 174
175# USB mouse at third port of the second hub to be called mouse1
3370fb21 176TOPOLOGY, BUS="usb", PLACE="2.3", NAME="mouse1"
d3db5e5e 177
26004fcc
KS
178# ttyUSB1 should always be called pda with two additional symlinks
179REPLACE, KERNEL="ttyUSB1", NAME="pda", SYMLINK="palmtop handheld"
3370fb21 180
26004fcc
KS
181# multiple USB webcams with symlinks to be called webcam0, webcam1, ...
182LABEL, BUS="usb", model="WebCam V3", NAME="video%n", SYMLINK="webcam%n"
d3db5e5e 183.fi
eb13ff87
KS
184.P
185Permissions and ownership for the created device files may specified at
4865de44 186.I /etc/udev/udev.permissions
c6c13c31 187or specified by the
4865de44 188.I udev_permission
c6c13c31 189value in the
4865de44
GKH
190.I /etc/udev/udev.conf
191file.
eb13ff87 192.br
5b8ba50a 193Every line lists a device name followed by owner, group and permission
07d7cfd1 194mode. All values are separated by colons. The name field may contain a
83fa40fc 195pattern to apply the values to a whole class of devices.
67922099 196.br
5b8ba50a
KS
197If
198.B udev
199was built using klibc or is used before the user database is accessible (e.g.
c6c13c31 200.BR initrd "(4)), only numeric owner and group values may be used."
eb13ff87 201.sp
c6c13c31 202.RI "A sample " udev.permissions " might look like this:"
eb13ff87
KS
203.sp
204.nf
205#name:user:group:mode
5b8ba50a 206input/*:root:root:644
d0a4a110 207ttyUSB1:0:8:0660
5b8ba50a 208video*:root:video:0660
eb13ff87
KS
209dsp1:::0666
210.fi
07d7cfd1
GKH
211.P
212A number of different fields in the above configuration files support a simple
83fa40fc 213form of shell style pattern matching. It supports the following pattern characters:
07d7cfd1
GKH
214.TP
215.B *
216Matches zero, one, or more characters.
217.TP
218.B ?
219Matches any single character, but does not match zero characters.
220.TP
221.B [ ]
222Matches any single character specified within the brackets. For example, the
223pattern string "tty[SR]" would match either "ttyS" or "ttyR". Ranges are also
224supported within this match with the '-' character. For example, to match on
83fa40fc
KS
225the range of all digits, the pattern [0-9] would be used. If the first character
226following the '[' is a '!' then any character not enclosed is matched.
04db8c9e
GKH
227.SH "FILES"
228.nf
04db8c9e 229/sbin/udev udev program
4865de44 230/etc/udev/* udev config files
04db8c9e
GKH
231/etc/hotplug.d/default/udev.hotplug hotplug symlink to udev program
232.fi
233.LP
234.SH "SEE ALSO"
eb13ff87 235.BR hotplug (8)
04db8c9e
GKH
236.PP
237The
238.I http://linux-hotplug.sourceforge.net/
239web site.
240.SH AUTHORS
da86c7f0
KS
241.B udev
242was developed by Greg Kroah-Hartman <greg@kroah.com> with much help from
fc1f0d43
GKH
243Dan Stekloff <dsteklof@us.ibm.com>, Kay Sievers <kay.sievers@vrfy.org>, and
244many others.