]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/udev.xml
man: grammar and wording improvements
[thirdparty/systemd.git] / man / udev.xml
1 <?xml version='1.0'?>
2 <?xml-stylesheet type="text/xsl" href="http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl"?>
3 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
4 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
5
6 <refentry id="udev">
7 <refentryinfo>
8 <title>udev</title>
9 <productname>systemd</productname>
10 <authorgroup>
11 <author>
12 <contrib>Developer</contrib>
13 <firstname>Greg</firstname>
14 <surname>Kroah-Hartmann</surname>
15 <email>greg@kroah.com</email>
16 </author>
17 <author>
18 <contrib>Developer</contrib>
19 <firstname>Kay</firstname>
20 <surname>Sievers</surname>
21 <email>kay@vrfy.org</email>
22 </author>
23 </authorgroup>
24 </refentryinfo>
25
26 <refmeta>
27 <refentrytitle>udev</refentrytitle>
28 <manvolnum>7</manvolnum>
29 </refmeta>
30
31 <refnamediv>
32 <refname>udev</refname>
33 <refpurpose>Dynamic device management</refpurpose>
34 </refnamediv>
35
36 <refsect1><title>Description</title>
37 <para>udev supplies the system software with device events, manages permissions
38 of device nodes and may create additional symlinks in the <filename>/dev</filename>
39 directory, or renames network interfaces. The kernel usually just assigns unpredictable
40 device names based on the order of discovery. Meaningful symlinks or network device
41 names provide a way to reliably identify devices based on their properties or
42 current configuration.</para>
43
44 <para>The udev daemon, <citerefentry><refentrytitle>systemd-udevd.service</refentrytitle>
45 <manvolnum>8</manvolnum></citerefentry>, receives device uevents directly from
46 the kernel whenever a device is added or removed from the system, or it changes its
47 state. When udev receives a device event, it matches its configured set of rules
48 against various device attributes to identify the device. Rules that match may
49 provide additional device information to be stored in the udev database or
50 to be used to create meaningful symlink names.</para>
51
52 <para>All device information udev processes is stored in the udev database and
53 sent out to possible event subscribers. Access to all stored data and the event
54 sources is provided by the library libudev.</para>
55 </refsect1>
56
57 <refsect1><title>Rules Files</title>
58 <para>The udev rules are read from the files located in the
59 system rules directory <filename>/usr/lib/udev/rules.d</filename>,
60 the volatile runtime directory <filename>/run/udev/rules.d</filename>
61 and the local administration directory <filename>/etc/udev/rules.d</filename>.
62 All rules files are collectively sorted and processed in lexical order,
63 regardless of the directories in which they live. However, files with
64 identical filenames replace each other. Files in <filename>/etc</filename>
65 have the highest priority, files in <filename>/run</filename> take precedence
66 over files with the same name in <filename>/usr/lib</filename>. This can be
67 used to override a system-supplied rules file with a local file if needed;
68 a symlink in <filename>/etc</filename> with the same name as a rules file in
69 <filename>/usr/lib</filename>, pointing to <filename>/dev/null</filename>,
70 disables the rules file entirely. Rule files must have the extension
71 <filename>.rules</filename>; other extensions are ignored.</para>
72
73 <para>Every line in the rules file contains at least one key-value pair.
74 Except for empty lines or lines beginning with <literal>#</literal>, which are ignored.
75 There are two kinds of keys: match and assignment.
76 If all match keys match against their values, the rule gets applied and the
77 assignment keys get the specified values assigned.</para>
78
79 <para>A matching rule may rename a network interface, add symlinks
80 pointing to the device node, or run a specified program as part of
81 the event handling.</para>
82
83 <para>A rule consists of a comma-separated list of one or more key-value pairs.
84 Each key has a distinct operation, depending on the used operator. Valid
85 operators are:</para>
86 <variablelist>
87 <varlistentry>
88 <term><literal>==</literal></term>
89 <listitem>
90 <para>Compare for equality.</para>
91 </listitem>
92 </varlistentry>
93
94 <varlistentry>
95 <term><literal>!=</literal></term>
96 <listitem>
97 <para>Compare for inequality.</para>
98 </listitem>
99 </varlistentry>
100
101 <varlistentry>
102 <term><literal>=</literal></term>
103 <listitem>
104 <para>Assign a value to a key. Keys that represent a list are reset
105 and only this single value is assigned.</para>
106 </listitem>
107 </varlistentry>
108
109 <varlistentry>
110 <term><literal>+=</literal></term>
111 <listitem>
112 <para>Add the value to a key that holds a list of entries.</para>
113 </listitem>
114 </varlistentry>
115
116 <varlistentry>
117 <term><literal>:=</literal></term>
118 <listitem>
119 <para>Assign a value to a key finally; disallow any later changes.</para>
120 </listitem>
121 </varlistentry>
122 </variablelist>
123
124 <para>The following key names can be used to match against device properties.
125 Some of the keys also match against properties of the parent devices in sysfs,
126 not only the device that has generated the event. If multiple keys that match
127 a parent device are specified in a single rule, all these keys must match at
128 one and the same parent device.</para>
129 <variablelist class='udev-directives'>
130 <varlistentry>
131 <term><varname>ACTION</varname></term>
132 <listitem>
133 <para>Match the name of the event action.</para>
134 </listitem>
135 </varlistentry>
136
137 <varlistentry>
138 <term><varname>DEVPATH</varname></term>
139 <listitem>
140 <para>Match the devpath of the event device.</para>
141 </listitem>
142 </varlistentry>
143
144 <varlistentry>
145 <term><varname>KERNEL</varname></term>
146 <listitem>
147 <para>Match the name of the event device.</para>
148 </listitem>
149 </varlistentry>
150
151 <varlistentry>
152 <term><varname>NAME</varname></term>
153 <listitem>
154 <para>Match the name of a network interface. It can be used once the
155 NAME key has been set in one of the preceding rules.</para>
156 </listitem>
157 </varlistentry>
158
159 <varlistentry>
160 <term><varname>SYMLINK</varname></term>
161 <listitem>
162 <para>Match the name of a symlink targeting the node. It can
163 be used once a SYMLINK key has been set in one of the preceding
164 rules. There may be multiple symlinks; only one needs to match.
165 </para>
166 </listitem>
167 </varlistentry>
168
169 <varlistentry>
170 <term><varname>SUBSYSTEM</varname></term>
171 <listitem>
172 <para>Match the subsystem of the event device.</para>
173 </listitem>
174 </varlistentry>
175 <varlistentry>
176 <term><varname>DRIVER</varname></term>
177 <listitem>
178 <para>Match the driver name of the event device. Only set this key for devices
179 which are bound to a driver at the time the event is generated.</para>
180 </listitem>
181 </varlistentry>
182 <varlistentry>
183 <term><varname>ATTR{<replaceable>filename</replaceable>}</varname></term>
184 <listitem>
185 <para>Match sysfs attribute values of the event device. Trailing
186 whitespace in the attribute values is ignored unless the specified match
187 value itself contains trailing whitespace.
188 </para>
189 </listitem>
190 </varlistentry>
191
192 <varlistentry>
193 <term><varname>KERNELS</varname></term>
194 <listitem>
195 <para>Search the devpath upwards for a matching device name.</para>
196 </listitem>
197 </varlistentry>
198
199 <varlistentry>
200 <term><varname>SUBSYSTEMS</varname></term>
201 <listitem>
202 <para>Search the devpath upwards for a matching device subsystem name.</para>
203 </listitem>
204 </varlistentry>
205
206 <varlistentry>
207 <term><varname>DRIVERS</varname></term>
208 <listitem>
209 <para>Search the devpath upwards for a matching device driver name.</para>
210 </listitem>
211 </varlistentry>
212
213 <varlistentry>
214 <term><varname>ATTRS{<replaceable>filename</replaceable>}</varname></term>
215 <listitem>
216 <para>Search the devpath upwards for a device with matching sysfs attribute values.
217 If multiple <varname>ATTRS</varname> matches are specified, all of them
218 must match on the same device. Trailing whitespace in the attribute values is ignored
219 unless the specified match value itself contains trailing whitespace.</para>
220 </listitem>
221 </varlistentry>
222
223 <varlistentry>
224 <term><varname>TAGS</varname></term>
225 <listitem>
226 <para>Search the devpath upwards for a device with matching tag.</para>
227 </listitem>
228 </varlistentry>
229
230 <varlistentry>
231 <term><varname>ENV{<replaceable>key</replaceable>}</varname></term>
232 <listitem>
233 <para>Match against a device property value.</para>
234 </listitem>
235 </varlistentry>
236
237 <varlistentry>
238 <term><varname>TAG</varname></term>
239 <listitem>
240 <para>Match against a device tag.</para>
241 </listitem>
242 </varlistentry>
243
244 <varlistentry>
245 <term><varname>TEST{<replaceable>octal mode mask</replaceable>}</varname></term>
246 <listitem>
247 <para>Test the existence of a file. An octal mode mask can be specified
248 if needed.</para>
249 </listitem>
250 </varlistentry>
251
252 <varlistentry>
253 <term><varname>PROGRAM</varname></term>
254 <listitem>
255 <para>Execute a program to determine whether there
256 is a match; the key is true if the program returns
257 successfully. The device properties are made available to the
258 executed program in the environment. The program's stdout
259 is available in the RESULT key.</para>
260 <para>This can only be used for very short-running foreground tasks. For details
261 see <varname>RUN</varname>.</para>
262 </listitem>
263 </varlistentry>
264
265 <varlistentry>
266 <term><varname>RESULT</varname></term>
267 <listitem>
268 <para>Match the returned string of the last PROGRAM call. This key can
269 be used in the same or in any later rule after a PROGRAM call.</para>
270 </listitem>
271 </varlistentry>
272 </variablelist>
273
274 <para>Most of the fields support shell glob pattern matching. The following
275 pattern characters are supported:</para>
276 <variablelist>
277 <varlistentry>
278 <term><literal>*</literal></term>
279 <listitem>
280 <para>Matches zero or more characters.</para>
281 </listitem>
282 </varlistentry>
283 <varlistentry>
284 <term><literal>?</literal></term>
285 <listitem>
286 <para>Matches any single character.</para>
287 </listitem>
288 </varlistentry>
289 <varlistentry>
290 <term><literal>[]</literal></term>
291 <listitem>
292 <para>Matches any single character specified within the brackets. For
293 example, the pattern string <literal>tty[SR]</literal>
294 would match either <literal>ttyS</literal> or <literal>ttyR</literal>.
295 Ranges are also supported via the <literal>-</literal> character.
296 For example, to match on the range of all digits, the pattern [0-9] could
297 be used. If the first character following the <literal>[</literal> is a
298 <literal>!</literal>, any characters not enclosed are matched.</para>
299 </listitem>
300 </varlistentry>
301 </variablelist>
302
303 <para>The following keys can get values assigned:</para>
304 <variablelist class='udev-directives'>
305 <varlistentry>
306 <term><varname>NAME</varname></term>
307 <listitem>
308 <para>The name to use for a network interface. The name of a device node
309 cannot be changed by udev, only additional symlinks can be created.</para>
310 </listitem>
311 </varlistentry>
312
313 <varlistentry>
314 <term><varname>SYMLINK</varname></term>
315 <listitem>
316 <para>The name of a symlink targeting the node. Every matching rule adds
317 this value to the list of symlinks to be created.</para>
318 <para>The set of characters to name a symlink is limited. Allowed
319 characters are <literal>0-9A-Za-z#+-.:=@_/</literal>, valid UTF-8 character
320 sequences, and <literal>\x00</literal> hex encoding. All other
321 characters are replaced by a <literal>_</literal> character.</para>
322 <para>Multiple symlinks may be specified by separating the names by the
323 space character. In case multiple devices claim the same name, the link
324 always points to the device with the highest link_priority. If the current
325 device goes away, the links are re-evaluated and the device with the
326 next highest link_priority becomes the owner of the link. If no
327 link_priority is specified, the order of the devices (and which one of
328 them owns the link) is undefined.</para>
329 <para>Symlink names must never conflict with the kernel's default device
330 node names, as that would result in unpredictable behavior.
331 </para>
332 </listitem>
333 </varlistentry>
334
335 <varlistentry>
336 <term><varname>OWNER</varname>, <varname>GROUP</varname>, <varname>MODE</varname></term>
337 <listitem>
338 <para>The permissions for the device node. Every specified value overrides
339 the compiled-in default value.</para>
340 </listitem>
341 </varlistentry>
342
343 <varlistentry>
344 <term><varname>SECLABEL{<replaceable>module</replaceable>}</varname></term>
345 <listitem>
346 <para>Applies the specified Linux Security Module label to the device node.</para>
347 </listitem>
348 </varlistentry>
349
350 <varlistentry>
351 <term><varname>ATTR{<replaceable>key</replaceable>}</varname></term>
352 <listitem>
353 <para>The value that should be written to a sysfs attribute of the
354 event device.</para>
355 </listitem>
356 </varlistentry>
357
358 <varlistentry>
359 <term><varname>ENV{<replaceable>key</replaceable>}</varname></term>
360 <listitem>
361 <para>Set a device property value. Property names with a leading <literal>.</literal>
362 are neither stored in the database nor exported to events or
363 external tools (run by, say, the PROGRAM match key).</para>
364 </listitem>
365 </varlistentry>
366
367 <varlistentry>
368 <term><varname>TAG</varname></term>
369 <listitem>
370 <para>Attach a tag to a device. This is used to filter events for users
371 of libudev's monitor functionality, or to enumerate a group of tagged
372 devices. The implementation can only work efficiently if only a few
373 tags are attached to a device. It is only meant to be used in
374 contexts with specific device filter requirements, and not as a
375 general-purpose flag. Excessive use might result in inefficient event
376 handling.</para>
377 </listitem>
378 </varlistentry>
379
380 <varlistentry>
381 <term><varname>RUN{<replaceable>type</replaceable>}</varname></term>
382 <listitem>
383 <para>Add a program to the list of programs to be executed after processing all the
384 rules for a specific event, depending on <literal>type</literal>:</para>
385 <variablelist>
386 <varlistentry>
387 <term><literal>program</literal></term>
388 <listitem>
389 <para>Execute an external program specified as the assigned
390 value. If no absolute path is given, the program is expected to live in
391 /usr/lib/udev, otherwise the absolute path must be specified.</para>
392 <para>This is the default if no <replaceable>type</replaceable> is
393 specified.</para>
394 </listitem>
395 </varlistentry>
396 <varlistentry>
397 <term><literal>builtin</literal></term>
398 <listitem>
399 <para>As <varname>program</varname>, but use one of the built-in programs rather
400 than an external one.</para>
401 </listitem>
402 </varlistentry>
403 </variablelist>
404 <para>The program name and following arguments are separated by spaces.
405 Single quotes can be used to specify arguments with spaces.</para>
406 <para>This can only be used for very short-running foreground tasks. Running an
407 event process for a long period of time may block all further events for
408 this or a dependent device.</para>
409 <para>Starting daemons or other long running processes is not appropriate
410 for udev; the forked processes, detached or not, will be unconditionally
411 killed after the event handling has finished.</para>
412 </listitem>
413 </varlistentry>
414
415 <varlistentry>
416 <term><varname>LABEL</varname></term>
417 <listitem>
418 <para>A named label to which a GOTO may jump.</para>
419 </listitem>
420 </varlistentry>
421
422 <varlistentry>
423 <term><varname>GOTO</varname></term>
424 <listitem>
425 <para>Jumps to the next LABEL with a matching name.</para>
426 </listitem>
427 </varlistentry>
428
429 <varlistentry>
430 <term><varname>IMPORT{<replaceable>type</replaceable>}</varname></term>
431 <listitem>
432 <para>Import a set of variables as device properties,
433 depending on <literal>type</literal>:</para>
434 <variablelist>
435 <varlistentry>
436 <term><literal>program</literal></term>
437 <listitem>
438 <para>Execute an external program specified as the assigned value and
439 import its output, which must be in environment key
440 format. Path specification, command/argument separation,
441 and quoting work like in <varname>RUN</varname>.</para>
442 </listitem>
443 </varlistentry>
444 <varlistentry>
445 <term><literal>builtin</literal></term>
446 <listitem>
447 <para>Similar to <literal>program</literal>, but use one of the
448 built-in programs rather than an external one.</para>
449 </listitem>
450 </varlistentry>
451 <varlistentry>
452 <term><literal>file</literal></term>
453 <listitem>
454 <para>Import a text file specified as the assigned value, the content
455 of which must be in environment key format.</para>
456 </listitem>
457 </varlistentry>
458 <varlistentry>
459 <term><literal>db</literal></term>
460 <listitem>
461 <para>Import a single property specified as the assigned value from the
462 current device database. This works only if the database is already populated
463 by an earlier event.</para>
464 </listitem>
465 </varlistentry>
466 <varlistentry>
467 <term><literal>cmdline</literal></term>
468 <listitem>
469 <para>Import a single property from the kernel command line. For simple flags
470 the value of the property is set to <literal>1</literal>.</para>
471 </listitem>
472 </varlistentry>
473 <varlistentry>
474 <term><literal>parent</literal></term>
475 <listitem>
476 <para>Import the stored keys from the parent device by reading
477 the database entry of the parent device. The value assigned to
478 <option>IMPORT{parent}</option> is used as a filter of key names
479 to import (with the same shell glob pattern matching used for
480 comparisons).</para>
481 </listitem>
482 </varlistentry>
483 </variablelist>
484 <para>This can only be used for very short-running foreground tasks. For details
485 see <option>RUN</option>.</para>
486 </listitem>
487 </varlistentry>
488
489 <varlistentry>
490 <term><varname>WAIT_FOR</varname></term>
491 <listitem>
492 <para>Wait for a file to become available or until a timeout of
493 10 seconds expires. The path is relative to the sysfs device;
494 if no path is specified, this waits for an attribute to appear.</para>
495 </listitem>
496 </varlistentry>
497
498 <varlistentry>
499 <term><varname>OPTIONS</varname></term>
500 <listitem>
501 <para>Rule and device options:</para>
502 <variablelist class='udev-directives'>
503 <varlistentry>
504 <term><option>link_priority=<replaceable>value</replaceable></option></term>
505 <listitem>
506 <para>Specify the priority of the created symlinks. Devices with higher
507 priorities overwrite existing symlinks of other devices. The default is 0.</para>
508 </listitem>
509 </varlistentry>
510 <varlistentry>
511 <term><option>event_timeout=</option></term>
512 <listitem>
513 <para>Number of seconds an event waits for operations to finish before
514 giving up and terminating itself.</para>
515 </listitem>
516 </varlistentry>
517 <varlistentry>
518 <term><option>string_escape=<replaceable>none|replace</replaceable></option></term>
519 <listitem>
520 <para>Usually control and other possibly unsafe characters are replaced
521 in strings used for device naming. The mode of replacement can be specified
522 with this option.</para>
523 </listitem>
524 </varlistentry>
525 <varlistentry>
526 <term><option>static_node=</option></term>
527 <listitem>
528 <para>Apply the permissions specified in this rule to the static device node with
529 the specified name. Also, for every tag specified in this rule, create a symlink
530 in the directory
531 <filename>/run/udev/static_node-tags/<replaceable>tag</replaceable></filename>
532 pointing at the static device node with the specified name. Static device node
533 creation is performed by systemd-tmpfiles before systemd-udevd is started. The
534 static nodes might not have a corresponding kernel device; they are used to
535 trigger automatic kernel module loading when they are accessed.</para>
536 </listitem>
537 </varlistentry>
538 <varlistentry>
539 <term><option>watch</option></term>
540 <listitem>
541 <para>Watch the device node with inotify; when the node is closed after being opened for
542 writing, a change uevent is synthesized.</para>
543 </listitem>
544 </varlistentry>
545 <varlistentry>
546 <term><option>nowatch</option></term>
547 <listitem>
548 <para>Disable the watching of a device node with inotify.</para>
549 </listitem>
550 </varlistentry>
551 </variablelist>
552 </listitem>
553 </varlistentry>
554 </variablelist>
555
556 <para>The <varname>NAME</varname>, <varname>SYMLINK</varname>, <varname>PROGRAM</varname>,
557 <varname>OWNER</varname>, <varname>GROUP</varname>, <varname>MODE</varname> and <varname>RUN</varname>
558 fields support simple string substitutions. The <varname>RUN</varname>
559 substitutions are performed after all rules have been processed, right before the program
560 is executed, allowing for the use of device properties set by earlier matching
561 rules. For all other fields, substitutions are performed while the individual rule is
562 being processed. The available substitutions are:</para>
563 <variablelist class='udev-directives'>
564 <varlistentry>
565 <term><option>$kernel</option>, <option>%k</option></term>
566 <listitem>
567 <para>The kernel name for this device.</para>
568 </listitem>
569 </varlistentry>
570
571 <varlistentry>
572 <term><option>$number</option>, <option>%n</option></term>
573 <listitem>
574 <para>The kernel number for this device. For example,
575 <literal>sda3</literal> has kernel number <literal>3</literal>.</para>
576 </listitem>
577 </varlistentry>
578
579 <varlistentry>
580 <term><option>$devpath</option>, <option>%p</option></term>
581 <listitem>
582 <para>The devpath of the device.</para>
583 </listitem>
584 </varlistentry>
585
586 <varlistentry>
587 <term><option>$id</option>, <option>%b</option></term>
588 <listitem>
589 <para>The name of the device matched while searching the devpath upwards for
590 <option>SUBSYSTEMS</option>, <option>KERNELS</option>, <option>DRIVERS</option> and <option>ATTRS</option>.
591 </para>
592 </listitem>
593 </varlistentry>
594
595 <varlistentry>
596 <term><option>$driver</option></term>
597 <listitem>
598 <para>The driver name of the device matched while searching the devpath upwards for
599 <option>SUBSYSTEMS</option>, <option>KERNELS</option>, <option>DRIVERS</option> and <option>ATTRS</option>.
600 </para>
601 </listitem>
602 </varlistentry>
603
604 <varlistentry>
605 <term><option>$attr{<replaceable>file</replaceable>}</option>, <option>%s{<replaceable>file</replaceable>}</option></term>
606 <listitem>
607 <para>The value of a sysfs attribute found at the device where
608 all keys of the rule have matched. If the matching device does not have
609 such an attribute, and a previous KERNELS, SUBSYSTEMS, DRIVERS, or
610 ATTRS test selected a parent device, then the attribute from that
611 parent device is used.</para>
612 <para>If the attribute is a symlink, the last element of the symlink target is
613 returned as the value.</para>
614 </listitem>
615 </varlistentry>
616
617 <varlistentry>
618 <term><option>$env{<replaceable>key</replaceable>}</option>, <option>%E{<replaceable>key</replaceable>}</option></term>
619 <listitem>
620 <para>A device property value.</para>
621 </listitem>
622 </varlistentry>
623
624 <varlistentry>
625 <term><option>$major</option>, <option>%M</option></term>
626 <listitem>
627 <para>The kernel major number for the device.</para>
628 </listitem>
629 </varlistentry>
630
631 <varlistentry>
632 <term><option>$minor</option>, <option>%m</option></term>
633 <listitem>
634 <para>The kernel minor number for the device.</para>
635 </listitem>
636 </varlistentry>
637
638 <varlistentry>
639 <term><option>$result</option>, <option>%c</option></term>
640 <listitem>
641 <para>The string returned by the external program requested with PROGRAM.
642 A single part of the string, separated by a space character, may be selected
643 by specifying the part number as an attribute: <literal>%c{N}</literal>.
644 If the number is followed by the <literal>+</literal> character, this part plus all remaining parts
645 of the result string are substituted: <literal>%c{N+}</literal>.</para>
646 </listitem>
647 </varlistentry>
648
649 <varlistentry>
650 <term><option>$parent</option>, <option>%P</option></term>
651 <listitem>
652 <para>The node name of the parent device.</para>
653 </listitem>
654 </varlistentry>
655
656 <varlistentry>
657 <term><option>$name</option></term>
658 <listitem>
659 <para>The current name of the device. If not changed by a rule, it is the
660 name of the kernel device.</para>
661 </listitem>
662 </varlistentry>
663
664 <varlistentry>
665 <term><option>$links</option></term>
666 <listitem>
667 <para>A space-separated list of the current symlinks. The value is
668 only set during a remove event or if an earlier rule assigned a value.</para>
669 </listitem>
670 </varlistentry>
671
672 <varlistentry>
673 <term><option>$root</option>, <option>%r</option></term>
674 <listitem>
675 <para>The udev_root value.</para>
676 </listitem>
677 </varlistentry>
678
679 <varlistentry>
680 <term><option>$sys</option>, <option>%S</option></term>
681 <listitem>
682 <para>The sysfs mount point.</para>
683 </listitem>
684 </varlistentry>
685
686 <varlistentry>
687 <term><option>$devnode</option>, <option>%N</option></term>
688 <listitem>
689 <para>The name of the device node.</para>
690 </listitem>
691 </varlistentry>
692
693 <varlistentry>
694 <term><option>%%</option></term>
695 <listitem>
696 <para>The <literal>%</literal> character itself.</para>
697 </listitem>
698 </varlistentry>
699
700 <varlistentry>
701 <term><option>$$</option></term>
702 <listitem>
703 <para>The <literal>$</literal> character itself.</para>
704 </listitem>
705 </varlistentry>
706 </variablelist>
707 </refsect1>
708
709 <refsect1><title>Hardware Database Files</title>
710 <para>The hwdb files are read from the files located in the
711 system hwdb directory <filename>/usr/lib/udev/hwdb.d</filename>,
712 the volatile runtime directory <filename>/run/udev/hwdb.d</filename>
713 and the local administration directory <filename>/etc/udev/hwdb.d</filename>.
714 All hwdb files are collectively sorted and processed in lexical order,
715 regardless of the directories in which they live. However, files with
716 identical filenames replace each other. Files in <filename>/etc</filename>
717 have the highest priority, files in <filename>/run</filename> take precedence
718 over files with the same name in <filename>/usr/lib</filename>. This can be
719 used to override a system-supplied hwdb file with a local file if needed;
720 a symlink in <filename>/etc</filename> with the same name as a hwdb file in
721 <filename>/usr/lib</filename>, pointing to <filename>/dev/null</filename>,
722 disables the hwdb file entirely. hwdb files must have the extension
723 <filename>.hwdb</filename>; other extensions are ignored.</para>
724
725 <para>The hwdb file contains data records consisting of matches and
726 associated key-value pairs. Every record in the hwdb starts with one or
727 more match string, specifying a shell glob to compare the database
728 lookup string against. Multiple match lines are specified in additional
729 consecutive lines. Every match line is compared indivdually, they are
730 combined by OR. Every match line must start at the first character of
731 the line.</para>
732
733 <para>The match lines are followed by one or more key-value pair lines, which
734 are recognized by a leading space character. The key name and value are separated
735 by <literal>=</literal>. An empty line signifies the end
736 of a record. Lines beginning with <literal>#</literal> are ignored.</para>
737
738 <para>The content of all hwdb files is read by
739 <citerefentry><refentrytitle>udevadm</refentrytitle><manvolnum>8</manvolnum></citerefentry>
740 and compiled to a binary database located at <filename>/etc/udev/hwdb.bin</filename>.
741 During runtime only the binary database is used.</para>
742 </refsect1>
743
744 <refsect1><title>Network Link Configuration</title>
745 <para>Network link configuration is performed by the <literal>net_setup_link</literal>
746 udev builtin.</para>
747
748 <para>The link files are read from the files located in the
749 system network directory <filename>/usr/lib/systemd/network</filename>,
750 the volatile runtime network directory <filename>/run/systemd/network</filename>
751 and the local administration network directory <filename>/etc/systemd/network</filename>.
752 Link files must have the extension <filename>.link</filename>; other extensions are ignored.
753 All link files are collectively sorted and processed in lexical order,
754 regardless of the directories in which they live. However, files with
755 identical filenames replace each other. Files in <filename>/etc</filename>
756 have the highest priority, files in <filename>/run</filename> take precedence
757 over files with the same name in <filename>/usr/lib</filename>. This can be
758 used to override a system-supplied link file with a local file if needed;
759 a symlink in <filename>/etc</filename> with the same name as a link file in
760 <filename>/usr/lib</filename>, pointing to <filename>/dev/null</filename>,
761 disables the link file entirely.</para>
762
763 <para>The link file contains a <literal>[Match]</literal> section, which
764 determines if a given link file may be applied to a given device; and a
765 <literal>[Link]</literal> section specifying how the device should be
766 configured. The first (in lexical order) of the link files that matches
767 a given device is applied.</para>
768
769 <para>A link file is said to match a device if each of the entries in the
770 <literal>[Match]</literal> section matches, or if the section is empty.
771 The following keys are accepted:</para>
772
773 <variablelist class='network-directives'>
774 <varlistentry>
775 <term><varname>MACAddress</varname></term>
776 <listitem>
777 <para>The hardware address.
778 </para>
779 </listitem>
780 </varlistentry>
781 <varlistentry>
782 <term><varname>Path</varname></term>
783 <listitem>
784 <para>The persistent path, as exposed by the udev property <literal>ID_PATH</literal>.</para>
785 </listitem>
786 </varlistentry>
787 <varlistentry>
788 <term><varname>Driver</varname></term>
789 <listitem>
790 <para>The driver currently bound to the device, as exposed by the udev property <literal>DRIVER</literal>.</para>
791 </listitem>
792 </varlistentry>
793 <varlistentry>
794 <term><varname>Type</varname></term>
795 <listitem>
796 <para>The device type, as exposed by the udev property <literal>DEVTYPE</literal>.</para>
797 </listitem>
798 </varlistentry>
799 </variablelist>
800
801 <para>The <literal>[Link]</literal> section accepts the following keys:</para>
802
803 <variablelist class='network-directives'>
804 <varlistentry>
805 <term><varname>Description</varname></term>
806 <listitem>
807 <para>A description of the device.</para>
808 </listitem>
809 </varlistentry>
810 <varlistentry>
811 <term><varname>Alias</varname></term>
812 <listitem>
813 <para>The <literal>ifalias</literal> is set to this value.</para>
814 </listitem>
815 </varlistentry>
816 <varlistentry>
817 <term><varname>MACAddressPolicy</varname></term>
818 <listitem>
819 <para>The policy by which the MAC address should be set. The available policies are:</para>
820 <variablelist>
821 <varlistentry>
822 <term><literal>persistent</literal></term>
823 <listitem>
824 <para>If the hardware has a persistent MAC address, as most hardware should, and this is used by
825 the kernel, nothing is done. Otherwise, a new MAC address is generated which is guaranteed to be
826 the same on every boot for the given machine and the given device, but which is otherwise random.
827 </para>
828 </listitem>
829 </varlistentry>
830 <varlistentry>
831 <term><literal>random</literal></term>
832 <listitem>
833 <para>If the kernel is using a random MAC address, nothing is done. Otherwise, a new address is
834 randomly generated each time the device appears, typically at boot.</para>
835 </listitem>
836 </varlistentry>
837 </variablelist>
838 </listitem>
839 </varlistentry>
840 <varlistentry>
841 <term><varname>MACAddress</varname></term>
842 <listitem>
843 <para>The MAC address to use, if no <literal>MACAddressPolicy</literal> is specified.</para>
844 </listitem>
845 </varlistentry>
846 <varlistentry>
847 <term><varname>NamePolicy</varname></term>
848 <listitem>
849 <para>An ordered, space-separated list of policies by which the interface name should be set.
850 <literal>NamePolicy</literal> may be disabeld by specifying <literal>net.ifnames=0</literal> on the
851 kernel commandline. Each of the policies may fail, and the first successfull one is used. The name
852 is not set directly, but exported to udev as the property <literal>ID_NET_NAME</literal>, which is
853 by default used by an udev rule to set <literal>NAME</literal>. The available policies are:</para>
854 <variablelist>
855 <varlistentry>
856 <term><literal>onboard</literal></term>
857 <listitem>
858 <para>The name is set based on information given by the firmware for on-board devices, as
859 exported by the udev property <literal>ID_NET_NAME_ONBOARD</literal>.</para>
860 </listitem>
861 </varlistentry>
862 <varlistentry>
863 <term><literal>slot</literal></term>
864 <listitem>
865 <para>The name is set based on information given by the firmware for hot-plug devices, as
866 exported by the udev property <literal>ID_NET_NAME_SLOT</literal>.</para>
867 </listitem>
868 </varlistentry>
869 <varlistentry>
870 <term><literal>path</literal></term>
871 <listitem>
872 <para>The name is set based on the device's physical location, as exported by the udev
873 property <literal>ID_NET_NAME_PATH</literal>.</para>
874 </listitem>
875 </varlistentry>
876 <varlistentry>
877 <term><literal>mac</literal></term>
878 <listitem>
879 <para>The name is set based on the device's persistent MAC address, as exported by the udev
880 property <literal>ID_NET_NAME_MAC</literal>.</para>
881 </listitem>
882 </varlistentry>
883 </variablelist>
884 </listitem>
885 </varlistentry>
886 <varlistentry>
887 <term><varname>Name</varname></term>
888 <listitem>
889 <para>The interface name to use in case all the policies specified in <literal>NamePolicy</literal>
890 fail, or in case <literal>NamePolicy</literal> is missing or disabled.</para>
891 </listitem>
892 </varlistentry>
893 <varlistentry>
894 <term><varname>MTU</varname></term>
895 <listitem>
896 <para>The MTU to set for the device.</para>
897 </listitem>
898 </varlistentry>
899 <varlistentry>
900 <term><varname>SpeedMBytes</varname></term>
901 <listitem>
902 <para>The speed to set for the device.</para>
903 </listitem>
904 </varlistentry>
905 <varlistentry>
906 <term><varname>Duplex</varname></term>
907 <listitem>
908 <para>The duplex mode to set for the device. The accepted values are <literal>half</literal> and
909 <literal>full</literal>.</para>
910 </listitem>
911 </varlistentry>
912 <varlistentry>
913 <term><varname>WakeOnLan</varname></term>
914 <listitem>
915 <para>The Wake-On-Lan policy to set for the device. The supported values are:</para>
916 <variablelist>
917 <varlistentry>
918 <term><literal>phy</literal></term>
919 <listitem>
920 <para>Wake on PHY activity.</para>
921 </listitem>
922 </varlistentry>
923 <varlistentry>
924 <term><literal>magic</literal></term>
925 <listitem>
926 <para>Wake on receipt of magic packet.</para>
927 </listitem>
928 </varlistentry>
929 <varlistentry>
930 <term><literal>off</literal></term>
931 <listitem>
932 <para>Never wake.</para>
933 </listitem>
934 </varlistentry>
935 </variablelist>
936 </listitem>
937 </varlistentry>
938 </variablelist>
939 </refsect1>
940
941 <refsect1>
942 <title>See Also</title>
943 <para><citerefentry>
944 <refentrytitle>systemd-udevd.service</refentrytitle><manvolnum>8</manvolnum>
945 </citerefentry>,
946 <citerefentry>
947 <refentrytitle>udevadm</refentrytitle><manvolnum>8</manvolnum>
948 </citerefentry></para>
949 </refsect1>
950 </refentry>