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