]> git.ipfire.org Git - thirdparty/systemd.git/blame - udev.8
[PATCH] udev - switch SYSFS_file to SYSFS{file}
[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.
4bd46ac7
KS
21These attributes may used as keys to determine a
22unique 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
4bd46ac7 28queries its 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
0c040e8d
GKH
60.B udev_log
61If you want udev to log some information to the syslog for every node created or
62removed. The default value for this is
63.I yes
64.TP
4865de44
GKH
65.B default_mode
66This is the default mode for all nodes that have no explicit match in the
67permissions file. The default value for this is
68.I 0666
765cbd97
KS
69.TP
70.B default_owner
71This is the default owner for all nodes that have no explicit match in the
72permissions file. The default value for this is
73.I root
74.TP
75.B default_group
76This is the default group for all nodes that have no explicit match in the
77permissions file. The default value for this is
78.I root
d3db5e5e 79.br
4865de44 80.P
c6c13c31 81.RI "A sample " udev.conf " might look like this:
4865de44
GKH
82.sp
83.nf
84# udev_root - where in the filesystem to place the device nodes
85udev_root="/udev/"
86
87# udev_db - The name and location of the udev database.
88udev_db="/udev/.udev.tdb"
89
90# udev_rules - The name and location of the udev rules file
91udev_rules="/etc/udev/udev.rules"
92
93# udev_permissions - The name and location of the udev permission file
94udev_permissions="/etc/udev/udev.permissions"
95
0c040e8d
GKH
96# udev_log - set to "yes" if you want logging, else "no"
97udev_log="yes"
98
e15b5ed5 99# default_mode - set the default mode for all nodes that have no
4865de44
GKH
100# explicit match in the permissions file
101default_mode="0666"
765cbd97
KS
102
103# default_owner - set the default owner for all nodes that have no
104# explicit match in the permissions file
105default_owner="root"
106
107# default_group - set the default group for all nodes that have no
108# explicit match in the permissions file
109default_group="root"
4865de44
GKH
110.fi
111.P
112The rules for udev to use when naming devices may specified at
113.I /etc/udev/udev.rules
c6c13c31 114or specified by the
4865de44 115.I udev_rules
d94df232 116value in the
4865de44
GKH
117.I /etc/udev/udev.conf
118file.
119.P
4bd46ac7
KS
120Every line in the rules file defines the mapping between device attributes
121and the device file name. One ore more keys are specified to match a rule
122with the current device. If all keys are matching, the rule will be applied
123and the name is used for the device node. One or more optional symlinks
124targeting the node may be specified.
c6c13c31 125.br
4bd46ac7 126If no matching rule is found, the default kernel device name is used.
3370fb21 127.P
eb13ff87 128The line format is:
eb13ff87 129.sp
4bd46ac7 130.I key,[key,...] name [, symlink]
eb13ff87 131.sp
4bd46ac7 132where keys are:
d3db5e5e 133.TP
e15b5ed5 134.B BUS
4bd46ac7
KS
135Match the bus type of the device.
136(The sysfs device bus must be able to be determined by a "device" symlink.)
137.TP
138.B KERNEL
139Match the kernel device name.
140.TP
141.B ID
142Match the device number on the bus, like PCI bus id.
143.TP
144.B PLACE
145Match the topological position on bus, like physical port of USB device
146.TP
16378373 147.BI SYSFS{ filename }
4bd46ac7
KS
148Match sysfs device attribute like label, vendor, USB serial number, SCSI UUID
149or file system label. Up to 5 different sysfs files can be checked, with
150all of the values being required in order to match the rule.
151.TP
152.B PROGRAM
153Call external program. This key is valid if the program returns successful.
154The string returned by the program may additionally matched with the
155.B RESULT
156key.
157.TP
158.B RESULT
159Match the returned string of the last
160.B PROGRAM
161call. This key may used in any following rule after a
162.B PROGRAM
163call.
eb13ff87 164.P
16378373
KS
165The
166.B NAME
167field given with the attribute
168.BR NAME{ all_partitions }
169will create all 15 partitions of a blockdevice.
170This may be useful for removable media devices.
171.P
c6c13c31 172.RB "The " NAME " ," SYMLINK " and " PROGRAM
83fa40fc 173fields support simple printf-like string substitution:
4b710f03
KS
174.TP
175.B %n
c6c13c31 176The "kernel number" of the device.
4b710f03
KS
177for example, 'sda3' has a "kernel number" of '3'
178.TP
170ae44e
GKH
179.B %k
180The "kernel name" for the device.
181.TP
4b710f03 182.B %M
c6c13c31 183The kernel major number for the device.
4b710f03
KS
184.TP
185.B %m
c6c13c31 186The kernel minor number for the device.
4b710f03
KS
187.TP
188.B %b
c6c13c31 189The bus id for the device.
67922099
GKH
190.TP
191.B %c
e68faf51
KS
192The
193.B PROGRAM
194returned string.
195(This does not work within the
196.B PROGRAM
197field for the obvious reason.)
36043f84 198.TP
b6864b4b
KS
199.B %%
200The '%' char itself.
4b710f03 201.P
c6c13c31 202.RI "A sample " udev.rules " might look like this:"
eb13ff87 203.sp
d3db5e5e 204.nf
67922099 205# if /sbin/scsi_id returns "OEM 0815" device will be called disk1
4bd46ac7 206BUS="scsi", PROGRAM="/sbin/scsi_id", RESULT="OEM 0815", NAME="disk1"
67922099 207
d3db5e5e 208# USB printer to be called lp_color
16378373 209BUS="usb", SYSFS{serial}="W09090207101241330", NAME="lp_color"
d3db5e5e 210
aa9c2a1e 211# SCSI disk with a specific vendor and model number is to be called boot
16378373 212BUS="scsi", SYSFS{vendor}="IBM", SYSFS{model}="ST336", NAME="boot%n"
aa9c2a1e 213
d3db5e5e 214# sound card with PCI bus id 00:0b.0 to be called dsp
4bd46ac7 215BUS="pci", ID="00:0b.0", NAME="dsp"
d3db5e5e 216
217# USB mouse at third port of the second hub to be called mouse1
4bd46ac7 218BUS="usb", PLACE="2.3", NAME="mouse1"
d3db5e5e 219
26004fcc 220# ttyUSB1 should always be called pda with two additional symlinks
4bd46ac7 221KERNEL="ttyUSB1", NAME="pda", SYMLINK="palmtop handheld"
3370fb21 222
26004fcc 223# multiple USB webcams with symlinks to be called webcam0, webcam1, ...
16378373 224BUS="usb", SYSFS{model}="XV3", NAME="video%n", SYMLINK="webcam%n"
d3db5e5e 225.fi
eb13ff87
KS
226.P
227Permissions and ownership for the created device files may specified at
4865de44 228.I /etc/udev/udev.permissions
c6c13c31 229or specified by the
4865de44 230.I udev_permission
c6c13c31 231value in the
4865de44
GKH
232.I /etc/udev/udev.conf
233file.
eb13ff87 234.br
5b8ba50a 235Every line lists a device name followed by owner, group and permission
07d7cfd1 236mode. All values are separated by colons. The name field may contain a
83fa40fc 237pattern to apply the values to a whole class of devices.
67922099 238.br
5b8ba50a
KS
239If
240.B udev
241was built using klibc or is used before the user database is accessible (e.g.
c6c13c31 242.BR initrd "(4)), only numeric owner and group values may be used."
eb13ff87 243.sp
c6c13c31 244.RI "A sample " udev.permissions " might look like this:"
eb13ff87
KS
245.sp
246.nf
247#name:user:group:mode
5b8ba50a 248input/*:root:root:644
d0a4a110 249ttyUSB1:0:8:0660
5b8ba50a 250video*:root:video:0660
eb13ff87
KS
251dsp1:::0666
252.fi
07d7cfd1
GKH
253.P
254A number of different fields in the above configuration files support a simple
83fa40fc 255form of shell style pattern matching. It supports the following pattern characters:
07d7cfd1
GKH
256.TP
257.B *
258Matches zero, one, or more characters.
259.TP
260.B ?
261Matches any single character, but does not match zero characters.
262.TP
263.B [ ]
264Matches any single character specified within the brackets. For example, the
265pattern string "tty[SR]" would match either "ttyS" or "ttyR". Ranges are also
266supported within this match with the '-' character. For example, to match on
83fa40fc
KS
267the range of all digits, the pattern [0-9] would be used. If the first character
268following the '[' is a '!' then any character not enclosed is matched.
04db8c9e
GKH
269.SH "FILES"
270.nf
04db8c9e 271/sbin/udev udev program
4865de44 272/etc/udev/* udev config files
04db8c9e
GKH
273/etc/hotplug.d/default/udev.hotplug hotplug symlink to udev program
274.fi
275.LP
276.SH "SEE ALSO"
05c0c9da 277.BR udevinfo (8),
eb13ff87 278.BR hotplug (8)
04db8c9e
GKH
279.PP
280The
281.I http://linux-hotplug.sourceforge.net/
282web site.
283.SH AUTHORS
da86c7f0
KS
284.B udev
285was developed by Greg Kroah-Hartman <greg@kroah.com> with much help from
fc1f0d43
GKH
286Dan Stekloff <dsteklof@us.ibm.com>, Kay Sievers <kay.sievers@vrfy.org>, and
287many others.