1UDEV(7)                              udev                              UDEV(7)
2
3
4

NAME

6       udev - dynamic device management
7

DESCRIPTION

9       udev provides a dynamic device directory containing only the files for
10       actually present devices. It creates or removes device node files in
11       the /dev directory, or it renames network interfaces.
12
13       Usually udev runs as udevd(8) and receives uevents directly from the
14       kernel if a device is added or removed from the system.
15
16       If udev receives a device event, it matches its configured rules
17       against the available device attributes provided in sysfs to identify
18       the device. Rules that match may provide additional device information
19       or specify a device node name and multiple symlink names and instruct
20       udev to run additional programs as part of the device event handling.
21

CONFIGURATION

23       udev configuration files are placed in /etc/udev/ and /lib/udev/. All
24       empty lines, or lines beginning with ´#´ will be ignored.
25
26   Configuration file
27       udev expects its main configuration file at /etc/udev/udev.conf. It
28       consists of a set of variables allowing the user to override default
29       udev values. The following variables can be set:
30
31       udev_root
32           Specifies where to place the device nodes in the filesystem. The
33           default value is /dev.
34
35       udev_log
36           The logging priority. Valid values are the numerical syslog
37           priorities or their textual representations: err, info and debug.
38
39   Rules files
40       The udev rules are read from the files located in the default rules
41       directory /lib/udev/rules.d/, the custom rules directory
42       /etc/udev/rules.d/ and the temporary rules directory
43       /dev/.udev/rules.d/. All rule files are sorted and processed in lexical
44       order, regardless in which of these directories they live.
45
46       Rule files are required to have a unique name, duplicate file names are
47       ignored. Files in /etc/udev/rules.d/ have precedence over files with
48       the same name in /lib/udev/rules.d/. This can be used to ignore a
49       default rules file if needed.
50
51       Every line in the rules file contains at least one key value pair.
52       There are two kind of keys, match and assignment keys. If all match
53       keys are matching against its value, the rule gets applied and the
54       assign keys get the specified value assigned.
55
56       A matching rule may specify the name of the device node, add a symlink
57       pointing to the node, or run a specified program as part of the event
58       handling. If no matching rule is found, the default device node name is
59       used.
60
61       A rule consists of a list of one or more key value pairs separated by a
62       comma. Each key has a distinct operation, depending on the used
63       operator. Valid operators are:
64
65       ==
66           Compare for equality.
67
68       !=
69           Compare for inequality.
70
71       =
72           Assign a value to a key. Keys that represent a list, are reset and
73           only this single value is assigned.
74
75       +=
76           Add the value to a key that holds a list of entries.
77
78       :=
79           Assign a value to a key finally; disallow any later changes, which
80           may be used to prevent changes by any later rules.
81
82       The following key names can be used to match against device properties.
83       Some of the keys also match against properties of the parent devices in
84       sysfs, not only the device that has generated the event. If multiple
85       keys that match a parent device are specified in a single rule, all
86       these keys must match at one and the same parent device.
87
88       ACTION
89           Match the name of the event action.
90
91       DEVPATH
92           Match the devpath of the event device.
93
94       KERNEL
95           Match the name of the event device.
96
97       NAME
98           Match the name of the node or network interface. It can be used
99           once the NAME key has been set in one of the preceding rules.
100
101       SYMLINK
102           Match the name of a symlink targeting the node. It can be used once
103           a SYMLINK key has been set in one of the preceding rules. There may
104           be multiple symlinks; only one needs to match.
105
106       SUBSYSTEM
107           Match the subsystem of the event device.
108
109       DRIVER
110           Match the driver name of the event device. Only set for devices
111           which are bound to a driver at the time the event is generated.
112
113       SECLABEL{module}
114           Applies the specified Linux Security Module label to the device
115           node. Note that at this time only selinux is supported.
116
117       ATTR{filename}
118           Match sysfs attribute values of the event device. Trailing
119           whitespace in the attribute values is ignored, if the specified
120           match value does not contain trailing whitespace itself.
121
122       KERNELS
123           Search the devpath upwards for a matching device name.
124
125       SUBSYSTEMS
126           Search the devpath upwards for a matching device subsystem name.
127
128       DRIVERS
129           Search the devpath upwards for a matching device driver name.
130
131       ATTRS{filename}
132           Search the devpath upwards for a device with matching sysfs
133           attribute values. If multiple ATTRS matches are specified, all of
134           them must match on the same device. Trailing whitespace in the
135           attribute values is ignored, if the specified match value does not
136           contain trailing whitespace itself.
137
138       ENV{key}
139           Match against a device property value.
140
141       TEST{octal mode mask}
142           Test the existence of a file. An octal mode mask can be specified
143           if needed.
144
145       PROGRAM
146           Execute a program. The key is true, if the program returns
147           successfully. The device properties are made available to the
148           executed program in the environment. The program´s output printed
149           to stdout, is available in the RESULT key.
150
151       RESULT
152           Match the returned string of the last PROGRAM call. This key can be
153           used in the same or in any later rule after a PROGRAM call.
154
155       Most of the fields support a shell style pattern matching. The
156       following pattern characters are supported:
157
158       *
159           Matches zero, or any number of characters.
160
161       ?
162           Matches any single character.
163
164       []
165           Matches any single character specified within the brackets. For
166           example, the pattern string ´tty[SR]´ would match either ´ttyS´ or
167           ´ttyR´. Ranges are also supported within this match with the ´-´
168           character. For example, to match on the range of all digits, the
169           pattern [0-9] would be used. If the first character following the
170           ´[´ is a ´!´, any characters not enclosed are matched.
171
172       The following keys can get values assigned:
173
174       NAME
175           The name of the node to be created, or the name the network
176           interface should be renamed to.
177
178       SYMLINK
179           The name of a symlink targeting the node. Every matching rule adds
180           this value to the list of symlinks to be created.
181
182           The set of characters to name a symlink is limited. Allowed
183           characters are [0-9A-Za-z#+-.:=@_/], valid utf8 character
184           sequences, and "\x00" hex encoding. All other characters are
185           replaced by a _ character.
186
187           Multiple symlinks may be specified by separating the names by the
188           space character. In case multiple devices claim the same name, the
189           link always points to the device with the highest link_priority. If
190           the current device goes away, the links are re-evaluated and the
191           device with the next highest link_priority becomes the owner of the
192           link. If no link_priority is specified, the order of the devices
193           (and which one of them owns the link) is undefined.
194
195           Symlink names must never conflict with the kernels default device
196           node names, as that would result in unpredictable behavior.
197
198       OWNER, GROUP, MODE
199           The permissions for the device node. Every specified value
200           overwrites the compiled-in default value.
201
202       ATTR{key}
203           The value that should be written to a sysfs attribute of the event
204           device.
205
206       ENV{key}
207           Set a device property value. Property names with a leading ´.´ are
208           not stored in the database or exported to external tool or events.
209
210       RUN
211           Add a program to the list of programs to be executed for a specific
212           device. This can only be used for very short running tasks. Running
213           an event process for a long period of time may block all further
214           events for this or a dependent device. Long running tasks need to
215           be immediately detached from the event process itself. If the
216           option RUN{fail_event_on_error} is specified, and the executed
217           program returns non-zero, the event will be marked as failed for a
218           possible later handling.
219
220           If the specified string starts with socket:path, all current event
221           values will be passed to the specified socket, as a message in the
222           same format the kernel sends an uevent. If the first character of
223           the specified path is an @ character, an abstract namespace socket
224           is used, instead of an existing socket file.
225
226       LABEL
227           Named label where a GOTO can jump to.
228
229       GOTO
230           Jumps to the next LABEL with a matching name
231
232       IMPORT{type}
233           Import a set of variables as device properties, depending on type:
234
235           program
236               Execute an external program specified as the assigned value and
237               import its output, which must be in environment key format.
238
239           file
240               Import a text file specified as the assigned value, which must
241               be in environment key format.
242
243           db
244               Import a single property specified as the assigned value from
245               the current device database. This works only if the database is
246               already populated by an earlier event.
247
248           cmdline
249               Import a single property from the kernel commandline. For
250               simple flags the value of the property will be set to ´1´.
251
252           parent
253               Import the stored keys from the parent device by reading the
254               database entry of the parent device. The value assigned to
255               IMPORT{parent} is used as a filter of key names to import (with
256               the same shell-style pattern matching used for comparisons).
257
258           If no option is given, udev will choose between program and file
259           based on the executable bit of the file permissions.
260
261       WAIT_FOR
262           Wait for a file to become available.
263
264       OPTIONS
265           Rule and device options:
266
267           ignore_device
268               Ignore this event completely.
269
270           ignore_remove
271               Do not remove the device node when the device goes away. This
272               may be useful as a workaround for broken device drivers.
273
274           link_priority=value
275               Specify the priority of the created symlinks. Devices with
276               higher priorities overwrite existing symlinks of other devices.
277               The default is 0.
278
279           all_partitions
280               Create the device nodes for all available partitions of a block
281               device. This may be useful for removable media devices where
282               media changes are not detected.
283
284           event_timeout=
285               Number of seconds an event will wait for operations to finish,
286               before it will terminate itself.
287
288           string_escape=none|replace
289               Usually control and other possibly unsafe characters are
290               replaced in strings used for device naming. The mode of
291               replacement can be specified with this option.
292
293           watch
294               Watch the device node with inotify, when closed after being
295               opened for writing, a change uevent will be synthesised.
296
297           nowatch
298               Disable the watching of a device node with inotify.
299
300       The NAME, SYMLINK, PROGRAM, OWNER, GROUP, MODE and RUN fields support
301       simple printf-like string substitutions. The RUN format chars gets
302       applied after all rules have been processed, right before the program
303       is executed. It allows the use of device properties set by earlier
304       matching rules. For all other fields, substitutions are applied while
305       the individual rule is being processed. The available substitutions
306       are:
307
308       $kernel, %k
309           The kernel name for this device.
310
311       $number, %n
312           The kernel number for this device. For example, ´sda3´ has kernel
313           number of ´3´
314
315       $devpath, %p
316           The devpath of the device.
317
318       $id, %b
319           The name of the device matched while searching the devpath upwards
320           for SUBSYSTEMS, KERNELS, DRIVERS and ATTRS.
321
322       $driver
323           The driver name of the device matched while searching the devpath
324           upwards for SUBSYSTEMS, KERNELS, DRIVERS and ATTRS.
325
326       $attr{file}, %s{file}
327           The value of a sysfs attribute found at the device, where all keys
328           of the rule have matched. If the matching device does not have such
329           an attribute, follow the chain of parent devices and use the value
330           of the first attribute that matches. If the attribute is a symlink,
331           the last element of the symlink target is returned as the value.
332
333       $env{key}, %E{key}
334           A device property value.
335
336       $major, %M
337           The kernel major number for the device.
338
339       $minor, %m
340           The kernel minor number for the device.
341
342       $result, %c
343           The string returned by the external program requested with PROGRAM.
344           A single part of the string, separated by a space character may be
345           selected by specifying the part number as an attribute: %c{N}. If
346           the number is followed by the ´+´ char this part plus all remaining
347           parts of the result string are substituted: %c{N+}
348
349       $parent, %P
350           The node name of the parent device.
351
352       $name
353           The current name of the device node. If not changed by a rule, it
354           is the name of the kernel device.
355
356       $links
357           The current list of symlinks, separated by a space character. The
358           value is only set if an earlier rule assigned a value, or during a
359           remove events.
360
361       $root, %r
362           The udev_root value.
363
364       $sys, %S
365           The sysfs mount point.
366
367       $tempnode, %N
368           The name of a created temporary device node to provide access to
369           the device from a external program before the real node is created.
370
371       %%
372           The ´%´ character itself.
373
374       $$
375           The ´$´ character itself.
376

AUTHOR

378       Written by Greg Kroah-Hartman greg@kroah.com and Kay Sievers
379       kay.sievers@vrfy.org. With much help from Dan Stekloff and many others.
380

SEE ALSO

382       udevd(8), udevadm(8)
383
384
385
386udev                              09/06/2016                           UDEV(7)
Impressum