Debian Codegraph @

man/udevadm.xml

raw
1 <?xml version='1.0'?>
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
4 <!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
5
6 <refentry id="udevadm"
7 xmlns:xi="http://www.w3.org/2001/XInclude">
8
9 <refentryinfo>
10 <title>udevadm</title>
11 <productname>systemd</productname>
12 </refentryinfo>
13
14 <refmeta>
15 <refentrytitle>udevadm</refentrytitle>
16 <manvolnum>8</manvolnum>
17 </refmeta>
18
19 <refnamediv>
20 <refname>udevadm</refname><refpurpose>udev management tool</refpurpose>
21 </refnamediv>
22
23 <refsynopsisdiv>
24 <cmdsynopsis>
25 <command>udevadm</command>
26 <arg><option>--debug</option></arg>
27 <arg><option>--version</option></arg>
28 <arg><option>--help</option></arg>
29 </cmdsynopsis>
30 <cmdsynopsis>
31 <command>udevadm info</command>
32 <arg choice="opt" rep="repeat"><replaceable>options</replaceable></arg>
33 <arg choice="opt" rep="repeat"><replaceable>devpath</replaceable>|<replaceable>syspath</replaceable>|<replaceable>id</replaceable>|<replaceable>unit</replaceable></arg>
34 </cmdsynopsis>
35 <cmdsynopsis>
36 <command>udevadm trigger</command>
37 <arg choice="opt" rep="repeat"><replaceable>options</replaceable></arg>
38 <arg choice="opt" rep="repeat"><replaceable>devpath</replaceable>|<replaceable>syspath</replaceable>|<replaceable>id</replaceable>|<replaceable>unit</replaceable></arg>
39 </cmdsynopsis>
40 <cmdsynopsis>
41 <command>udevadm settle</command>
42 <arg choice="opt" rep="repeat"><replaceable>options</replaceable></arg>
43 </cmdsynopsis>
44 <cmdsynopsis>
45 <command>udevadm control</command>
46 <arg choice="plain" rep="repeat"><replaceable>options</replaceable></arg>
47 </cmdsynopsis>
48 <cmdsynopsis>
49 <command>udevadm monitor</command>
50 <arg choice="opt" rep="repeat"><replaceable>options</replaceable></arg>
51 </cmdsynopsis>
52 <cmdsynopsis>
53 <command>udevadm test</command>
54 <arg choice="opt" rep="repeat"><replaceable>options</replaceable></arg>
55 <arg choice="plain"><replaceable>devpath</replaceable>|<replaceable>syspath</replaceable>|<replaceable>id</replaceable>|<replaceable>unit</replaceable></arg>
56 </cmdsynopsis>
57 <cmdsynopsis>
58 <command>udevadm test-builtin</command>
59 <arg choice="opt" rep="repeat"><replaceable>options</replaceable></arg>
60 <arg choice="plain"><replaceable>command</replaceable></arg>
61 <arg choice="plain"><replaceable>devpath</replaceable>|<replaceable>syspath</replaceable>|<replaceable>id</replaceable>|<replaceable>unit</replaceable></arg>
62 </cmdsynopsis>
63 <cmdsynopsis>
64 <command>udevadm verify</command>
65 <arg choice="opt" rep="repeat"><replaceable>options</replaceable></arg>
66 <arg choice="opt" rep="repeat"><replaceable>files</replaceable></arg>
67 </cmdsynopsis>
68 <cmdsynopsis>
69 <command>udevadm cat</command>
70 <arg choice="opt" rep="repeat"><replaceable>options</replaceable></arg>
71 <arg choice="opt" rep="repeat"><replaceable>files</replaceable></arg>
72 </cmdsynopsis>
73 <cmdsynopsis>
74 <command>udevadm wait</command>
75 <arg choice="opt" rep="repeat"><replaceable>options</replaceable></arg>
76 <arg choice="plain" rep="repeat"><replaceable>devpath</replaceable>|<replaceable>syspath</replaceable></arg>
77 </cmdsynopsis>
78 <cmdsynopsis>
79 <command>udevadm lock</command>
80 <arg choice="opt" rep="repeat"><replaceable>options</replaceable></arg>
81 <arg choice="plain" rep="repeat"><replaceable>command</replaceable></arg>
82 </cmdsynopsis>
83 </refsynopsisdiv>
84
85 <refsect1>
86 <title>Description</title>
87 <para><command>udevadm</command> expects a command and command
88 specific options. It controls the runtime behavior of
89 <command>systemd-udevd</command>, requests kernel events, manages
90 the event queue, and provides simple debugging mechanisms.</para>
91 </refsect1>
92
93 <refsect1>
94 <title>Options</title>
95
96 <variablelist>
97 <varlistentry>
98 <term><option>-d</option></term>
99 <term><option>--debug</option></term>
100 <listitem>
101 <para>Print debug messages to standard error. This option is implied in <command>udevadm test</command> and
102 <command>udevadm test-builtin</command> commands.</para>
103 </listitem>
104 </varlistentry>
105
106 <varlistentry>
107 <term><option>-V</option></term>
108 <term><option>--version</option></term>
109 <xi:include href="standard-options.xml" xpointer="version-text" />
110 </varlistentry>
111
112 <xi:include href="standard-options.xml" xpointer="help" />
113 </variablelist>
114
115 <refsect2>
116 <title>udevadm info
117 <optional><replaceable>options</replaceable>…</optional>
118 <optional><replaceable>devpath</replaceable>|<replaceable>syspath</replaceable>|<replaceable>id</replaceable>|<replaceable>unit</replaceable>…</optional>
119 </title>
120
121 <para>Query the udev database for device information.</para>
122
123 <para>Positional arguments should be used to specify one or more devices. Each one may be a device name
124 (in which case it must start with <filename>/dev/</filename>), a sys path (in which case it must start
125 with <filename>/sys/</filename>), a device ID (such as <literal>n1</literal>, <literal>c5:1</literal>,
126 or <literal>b259:1</literal>, see
127 <citerefentry><refentrytitle>sd_device_get_device_id</refentrytitle><manvolnum>3</manvolnum></citerefentry>).
128 or a systemd device unit name (in which case it must end with <literal>.device</literal>, see
129 <citerefentry><refentrytitle>systemd.device</refentrytitle><manvolnum>5</manvolnum></citerefentry>).
130 </para>
131
132 <variablelist>
133 <varlistentry>
134 <term><option>-q</option></term>
135 <term><option>--query=<replaceable>TYPE</replaceable></option></term>
136 <listitem>
137 <para>Query the database for the specified type of device data.
138 Valid <replaceable>TYPE</replaceable>s are:
139 <constant>name</constant>, <constant>symlink</constant>,
140 <constant>path</constant>, <constant>property</constant>,
141 <constant>all</constant>.</para>
142 </listitem>
143 </varlistentry>
144
145 <varlistentry>
146 <term><option>--property=<replaceable>NAME</replaceable></option></term>
147 <listitem>
148 <para>When showing device properties using the <option>--query=property</option>
149 option, limit display to properties specified in the argument. The argument should
150 be a comma-separated list of property names. If not specified, all known properties
151 are shown.</para>
152
153 <xi:include href="version-info.xml" xpointer="v250"/>
154 </listitem>
155 </varlistentry>
156 <varlistentry>
157 <term><option>--value</option></term>
158 <listitem>
159 <para>When showing device properties using the <option>--query=property</option>
160 option, print only their values, and skip the property name and <literal>=</literal>.</para>
161 <para>Cannot be used together with <option>-x/--export</option> or
162 <option>-P/--export-prefix</option>.</para>
163
164 <xi:include href="version-info.xml" xpointer="v250"/>
165 </listitem>
166 </varlistentry>
167 <varlistentry>
168 <term><option>-p</option></term>
169 <term><option>--path=<replaceable>DEVPATH</replaceable></option></term>
170 <listitem>
171 <para>The <filename>/sys/</filename> path of the device to query, e.g.
172 <filename><optional>/sys/</optional>/class/block/sda</filename>. This option is an alternative to
173 the positional argument with a <filename>/sys/</filename> prefix. <command>udevadm info
174 --path=/class/block/sda</command> is equivalent to <command>udevadm info
175 /sys/class/block/sda</command>.</para>
176 </listitem>
177 </varlistentry>
178 <varlistentry>
179 <term><option>-n</option></term>
180 <term><option>--name=<replaceable>FILE</replaceable></option></term>
181 <listitem>
182 <para>The name of the device node or a symlink to query,
183 e.g. <filename><optional>/dev/</optional>/sda</filename>. This option is an alternative to the
184 positional argument with a <filename>/dev/</filename> prefix. <command>udevadm info
185 --name=sda</command> is equivalent to <command>udevadm info /dev/sda</command>.</para>
186 </listitem>
187 </varlistentry>
188 <varlistentry>
189 <term><option>-r</option></term>
190 <term><option>--root</option></term>
191 <listitem>
192 <para>Print absolute paths in <command>name</command> or <command>symlink</command>
193 query.</para>
194 </listitem>
195 </varlistentry>
196 <varlistentry>
197 <term><option>-a</option></term>
198 <term><option>--attribute-walk</option></term>
199 <listitem>
200 <para>Print all sysfs properties of the specified device that can be used
201 in udev rules to match the specified device. It prints all devices
202 along the chain, up to the root of sysfs that can be used in udev rules.</para>
203
204 <para>This switch supports JSON output mode (see <option>--json=</option> below). Note that
205 because this switch generates multiple JSON objects, JSON-SEQ mode is automatically enabled
206 (RFC7464). (Note: tools such as <ulink url="https://jqlang.github.io/jq/manual/">jq</ulink>
207 natively support JSON-SEQ via the <option>--seq</option> switch.)</para>
208 </listitem>
209 </varlistentry>
210 <varlistentry>
211 <term><option>-t</option></term>
212 <term><option>--tree</option></term>
213 <listitem>
214 <para>Display a sysfs tree. This recursively iterates through the sysfs hierarchy and displays it
215 in a tree structure. If a path is specified only the subtree below and its parent directories are
216 shown. This will show both device and subsystem items.</para>
217
218 <xi:include href="version-info.xml" xpointer="v251"/>
219 </listitem>
220 </varlistentry>
221 <varlistentry>
222 <term><option>-x</option></term>
223 <term><option>--export</option></term>
224 <listitem>
225 <para>Print output as key/value pairs. Values are enclosed in single quotes.
226 This takes effects only when <option>--query=property</option> or
227 <option>--device-id-of-file=<replaceable>FILE</replaceable></option> is specified.</para>
228 </listitem>
229 </varlistentry>
230 <varlistentry>
231 <term><option>-P</option></term>
232 <term><option>--export-prefix=<replaceable>NAME</replaceable></option></term>
233 <listitem>
234 <para>Add a prefix to the key name of exported values.
235 This implies <option>--export</option>.</para>
236 </listitem>
237 </varlistentry>
238 <varlistentry>
239 <term><option>-d</option></term>
240 <term><option>--device-id-of-file=<replaceable>FILE</replaceable></option></term>
241 <listitem>
242 <para>Print major/minor numbers of the underlying device, where the file lives on.
243 If this is specified, all positional arguments are ignored.</para>
244 </listitem>
245 </varlistentry>
246 <varlistentry>
247 <term><option>-e</option></term>
248 <term><option>--export-db</option></term>
249 <listitem>
250 <para>Export the content of the udev database.</para>
251 </listitem>
252 </varlistentry>
253 <varlistentry>
254 <term><option>-c</option></term>
255 <term><option>--cleanup-db</option></term>
256 <listitem>
257 <para>Cleanup the udev database.</para>
258 </listitem>
259 </varlistentry>
260 <varlistentry>
261 <term><option>-w<optional>SECONDS</optional></option></term>
262 <term><option>--wait-for-initialization<optional>=SECONDS</optional></option></term>
263 <listitem>
264 <para>Wait for device to be initialized. If argument <replaceable>SECONDS</replaceable>
265 is not specified, the default is to wait forever.</para>
266
267 <xi:include href="version-info.xml" xpointer="v243"/>
268 </listitem>
269 </varlistentry>
270 <varlistentry>
271 <term><option>--subsystem-match<optional>=SUBSYSTEM</optional></option></term>
272 <term><option>--subsystem-nomatch<optional>=SUBSYSTEM</optional></option></term>
273 <listitem>
274 <para>When used with <option>--export-db</option>, only show devices of or not of the given
275 subsystem respectively.</para>
276
277 <xi:include href="version-info.xml" xpointer="v255"/>
278 </listitem>
279 </varlistentry>
280 <varlistentry>
281 <term><option>--attr-match<optional>=FILE[=VALUE]</optional></option></term>
282 <term><option>--attr-nomatch<optional>=FILE[=VALUE]</optional></option></term>
283 <listitem>
284 <para>When used with <option>--export-db</option>, only show devices matching or not matching the
285 given attribute respectively.</para>
286
287 <xi:include href="version-info.xml" xpointer="v255"/>
288 </listitem>
289 </varlistentry>
290 <varlistentry>
291 <term><option>--property-match<optional>=KEY=VALUE</optional></option></term>
292 <listitem>
293 <para>When used with <option>--export-db</option>, only show devices matching the given property
294 and value.</para>
295
296 <xi:include href="version-info.xml" xpointer="v255"/>
297 </listitem>
298 </varlistentry>
299 <varlistentry>
300 <term><option>--tag-match<optional>=TAG</optional></option></term>
301 <listitem>
302 <para>When used with <option>--export-db</option>, only show devices with the given tag.</para>
303
304 <xi:include href="version-info.xml" xpointer="v255"/>
305 </listitem>
306 </varlistentry>
307 <varlistentry>
308 <term><option>--sysname-match<optional>=NAME</optional></option></term>
309 <listitem>
310 <para>When used with <option>--export-db</option>, only show devices with the given
311 <literal>/sys</literal> path.</para>
312
313 <xi:include href="version-info.xml" xpointer="v255"/>
314 </listitem>
315 </varlistentry>
316 <varlistentry>
317 <term><option>--name-match<optional>=NAME</optional></option></term>
318 <listitem>
319 <para>When used with <option>--export-db</option>, only show devices with the given name in
320 <literal>/dev</literal>.</para>
321
322 <xi:include href="version-info.xml" xpointer="v255"/>
323 </listitem>
324 </varlistentry>
325 <varlistentry>
326 <term><option>--parent-match<optional>=NAME</optional></option></term>
327 <listitem>
328 <para>When used with <option>--export-db</option>, only show devices with the given parent
329 device.</para>
330
331 <xi:include href="version-info.xml" xpointer="v255"/>
332 </listitem>
333 </varlistentry>
334 <varlistentry>
335 <term><option>--initialized-match</option></term>
336 <term><option>--initialized-nomatch</option></term>
337 <listitem>
338 <para>When used with <option>--export-db</option>, only show devices that are initialized or not
339 initialized respectively.</para>
340
341 <xi:include href="version-info.xml" xpointer="v255"/>
342 </listitem>
343 </varlistentry>
344
345 <xi:include href="standard-options.xml" xpointer="json" />
346 <xi:include href="standard-options.xml" xpointer="no-pager" />
347 </variablelist>
348
349 <para>The generated output shows the current device database entry in a terse format. Each line shown
350 is prefixed with one of the following characters:</para>
351
352 <table>
353 <title><command>udevadm info</command> output prefixes</title>
354 <tgroup cols='2' align='left' colsep='1' rowsep='1'>
355 <colspec colname="prefix" />
356 <colspec colname="meaning" />
357 <thead>
358 <row>
359 <entry>Prefix</entry>
360 <entry>Meaning</entry>
361 </row>
362 </thead>
363 <tbody>
364 <row>
365 <entry><literal>P:</literal></entry>
366 <entry>Device path in <filename>/sys/</filename></entry>
367 </row>
368 <row>
369 <entry><literal>M:</literal></entry>
370 <entry>Device name in <filename>/sys/</filename> (i.e. the last component of <literal>P:</literal>)</entry>
371 </row>
372 <row>
373 <entry><literal>R:</literal></entry>
374 <entry>Device number in <filename>/sys/</filename> (i.e. the numeric suffix of the last component of <literal>P:</literal>)</entry>
375 </row>
376 <row>
377 <entry><literal>J:</literal></entry>
378 <entry>Device ID</entry>
379 </row>
380 <row>
381 <entry><literal>U:</literal></entry>
382 <entry>Kernel subsystem</entry>
383 </row>
384 <row>
385 <entry><literal>B:</literal></entry>
386 <entry>Driver subsystem</entry>
387 </row>
388 <row>
389 <entry><literal>T:</literal></entry>
390 <entry>Kernel device type within subsystem</entry>
391 </row>
392 <row>
393 <entry><literal>D:</literal></entry>
394 <entry>Kernel device node major/minor</entry>
395 </row>
396 <row>
397 <entry><literal>I:</literal></entry>
398 <entry>Network interface index</entry>
399 </row>
400 <row>
401 <entry><literal>N:</literal></entry>
402 <entry>Kernel device node name</entry>
403 </row>
404 <row>
405 <entry><literal>L:</literal></entry>
406 <entry>Device node symlink priority</entry>
407 </row>
408 <row>
409 <entry><literal>S:</literal></entry>
410 <entry>Device node symlink</entry>
411 </row>
412 <row>
413 <entry><literal>Q:</literal></entry>
414 <entry>Block device sequence number (DISKSEQ)</entry>
415 </row>
416 <row>
417 <entry><literal>V:</literal></entry>
418 <entry>Attached driver</entry>
419 </row>
420 <row>
421 <entry><literal>E:</literal></entry>
422 <entry>Device property</entry>
423 </row>
424 </tbody>
425 </tgroup>
426 </table>
427 </refsect2>
428
429 <refsect2>
430 <title>udevadm trigger
431 <optional><replaceable>options</replaceable>…</optional>
432 <optional><replaceable>devpath</replaceable>|<replaceable>syspath</replaceable>|<replaceable>id</replaceable>|<replaceable>unit</replaceable>…</optional>
433 </title>
434
435 <para>Request device events from the kernel. Primarily used to replay events at system coldplug time.</para>
436
437 <para>Takes device specifications as positional arguments. See the description of
438 <command>udevadm info</command> above.</para>
439
440 <variablelist>
441 <varlistentry>
442 <term><option>-v</option></term>
443 <term><option>--verbose</option></term>
444 <listitem>
445 <para>Print the list of devices which will be triggered.</para>
446 </listitem>
447 </varlistentry>
448 <varlistentry>
449 <term><option>-n</option></term>
450 <term><option>--dry-run</option></term>
451 <listitem>
452 <para>Do not actually trigger the event.</para>
453 </listitem>
454 </varlistentry>
455 <varlistentry>
456 <term><option>-q</option></term>
457 <term><option>--quiet</option></term>
458 <listitem>
459 <para>Suppress error logging in triggering events.</para>
460
461 <xi:include href="version-info.xml" xpointer="v248"/>
462 </listitem>
463 </varlistentry>
464 <varlistentry>
465 <term><option>-t</option></term>
466 <term><option>--type=<replaceable>TYPE</replaceable></option></term>
467 <listitem>
468 <para>Trigger a specific type of devices. Valid types are <literal>all</literal>,
469 <literal>devices</literal>, and <literal>subsystems</literal>. The default value is
470 <literal>devices</literal>.</para>
471 </listitem>
472 </varlistentry>
473 <varlistentry>
474 <term><option>-c</option></term>
475 <term><option>--action=<replaceable>ACTION</replaceable></option></term>
476 <listitem>
477 <para>Type of event to be triggered. Possible actions are <literal>add</literal>,
478 <literal>remove</literal>, <literal>change</literal>, <literal>move</literal>,
479 <literal>online</literal>, <literal>offline</literal>, <literal>bind</literal>,
480 and <literal>unbind</literal>. Also, the special value <literal>help</literal> can be used
481 to list the possible actions. The default value is <literal>change</literal>.
482 </para>
483 </listitem>
484 </varlistentry>
485 <varlistentry>
486 <term><option>--prioritized-subsystem=<replaceable>SUBSYSTEM<optional>,<replaceable>SUBSYSTEM</replaceable>…</optional></replaceable></option></term>
487 <listitem>
488 <para>Takes a comma separated list of subsystems. When triggering events for devices, the
489 devices from the specified subsystems and their parents are triggered first. For example,
490 if <option>--prioritized-subsystem=block,net</option>, then firstly all block devices and
491 their parents are triggered, in the next all network devices and their parents are
492 triggered, and lastly the other devices are triggered. This option can be specified
493 multiple times, and in that case the lists of the subsystems will be merged. That is,
494 <option>--prioritized-subsystem=block --prioritized-subsystem=net</option> is equivalent to
495 <option>--prioritized-subsystem=block,net</option>.</para>
496
497 <xi:include href="version-info.xml" xpointer="v251"/>
498 </listitem>
499 </varlistentry>
500 <varlistentry>
501 <term><option>-s</option></term>
502 <term><option>--subsystem-match=<replaceable>SUBSYSTEM</replaceable></option></term>
503 <listitem>
504 <para>Trigger events for devices which belong to a
505 matching subsystem. This option supports shell style pattern matching.
506 When this option is specified more than once, then each matching result is ORed, that is,
507 all the devices in each subsystem are triggered.</para>
508 </listitem>
509 </varlistentry>
510 <varlistentry>
511 <term><option>-S</option></term>
512 <term><option>--subsystem-nomatch=<replaceable>SUBSYSTEM</replaceable></option></term>
513 <listitem>
514 <para>Do not trigger events for devices which belong to a matching subsystem. This option
515 supports shell style pattern matching. When this option is specified more than once,
516 then each matching result is ANDed, that is, devices which do not match all specified
517 subsystems are triggered.</para>
518 </listitem>
519 </varlistentry>
520 <varlistentry>
521 <term><option>-a</option></term>
522 <term><option>--attr-match=<replaceable>ATTRIBUTE</replaceable>=<replaceable>VALUE</replaceable></option></term>
523 <listitem>
524 <para>Trigger events for devices with a matching sysfs attribute. If a value is specified along
525 with the attribute name, the content of the attribute is matched against the given value using
526 shell style pattern matching. If no value is specified, the existence of the sysfs attribute is
527 checked. When this option is specified multiple times, then each matching result is ANDed,
528 that is, only devices which have all specified attributes are triggered.</para>
529 </listitem>
530 </varlistentry>
531 <varlistentry>
532 <term><option>-A</option></term>
533 <term><option>--attr-nomatch=<replaceable>ATTRIBUTE</replaceable>=<replaceable>VALUE</replaceable></option></term>
534 <listitem>
535 <para>Do not trigger events for devices with a matching sysfs attribute. If a value is specified
536 along with the attribute name, the content of the attribute is matched against the given value
537 using shell style pattern matching. If no value is specified, the existence of the sysfs attribute
538 is checked. When this option is specified multiple times, then each matching result is ANDed,
539 that is, only devices which have none of the specified attributes are triggered.</para>
540 </listitem>
541 </varlistentry>
542 <varlistentry>
543 <term><option>-p</option></term>
544 <term><option>--property-match=<replaceable>PROPERTY</replaceable>=<replaceable>VALUE</replaceable></option></term>
545 <listitem>
546 <para>Trigger events for devices with a matching property value. This option supports shell style
547 pattern matching. When this option is specified more than once, then each matching result is ORed,
548 that is, devices which have one of the specified properties are triggered.</para>
549 </listitem>
550 </varlistentry>
551 <varlistentry>
552 <term><option>-g</option></term>
553 <term><option>--tag-match=<replaceable>TAG</replaceable></option></term>
554 <listitem>
555 <para>Trigger events for devices with a matching tag. When this option is specified multiple times,
556 then each matching result is ANDed, that is, devices which have all specified tags are triggered.</para>
557 </listitem>
558 </varlistentry>
559 <varlistentry>
560 <term><option>-y</option></term>
561 <term><option>--sysname-match=<replaceable>NAME</replaceable></option></term>
562 <listitem>
563 <para>Trigger events for devices for which the last component (i.e. the filename) of the
564 <filename>/sys/</filename> path matches the specified <replaceable>PATH</replaceable>. This option
565 supports shell style pattern matching. When this option is specified more than once, then each
566 matching result is ORed, that is, all devices which have any of the specified
567 <replaceable>NAME</replaceable> are triggered.</para>
568 </listitem>
569 </varlistentry>
570 <varlistentry>
571 <term><option>--name-match=<replaceable>NAME</replaceable></option></term>
572 <listitem>
573 <para>Trigger events for devices with a matching device path. When this option is specified more than once,
574 then each matching result is ORed, that is, all specified devices are triggered.</para>
575
576 <xi:include href="version-info.xml" xpointer="v218"/>
577 </listitem>
578 </varlistentry>
579 <varlistentry>
580 <term><option>-b</option></term>
581 <term><option>--parent-match=<replaceable>SYSPATH</replaceable></option></term>
582 <listitem>
583 <para>Trigger events for all children of a given device. When this option is specified more than once,
584 then each matching result is ORed, that is, all children of each specified device are triggered.</para>
585 </listitem>
586 </varlistentry>
587 <varlistentry>
588 <term><option>--initialized-match</option></term>
589 <term><option>--initialized-nomatch</option></term>
590 <listitem>
591 <para>When <option>--initialized-match</option> is specified, trigger events for devices
592 that are already initialized by <command>systemd-udevd</command>, and skip devices that
593 are not initialized yet.</para>
594 <para>When <option>--initialized-nomatch</option> is specified, trigger events for devices
595 that are not initialized by <command>systemd-udevd</command> yet, and skip devices that
596 are already initialized.</para>
597 <para>Typically, it is essential that applications which intend to use such a match, make
598 sure a suitable udev rule is installed that sets at least one property on devices that
599 shall be matched. See also Initialized Devices section below for more details.</para>
600 <warning>
601 <para><option>--initialized-nomatch</option> can potentially save a significant
602 amount of time compared to re-triggering all devices in the system and e.g. can be used to
603 optimize boot time. However, this is not safe to be used in a boot sequence in general.
604 Especially, when udev rules for a device depend on its parent devices (e.g.
605 <literal>ATTRS</literal> or <literal>IMPORT{parent}</literal> keys, see
606 <citerefentry><refentrytitle>udev</refentrytitle><manvolnum>7</manvolnum></citerefentry>
607 for more details), the final state of the device becomes easily unstable with this option.
608 </para>
609 </warning>
610
611 <xi:include href="version-info.xml" xpointer="v251"/>
612 </listitem>
613 </varlistentry>
614 <varlistentry>
615 <term><option>--include-parents</option></term>
616 <listitem>
617 <para>Trigger parent devices of found devices even if the parents
618 will not match the filter condition.
619 This is useful if we are interested to limit the coldplug activities to
620 some devices or subsystems.</para>
621
622 <xi:include href="version-info.xml" xpointer="v258"/>
623 </listitem>
624 </varlistentry>
625 <varlistentry>
626 <term><option>-w</option></term>
627 <term><option>--settle</option></term>
628 <listitem>
629 <para>Apart from triggering events, also waits for those events to
630 finish. Note that this is different from calling <command>udevadm
631 settle</command>. <command>udevadm settle</command> waits for all
632 events to finish. This option only waits for events triggered by
633 the same command to finish.</para>
634
635 <xi:include href="version-info.xml" xpointer="v238"/>
636 </listitem>
637 </varlistentry>
638 <varlistentry>
639 <term><option>--uuid</option></term>
640 <listitem>
641 <para>Trigger the synthetic device events, and associate a randomized UUID with each. These UUIDs
642 are printed to standard output, one line for each event. These UUIDs are included in the uevent
643 environment block (in the <literal>SYNTH_UUID=</literal> property) and may be used to track
644 delivery of the generated events.</para>
645
646 <xi:include href="version-info.xml" xpointer="v249"/>
647 </listitem>
648 </varlistentry>
649 <varlistentry>
650 <term><option>--wait-daemon[=<replaceable>SECONDS</replaceable>]</option></term>
651 <listitem>
652 <para>Before triggering uevents, wait for systemd-udevd daemon to be initialized.
653 Optionally takes timeout value. Default timeout is 5 seconds. This is equivalent to invoking
654 <command>udevadm control --ping</command> before <command>udevadm trigger</command>.</para>
655
656 <xi:include href="version-info.xml" xpointer="v241"/>
657 </listitem>
658 </varlistentry>
659 </variablelist>
660
661 <para>In addition, optional positional arguments can be used
662 to specify device names or sys paths. They must start with
663 <filename>/dev/</filename> or <filename>/sys/</filename>
664 respectively.</para>
665 </refsect2>
666
667 <refsect2>
668 <title>udevadm settle
669 <optional><replaceable>options</replaceable>…</optional>
670 </title>
671
672 <para>Watches the udev event queue, and exits if all current events are handled.</para>
673
674 <variablelist>
675 <varlistentry>
676 <term><option>-t</option></term>
677 <term><option>--timeout=<replaceable>SECONDS</replaceable></option></term>
678 <listitem>
679 <para>Maximum number of seconds to wait for the event
680 queue to become empty. The default value is 120 seconds. A
681 value of 0 will check if the queue is empty and always
682 return immediately. A non-zero value will return an exit
683 code of 0 if queue became empty before timeout was reached,
684 non-zero otherwise.</para>
685 </listitem>
686 </varlistentry>
687 <varlistentry>
688 <term><option>-E</option></term>
689 <term><option>--exit-if-exists=<replaceable>FILE</replaceable></option></term>
690 <listitem>
691 <para>Stop waiting if file exists.</para>
692 </listitem>
693 </varlistentry>
694 </variablelist>
695
696 <para>See
697 <citerefentry><refentrytitle>systemd-udev-settle.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
698 for more information.</para>
699 </refsect2>
700
701 <refsect2>
702 <title>udevadm control <replaceable>options</replaceable>…</title>
703
704 <para>Modify the internal state of the running udev daemon.</para>
705
706 <variablelist>
707 <varlistentry>
708 <term><option>-e</option></term>
709 <term><option>--exit</option></term>
710 <listitem>
711 <para>Signal and wait for systemd-udevd to exit. No option except for
712 <option>--timeout</option> can be specified after this option.
713 Note that <filename>systemd-udevd.service</filename> contains
714 <option>Restart=always</option> and so as a result, this option restarts systemd-udevd.
715 If you want to stop <filename>systemd-udevd.service</filename>, please use the following:
716 <programlisting>systemctl stop systemd-udevd-control.socket systemd-udevd-kernel.socket systemd-udevd-varlink.socket systemd-udevd.service</programlisting>
717 </para>
718 </listitem>
719 </varlistentry>
720 <varlistentry>
721 <term><option>-l</option></term>
722 <term><option>--log-level=<replaceable>value</replaceable></option></term>
723 <listitem>
724 <para>Set the internal log level of
725 <filename>systemd-udevd</filename>. Valid values are the
726 numerical syslog priorities or their textual
727 representations: <option>emerg</option>,
728 <option>alert</option>, <option>crit</option>,
729 <option>err</option>, <option>warning</option>,
730 <option>notice</option>, <option>info</option>, and
731 <option>debug</option>.</para>
732 </listitem>
733 </varlistentry>
734 <varlistentry>
735 <term><option>-s</option></term>
736 <term><option>--stop-exec-queue</option></term>
737 <listitem>
738 <para>Signal systemd-udevd to stop executing new events. Incoming events
739 will be queued.</para>
740 </listitem>
741 </varlistentry>
742 <varlistentry>
743 <term><option>-S</option></term>
744 <term><option>--start-exec-queue</option></term>
745 <listitem>
746 <para>Signal systemd-udevd to enable the execution of events.</para>
747 </listitem>
748 </varlistentry>
749 <varlistentry>
750 <term><option>-R</option></term>
751 <term><option>--reload</option></term>
752 <listitem>
753 <para>Signal systemd-udevd to reload the rules files and other databases like the kernel
754 module index. Reloading rules and databases does not apply any changes to already
755 existing devices; the new configuration will only be applied to new events.</para>
756 </listitem>
757 </varlistentry>
758 <varlistentry>
759 <term><option>-p</option></term>
760 <term><option>--property=<replaceable>KEY</replaceable>=<replaceable>value</replaceable></option></term>
761 <listitem>
762 <para>Set a global property for all events.</para>
763 </listitem>
764 </varlistentry>
765 <varlistentry>
766 <term><option>-m</option></term>
767 <term><option>--children-max=<replaceable>value</replaceable></option></term>
768 <listitem>
769 <para>Set the maximum number of events, systemd-udevd will handle at the same time. When 0 is
770 specified, then the maximum is determined based on the system resources.</para>
771 </listitem>
772 </varlistentry>
773 <varlistentry>
774 <term><option>--ping</option></term>
775 <listitem>
776 <para>Send a ping message to systemd-udevd and wait for the reply. This may be useful to check that
777 systemd-udevd daemon is running.</para>
778
779 <xi:include href="version-info.xml" xpointer="v241"/>
780 </listitem>
781 </varlistentry>
782 <varlistentry>
783 <term><option>--trace=<replaceable>BOOL</replaceable></option></term>
784 <listitem>
785 <para>Enable/disable trace logging in <command>systemd-udevd</command>.</para>
786
787 <xi:include href="version-info.xml" xpointer="v258"/>
788 </listitem>
789 </varlistentry>
790 <varlistentry>
791 <term><option>--revert</option></term>
792 <listitem>
793 <para>Revert settings previously set with <command>udevadm control</command> command. When
794 specified, settings set with <option>-l/--log-level=</option>, <option>--trace</option>,
795 <option>-m/--children-max=</option>, and <option>-p/--property=</option> will be cleared.</para>
796
797 <xi:include href="version-info.xml" xpointer="v258"/>
798 </listitem>
799 </varlistentry>
800 <varlistentry>
801 <term><option>-t</option></term>
802 <term><option>--timeout=<replaceable>seconds</replaceable></option></term>
803 <listitem>
804 <para>The maximum number of seconds to wait for a reply from systemd-udevd.</para>
805 </listitem>
806 </varlistentry>
807
808 <varlistentry>
809 <term><option>--load-credentials</option></term>
810 <listitem>
811 <para>When specified, the following credentials are used when passed in:</para>
812
813 <variablelist>
814 <varlistentry>
815 <term><varname>udev.conf.*</varname></term>
816 <listitem>
817 <para>These credentials should contain valid
818 <citerefentry><refentrytitle>udev.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>
819 configuration data. From each matching credential a separate file is created. Example: a
820 passed credential <filename>udev.conf.50-foobar</filename> will be copied into a
821 configuration file <filename>/run/udev/udev.conf.d/50-foobar.conf</filename>.</para>
822
823 <xi:include href="version-info.xml" xpointer="v256"/>
824 </listitem>
825 </varlistentry>
826 <varlistentry>
827 <term><varname>udev.rules.*</varname></term>
828 <listitem>
829 <para>These credentials should contain valid
830 <citerefentry><refentrytitle>udev</refentrytitle><manvolnum>7</manvolnum></citerefentry>
831 rules. From each matching credential a separate file is created. Example: a passed credential
832 <filename>udev.rules.50-foobar</filename> will be copied into a configuration file
833 <filename>/run/udev/rules.d/50-foobar.rules</filename>.</para>
834
835 <xi:include href="version-info.xml" xpointer="v256"/>
836 </listitem>
837 </varlistentry>
838 </variablelist>
839
840 <para>Note, this <emphasis>does not</emphasis> imply <option>--reload</option> option. So, if
841 <command>systemd-udevd</command> is already running, please consider to also specify
842 <option>-reload</option> to make the copied udev rules files used by
843 <command>systemd-udevd</command>.</para>
844
845 <xi:include href="version-info.xml" xpointer="v256"/>
846 </listitem>
847 </varlistentry>
848 </variablelist>
849 </refsect2>
850
851 <refsect2>
852 <title>udevadm monitor
853 <optional><replaceable>options</replaceable>…</optional>
854 </title>
855
856 <para>Listens to the kernel uevents and events sent out by a udev rule
857 and prints the devpath of the event to the console. It can be used to analyze the
858 event timing, by comparing the timestamps of the kernel uevent and the udev event.
859 </para>
860
861 <variablelist>
862 <varlistentry>
863 <term><option>-k</option></term>
864 <term><option>--kernel</option></term>
865 <listitem>
866 <para>Print the kernel uevents.</para>
867 </listitem>
868 </varlistentry>
869 <varlistentry>
870 <term><option>-u</option></term>
871 <term><option>--udev</option></term>
872 <listitem>
873 <para>Print the udev event after the rule processing.</para>
874 </listitem>
875 </varlistentry>
876 <varlistentry>
877 <term><option>-p</option></term>
878 <term><option>--property</option></term>
879 <listitem>
880 <para>Also print the properties of the event.</para>
881 </listitem>
882 </varlistentry>
883 <varlistentry>
884 <term><option>-s</option></term>
885 <term><option>--subsystem-match=<replaceable>string[/string]</replaceable></option></term>
886 <listitem>
887 <para>Filter kernel uevents and udev events by subsystem[/devtype]. Only events with a matching subsystem value will pass.
888 When this option is specified more than once, then each matching result is ORed, that is, all devices in the specified
889 subsystems are monitored.</para>
890 </listitem>
891 </varlistentry>
892 <varlistentry>
893 <term><option>-t</option></term>
894 <term><option>--tag-match=<replaceable>string</replaceable></option></term>
895 <listitem>
896 <para>Filter udev events by tag. Only udev events with a given tag attached will pass.
897 When this option is specified more than once, then each matching result is ORed, that is, devices which have one of the
898 specified tags are monitored.</para>
899 </listitem>
900 </varlistentry>
901 </variablelist>
902 </refsect2>
903
904 <refsect2>
905 <title>udevadm test
906 <optional><replaceable>options</replaceable>…</optional>
907 <replaceable>devpath</replaceable>|<replaceable>syspath</replaceable>|<replaceable>id</replaceable>|<replaceable>unit</replaceable>
908 </title>
909
910 <para>
911 Simulate a udev event run for the given device, and print debug output. The option
912 <option>--json=</option> may be useful for parsing the final result. See also Example section.
913 </para>
914
915 <variablelist>
916 <varlistentry>
917 <term><option>-a</option></term>
918 <term><option>--action=<replaceable>ACTION</replaceable></option></term>
919 <listitem>
920 <para>Type of event to be simulated. Possible actions are <literal>add</literal>,
921 <literal>remove</literal>, <literal>change</literal>, <literal>move</literal>,
922 <literal>online</literal>, <literal>offline</literal>, <literal>bind</literal>,
923 and <literal>unbind</literal>. Also, the special value <literal>help</literal> can be used
924 to list the possible actions. The default value is <literal>add</literal>.</para>
925 </listitem>
926 </varlistentry>
927 <varlistentry>
928 <term><option>-N</option></term>
929 <term><option>--resolve-names=<constant>early</constant>|<constant>late</constant>|<constant>never</constant></option></term>
930 <listitem>
931 <para>Specify when <command>udevadm</command> should resolve names of users and groups specified
932 in udev rules. When set to <constant>early</constant> (the default), names will be resolved when
933 the rules are parsed. When set to <constant>late</constant>, names will be resolved during the
934 event being processed. When set to <constant>never</constant>, names will never be resolved and
935 relevant udev rules will be ignored.</para>
936
937 <xi:include href="version-info.xml" xpointer="v209"/>
938 </listitem>
939 </varlistentry>
940 <varlistentry>
941 <term><option>-D <replaceable>DIR</replaceable></option></term>
942 <term><option>--extra-rules-dir=<replaceable>DIR</replaceable></option></term>
943 <listitem>
944 <para>Also load udev rules files from the specified directory. This option can be specified
945 multiple times. It may be useful for debugging udev rules by copying some udev rules files to a
946 temporary directory, editing them, and specifying the directory with this option. Files found in
947 the specified directories have a higher priority than rules files in the default
948 <filename>udev/rules.d</filename> directories used by <command>systemd-udevd</command>. See
949 <citerefentry><refentrytitle>udev</refentrytitle><manvolnum>7</manvolnum></citerefentry> for more
950 details about the search paths.</para>
951
952 <xi:include href="version-info.xml" xpointer="v258"/>
953 </listitem>
954 </varlistentry>
955 <varlistentry>
956 <term><option>-v</option></term>
957 <term><option>--verbose</option></term>
958 <listitem>
959 <para>Shows verbose logs in processing udev rules.</para>
960
961 <xi:include href="version-info.xml" xpointer="v258"/>
962 </listitem>
963 </varlistentry>
964
965 <xi:include href="standard-options.xml" xpointer="json" />
966 </variablelist>
967 </refsect2>
968
969 <refsect2>
970 <title>udevadm test-builtin
971 <optional><replaceable>options</replaceable>…</optional>
972 <replaceable>command</replaceable>
973 <replaceable>devpath</replaceable>|<replaceable>file</replaceable>|<replaceable>unit</replaceable>
974 </title>
975
976 <para>Run a built-in command <replaceable>COMMAND</replaceable>
977 for device <replaceable>DEVPATH</replaceable>, and print debug
978 output.</para>
979
980 <variablelist>
981 <varlistentry>
982 <term><option>-a</option></term>
983 <term><option>--action=<replaceable>ACTION</replaceable></option></term>
984 <listitem>
985 <para>Type of event to be simulated. Possible actions are <literal>add</literal>,
986 <literal>remove</literal>, <literal>change</literal>, <literal>move</literal>,
987 <literal>online</literal>, <literal>offline</literal>, <literal>bind</literal>,
988 and <literal>unbind</literal>. Also, the special value <literal>help</literal> can be used
989 to list the possible actions. The default value is <literal>add</literal>.</para>
990
991 <xi:include href="version-info.xml" xpointer="v250"/>
992 </listitem>
993 </varlistentry>
994 </variablelist>
995 </refsect2>
996
997 <refsect2>
998 <title>udevadm verify
999 <optional><replaceable>options</replaceable>…</optional>
1000 <optional><replaceable>files</replaceable>…</optional>
1001 </title>
1002
1003 <para>Verify syntactic, semantic, and stylistic correctness of udev rules files.</para>
1004
1005 <para>Positional arguments can be used to specify one or more files to check. Each argument must be an
1006 absolute path to a udev rules file or a directory that contains rules files, or a file name of udev
1007 rules file (e.g. <filename>99-systemd.rules</filename>). If a file name is specified, the file will be
1008 searched in the <filename>udev/rules.d</filename> directories that are processed by
1009 <command>systemd-udevd</command>, and searched in the current working directory if not found. If no
1010 files are specified, the udev rules are read from the files located in the same
1011 <filename>udev/rules.d</filename> directories that are processed by <command>systemd-udevd</command>.
1012 See <citerefentry><refentrytitle>udev</refentrytitle><manvolnum>7</manvolnum></citerefentry> for more
1013 details about the search paths.</para>
1014
1015 <para>The exit status is <constant>0</constant> if all specified udev
1016 rules files are syntactically, semantically, and stylistically correct,
1017 and a non-zero error code otherwise.</para>
1018
1019 <variablelist>
1020 <varlistentry>
1021 <term><option>-N</option></term>
1022 <term><option>--resolve-names=<constant>early</constant>|<constant>late</constant>|<constant>never</constant></option></term>
1023 <listitem>
1024 <para>Specify when <command>udevadm</command> should resolve names of users and groups specified
1025 in udev rules. When set to <constant>early</constant> (the default), names will be resolved when
1026 the rules are parsed. When set to <constant>late</constant>, names will not be verified, as
1027 <command>systemd-udevd</command> resolves names during each event being processed. When set to
1028 <constant>never</constant>, names will never be resolved and relevant rules will be ignored.
1029 </para>
1030
1031 <xi:include href="version-info.xml" xpointer="v254"/>
1032 </listitem>
1033 </varlistentry>
1034
1035 <varlistentry>
1036 <term><option>--root=<replaceable>PATH</replaceable></option></term>
1037 <listitem>
1038 <para>When looking for udev rules files located in the <filename>udev/rules.d</filename>
1039 directories, operate on files underneath the specified root path <replaceable>PATH</replaceable>.
1040 When a file name is specified, and it is not found in the <filename>udev/rules.d</filename>
1041 directories, the file will be searched in the specified root path
1042 <replaceable>PATH</replaceable>, rather than the current working directory.</para>
1043
1044 <xi:include href="version-info.xml" xpointer="v254"/>
1045 </listitem>
1046 </varlistentry>
1047
1048 <varlistentry>
1049 <term><option>--no-summary</option></term>
1050 <listitem>
1051 <para>Do not show summary.</para>
1052
1053 <xi:include href="version-info.xml" xpointer="v254"/>
1054 </listitem>
1055 </varlistentry>
1056
1057 <varlistentry>
1058 <term><option>--no-style</option></term>
1059 <listitem>
1060 <para>Ignore style issues. When specified, even if style issues are found in udev rules files,
1061 the exit status is <constant>0</constant> if no syntactic or semantic errors are found.</para>
1062
1063 <xi:include href="version-info.xml" xpointer="v254"/>
1064 </listitem>
1065 </varlistentry>
1066 </variablelist>
1067 </refsect2>
1068
1069 <refsect2>
1070 <title>udevadm cat
1071 <optional><replaceable>options</replaceable>…</optional>
1072 <optional><replaceable>file</replaceable>…</optional>
1073 </title>
1074
1075 <para>Show udev rules files or udev.conf.</para>
1076
1077 <para>Positional arguments can be used to specify one or more files to show. Each argument must be an
1078 absolute path to a udev rules file or a directory that contains rules files, or a file name of udev
1079 rules file (e.g. <filename>99-systemd.rules</filename>). If a file name is specified, the file will be
1080 searched in the <filename>udev/rules.d</filename> directories that are processed by
1081 <command>systemd-udevd</command>, and searched in the current working directory if not found. If no
1082 files are specified, the udev rules are read from the files located in the same
1083 <filename>udev/rules.d</filename> directories that are processed by <command>systemd-udevd</command>.
1084 See <citerefentry><refentrytitle>udev</refentrytitle><manvolnum>7</manvolnum></citerefentry> for more
1085 details about the search paths.</para>
1086
1087 <variablelist>
1088 <varlistentry>
1089 <term><option>--root=<replaceable>PATH</replaceable></option></term>
1090 <listitem>
1091 <para>When looking for udev rules files located in the <filename>udev/rules.d</filename>
1092 directories, operate on files underneath the specified root path <replaceable>PATH</replaceable>.
1093 When a file name is specified, and it is not found in the <filename>udev/rules.d</filename>
1094 directories, the file will be searched in the specified root path
1095 <replaceable>PATH</replaceable>, rather than the current working directory.</para>
1096
1097 <xi:include href="version-info.xml" xpointer="v258"/>
1098 </listitem>
1099 </varlistentry>
1100
1101 <varlistentry>
1102 <term><option>--tldr</option></term>
1103 <listitem>
1104 <para>Only print the "interesting" parts of the configuration files, skipping comments and empty
1105 lines and section headers followed only by comments and empty lines.</para>
1106
1107 <xi:include href="version-info.xml" xpointer="v258"/>
1108 </listitem>
1109 </varlistentry>
1110
1111 <varlistentry>
1112 <term><option>--config</option></term>
1113 <listitem>
1114 <para>Shows
1115 <citerefentry><refentrytitle>udev.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>
1116 files, rather than udev rules files. When specified, no udev rules file cannot be specified.
1117 </para>
1118
1119 <xi:include href="version-info.xml" xpointer="v258"/>
1120 </listitem>
1121 </varlistentry>
1122 </variablelist>
1123 </refsect2>
1124
1125 <refsect2>
1126 <title>udevadm wait
1127 <optional><replaceable>options</replaceable>…</optional>
1128 <replaceable>devpath|syspath</replaceable>…
1129 </title>
1130
1131 <para>Wait for devices or device symlinks being created and initialized by
1132 <command>systemd-udevd</command>. Each device path must start with
1133 <literal>/dev/</literal> or <literal>/sys/</literal>, e.g. <literal>/dev/sda</literal>,
1134 <literal>/dev/disk/by-path/pci-0000:3c:00.0-nvme-1-part1</literal>,
1135 <literal>/sys/devices/pci0000:00/0000:00:1f.6/net/eth0</literal>, or
1136 <literal>/sys/class/net/eth0</literal>. This can take multiple devices. This may be useful for
1137 waiting for devices being processed by <command>systemd-udevd</command> after e.g. partitioning
1138 or formatting the devices.</para>
1139
1140 <variablelist>
1141 <varlistentry>
1142 <term><option>-t</option></term>
1143 <term><option>--timeout=<replaceable>SECONDS</replaceable></option></term>
1144 <listitem>
1145 <para>Maximum number of seconds to wait for the specified devices or device symlinks being
1146 created, initialized, or removed. The default value is <literal>infinity</literal>.</para>
1147
1148 <xi:include href="version-info.xml" xpointer="v251"/>
1149 </listitem>
1150 </varlistentry>
1151
1152 <varlistentry>
1153 <term><option>--initialized=<replaceable>BOOL</replaceable></option></term>
1154 <listitem>
1155 <para>Check if <command>systemd-udevd</command> initialized devices. Defaults to true. When
1156 false, the command only checks if the specified devices exist. Set false to this setting if
1157 there is no udev rules for the specified devices, as the devices will never be considered
1158 as initialized in that case. See Initialized Devices section below for more details.</para>
1159
1160 <xi:include href="version-info.xml" xpointer="v251"/>
1161 </listitem>
1162 </varlistentry>
1163
1164 <varlistentry>
1165 <term><option>--removed</option></term>
1166 <listitem>
1167 <para>When specified, the command wait for devices being removed instead of created or
1168 initialized. If this is specified, <option>--initialized=</option> will be ignored.</para>
1169
1170 <xi:include href="version-info.xml" xpointer="v251"/>
1171 </listitem>
1172 </varlistentry>
1173
1174 <varlistentry>
1175 <term><option>--settle</option></term>
1176 <listitem>
1177 <para>When specified, also watches the udev event queue, and wait for all queued events
1178 being processed by <command>systemd-udevd</command>.</para>
1179
1180 <xi:include href="version-info.xml" xpointer="v251"/>
1181 </listitem>
1182 </varlistentry>
1183 </variablelist>
1184 </refsect2>
1185
1186 <refsect2>
1187 <title>udevadm lock
1188 <optional><replaceable>options</replaceable>…</optional>
1189 <replaceable>command</replaceable>…
1190 </title>
1191
1192 <para><command>udevadm lock</command> takes an (advisory) exclusive lock on a block device (or all
1193 specified devices), as per <ulink url="https://systemd.io/BLOCK_DEVICE_LOCKING">Locking Block Device
1194 Access</ulink> and invokes a program with the locks taken. When the invoked program exits the locks
1195 are automatically released and its return value is propagated as exit code of <command>udevadm
1196 lock</command>.</para>
1197
1198 <para>This tool is in particular useful to ensure that
1199 <citerefentry><refentrytitle>systemd-udevd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
1200 does not probe a block device while changes are made to it, for example partitions created or file
1201 systems formatted. Note that many tools that interface with block devices natively support taking
1202 relevant locks, see for example
1203 <citerefentry project='man-pages'><refentrytitle>sfdisk</refentrytitle><manvolnum>8</manvolnum></citerefentry>'s
1204 <option>--lock</option> switch.</para>
1205
1206 <para>The command expects at least one block device specified via <option>--device=</option> or
1207 <option>--backing=</option>, and a command line to execute as arguments.</para>
1208
1209 <variablelist>
1210 <varlistentry>
1211 <term><option>--device=<replaceable>DEVICE</replaceable></option></term>
1212 <term><option>-d <replaceable>DEVICE</replaceable></option></term>
1213
1214 <listitem>
1215 <para>Takes a path to a device node of the device to lock. This switch may be used
1216 multiple times (and in combination with <option>--backing=</option>) in order to lock multiple
1217 devices. If a partition block device node is specified the containing "whole" block device is
1218 automatically determined and used for the lock, as per the specification. If multiple devices are
1219 specified, they are deduplicated, sorted by the major/minor of their device nodes and then locked
1220 in order.</para>
1221
1222 <para>This switch must be used at least once, to specify at least one device to
1223 lock. (Alternatively, use <option>--backing=</option>, see below.)</para>
1224
1225 <xi:include href="version-info.xml" xpointer="v251"/>
1226 </listitem>
1227 </varlistentry>
1228
1229 <varlistentry>
1230 <term><option>--backing=<replaceable>PATH</replaceable></option></term>
1231 <term><option>-b <replaceable>PATH</replaceable></option></term>
1232
1233 <listitem>
1234 <para>If a path to a device node is specified, identical to
1235 <option>--device=</option>. However, this switch alternatively accepts a path to a regular file or
1236 directory, in which case the block device of the file system the file/directory resides on is
1237 automatically determined and used as if it was specified with
1238 <option>--device=</option>.</para>
1239
1240 <xi:include href="version-info.xml" xpointer="v251"/>
1241 </listitem>
1242 </varlistentry>
1243
1244 <varlistentry>
1245 <term><option>--timeout=<replaceable>SECS</replaceable></option></term>
1246 <term><option>-t <replaceable>SECS</replaceable></option></term>
1247
1248 <listitem>
1249 <para>Specifies how long to wait at most until all locks can be taken. Takes a value in
1250 seconds, or in the usual supported time units, see
1251 <citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry>. If
1252 specified as zero the lock is attempted and if not successful the invocation will immediately
1253 fail. If passed as <literal>infinity</literal> (the default) the invocation will wait indefinitely
1254 until the lock can be acquired. If the lock cannot be taken in the specified time the specified
1255 command will not be executed and the invocation will fail.</para>
1256
1257 <xi:include href="version-info.xml" xpointer="v251"/>
1258 </listitem>
1259 </varlistentry>
1260
1261 <varlistentry>
1262 <term><option>--print</option></term>
1263 <term><option>-p</option></term>
1264
1265 <listitem>
1266 <para>Instead of locking the specified devices and executing a command, just print the
1267 device paths that would be locked, and execute no command. This command is useful to determine
1268 the "whole" block device in case a partition block device is specified. The devices will be sorted
1269 by their device node major number as primary ordering key and the minor number as secondary
1270 ordering key (i.e. they are shown in the order they'd be locked). Note that the number of lines
1271 printed here can be less than the number of <option>--device=</option> and
1272 <option>--backing=</option> switches specified in case these resolve to the same "whole"
1273 devices.</para>
1274
1275 <xi:include href="version-info.xml" xpointer="v251"/>
1276 </listitem>
1277 </varlistentry>
1278 </variablelist>
1279 </refsect2>
1280 </refsect1>
1281
1282 <refsect1>
1283 <title>Initialized Devices</title>
1284
1285 <para>Initialized devices are those for which at least one udev rule already completed execution
1286 – for any action but <literal>remove</literal> — that set a property or other device setting (and
1287 thus has an entry in the udev device database). Devices are no longer considered initialized if a
1288 <literal>remove</literal> action is seen for them (which removes their entry in the udev device
1289 database). Note that devices that have no udev rules are never considered initialized, but might
1290 still be announced via the sd-device API (or similar).</para>
1291 </refsect1>
1292
1293 <refsect1>
1294 <title>Example</title>
1295
1296 <example>
1297 <title>Format a File System</title>
1298
1299 <para>Take a lock on the backing block device while creating a file system, to ensure that
1300 <command>systemd-udevd</command> does not probe or announce the new superblock before it is
1301 comprehensively written:</para>
1302
1303 <programlisting># udevadm lock --device=/dev/sda1 mkfs.ext4 /dev/sda1</programlisting>
1304 </example>
1305
1306 <example>
1307 <title>Format a RAID File System</title>
1308
1309 <para>Similar, but take locks on multiple devices at once:</para>
1310
1311 <programlisting># udevadm lock --device=/dev/sda1 --device=/dev/sdb1 mkfs.btrfs /dev/sda1 /dev/sdb1</programlisting>
1312 </example>
1313
1314 <example>
1315 <title>Copy in a File System</title>
1316
1317 <para>Take a lock on the backing block device while copying in a prepared file system image, to ensure
1318 that <command>systemd-udevd</command> does not probe or announce the new superblock before it is fully
1319 written:</para>
1320
1321 <programlisting># udevadm lock -d /dev/sda1 dd if=fs.raw of=/dev/sda1</programlisting>
1322 </example>
1323
1324 <example>
1325 <title>Predict Network Interface Renaming</title>
1326
1327 <para>To predict a network interface name, <command>udevadm test</command> can be used:</para>
1328
1329 <programlisting>$ udevadm test /sys/class/net/wlan0 --json=pretty 2>/dev/null | jq .networkInterface.name
1330 "wlp59s0"</programlisting>
1331 </example>
1332
1333 <example>
1334 <title>Predict Symbolic links of a Device Node</title>
1335
1336 <para>To predict symbolic links to a device node, <command>udevadm test</command> can be used:</para>
1337
1338 <programlisting>$ udevadm test /dev/nvme0n1p1 --json=pretty 2>/dev/null | jq .node.symlinks
1339 [
1340 "/dev/disk/by-diskseq/1-part1",
1341 "/dev/disk/by-id/nvme-WDC_PC_SN720_SDAQNTW-512G-1001_192290802247-part1",
1342 "/dev/disk/by-id/nvme-WDC_PC_SN720_SDAQNTW-512G-1001_192290802247_1-part1",
1343 "/dev/disk/by-id/nvme-eui.1922908022470001001b448b44ccb9d6-part1",
1344 "/dev/disk/by-path/pci-0000:3c:00.0-nvme-1-part/by-partnum/1",
1345 "/dev/disk/by-path/pci-0000:3c:00.0-nvme-1-part1"
1346 ]
1347 $ udevadm test /dev/input/event3 --json=pretty 2>/dev/null | jq .node.symlinks
1348 [
1349 "/dev/input/by-path/platform-i8042-serio-0-event-kbd"
1350 ]</programlisting>
1351 </example>
1352
1353 </refsect1>
1354
1355 <refsect1>
1356 <title>See Also</title>
1357 <para><simplelist type="inline">
1358 <member><citerefentry><refentrytitle>udev</refentrytitle><manvolnum>7</manvolnum></citerefentry></member>
1359 <member><citerefentry><refentrytitle>systemd-udevd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry></member>
1360 <member><citerefentry><refentrytitle>udev.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
1361 </simplelist></para>
1362 </refsect1>
1363 </refentry>