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