]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/udevadm.xml
1c339a6b6d119140f4736a16004edcbcee4cac24
[thirdparty/systemd.git] / man / udevadm.xml
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.2/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 <optional>options</optional> <optional>devpath</optional></command>
32 </cmdsynopsis>
33 <cmdsynopsis>
34 <command>udevadm trigger <optional>options</optional> <optional>devpath</optional></command>
35 </cmdsynopsis>
36 <cmdsynopsis>
37 <command>udevadm settle <optional>options</optional></command>
38 </cmdsynopsis>
39 <cmdsynopsis>
40 <command>udevadm control <replaceable>option</replaceable></command>
41 </cmdsynopsis>
42 <cmdsynopsis>
43 <command>udevadm monitor <optional>options</optional></command>
44 </cmdsynopsis>
45 <cmdsynopsis>
46 <command>udevadm test <optional>options</optional> <replaceable>devpath</replaceable></command>
47 </cmdsynopsis>
48 <cmdsynopsis>
49 <command>udevadm test-builtin <optional>options</optional> <replaceable>command</replaceable> <replaceable>devpath</replaceable></command>
50 </cmdsynopsis>
51 <cmdsynopsis>
52 <command>udevadm verify</command>
53 <arg choice="opt" rep="repeat">options</arg>
54 <arg choice="opt" rep="repeat"><replaceable>file</replaceable></arg>
55 </cmdsynopsis>
56 <cmdsynopsis>
57 <command>udevadm wait <optional>options</optional> <replaceable>device|syspath</replaceable></command>
58 </cmdsynopsis>
59 <cmdsynopsis>
60 <command>udevadm lock <optional>options</optional> <replaceable>command</replaceable></command>
61 </cmdsynopsis>
62 </refsynopsisdiv>
63
64 <refsect1><title>Description</title>
65 <para><command>udevadm</command> expects a command and command
66 specific options. It controls the runtime behavior of
67 <command>systemd-udevd</command>, requests kernel events, manages
68 the event queue, and provides simple debugging mechanisms.</para>
69 </refsect1>
70
71 <refsect1><title>Options</title>
72 <variablelist>
73 <varlistentry>
74 <term><option>-d</option></term>
75 <term><option>--debug</option></term>
76 <listitem>
77 <para>Print debug messages to standard error. This option is implied in <command>udevadm test</command> and
78 <command>udevadm test-builtin</command> commands.</para>
79 </listitem>
80 </varlistentry>
81
82 <xi:include href="standard-options.xml" xpointer="help" />
83 </variablelist>
84
85 <refsect2><title>udevadm info
86 <arg choice="opt"><replaceable>options</replaceable></arg>
87 <arg choice="opt" rep="repeat"><replaceable>devpath</replaceable>|<replaceable>file</replaceable>|<replaceable>unit</replaceable></arg>
88 </title>
89
90 <para>Query the udev database for device information.</para>
91
92 <para>Positional arguments should be used to specify one or more devices. Each one may be a device name
93 (in which case it must start with <filename>/dev/</filename>), a sys path (in which case it must start
94 with <filename>/sys/</filename>), or a systemd device unit name (in which case it must end with
95 <literal>.device</literal>, see
96 <citerefentry><refentrytitle>systemd.device</refentrytitle><manvolnum>5</manvolnum></citerefentry>).
97 </para>
98
99 <variablelist>
100 <varlistentry>
101 <term><option>-q</option></term>
102 <term><option>--query=<replaceable>TYPE</replaceable></option></term>
103 <listitem>
104 <para>Query the database for the specified type of device data.
105 Valid <replaceable>TYPE</replaceable>s are:
106 <constant>name</constant>, <constant>symlink</constant>,
107 <constant>path</constant>, <constant>property</constant>,
108 <constant>all</constant>.</para>
109 </listitem>
110 </varlistentry>
111
112 <varlistentry>
113 <term><option>--property=<replaceable>NAME</replaceable></option></term>
114 <listitem>
115 <para>When showing device properties using the <option>--query=property</option>
116 option, limit display to properties specified in the argument. The argument should
117 be a comma-separated list of property names. If not specified, all known properties
118 are shown.</para>
119 </listitem>
120 </varlistentry>
121 <varlistentry>
122 <term><option>--value</option></term>
123 <listitem>
124 <para>When showing device properties using the <option>--query=property</option>
125 option, print only their values, and skip the property name and <literal>=</literal>.</para>
126 <para>Cannot be used together with <option>-x/--export</option> or
127 <option>-P/--export-prefix</option>.</para>
128 </listitem>
129 </varlistentry>
130 <varlistentry>
131 <term><option>-p</option></term>
132 <term><option>--path=<replaceable>DEVPATH</replaceable></option></term>
133 <listitem>
134 <para>The <filename>/sys/</filename> path of the device to query, e.g.
135 <filename><optional>/sys/</optional>/class/block/sda</filename>. This option is an alternative to
136 the positional argument with a <filename>/sys/</filename> prefix. <command>udevadm info
137 --path=/class/block/sda</command> is equivalent to <command>udevadm info
138 /sys/class/block/sda</command>.</para>
139 </listitem>
140 </varlistentry>
141 <varlistentry>
142 <term><option>-n</option></term>
143 <term><option>--name=<replaceable>FILE</replaceable></option></term>
144 <listitem>
145 <para>The name of the device node or a symlink to query,
146 e.g. <filename><optional>/dev/</optional>/sda</filename>. This option is an alternative to the
147 positional argument with a <filename>/dev/</filename> prefix. <command>udevadm info
148 --name=sda</command> is equivalent to <command>udevadm info /dev/sda</command>.</para>
149 </listitem>
150 </varlistentry>
151 <varlistentry>
152 <term><option>-r</option></term>
153 <term><option>--root</option></term>
154 <listitem>
155 <para>Print absolute paths in <command>name</command> or <command>symlink</command>
156 query.</para>
157 </listitem>
158 </varlistentry>
159 <varlistentry>
160 <term><option>-a</option></term>
161 <term><option>--attribute-walk</option></term>
162 <listitem>
163 <para>Print all sysfs properties of the specified device that can be used
164 in udev rules to match the specified device. It prints all devices
165 along the chain, up to the root of sysfs that can be used in udev rules.</para>
166 </listitem>
167 </varlistentry>
168 <varlistentry>
169 <term><option>-t</option></term>
170 <term><option>--tree</option></term>
171 <listitem>
172 <para>Display a sysfs tree. This recursively iterates through the sysfs hierarchy and displays it
173 in a tree structure. If a path is specified only the subtree below and its parent directories are
174 shown. This will show both device and subsystem items.</para>
175 </listitem>
176 </varlistentry>
177 <varlistentry>
178 <term><option>-x</option></term>
179 <term><option>--export</option></term>
180 <listitem>
181 <para>Print output as key/value pairs. Values are enclosed in single quotes.
182 This takes effects only when <option>--query=property</option> or
183 <option>--device-id-of-file=<replaceable>FILE</replaceable></option> is specified.</para>
184 </listitem>
185 </varlistentry>
186 <varlistentry>
187 <term><option>-P</option></term>
188 <term><option>--export-prefix=<replaceable>NAME</replaceable></option></term>
189 <listitem>
190 <para>Add a prefix to the key name of exported values.
191 This implies <option>--export</option>.</para>
192 </listitem>
193 </varlistentry>
194 <varlistentry>
195 <term><option>-d</option></term>
196 <term><option>--device-id-of-file=<replaceable>FILE</replaceable></option></term>
197 <listitem>
198 <para>Print major/minor numbers of the underlying device, where the file lives on.
199 If this is specified, all positional arguments are ignored.</para>
200 </listitem>
201 </varlistentry>
202 <varlistentry>
203 <term><option>-e</option></term>
204 <term><option>--export-db</option></term>
205 <listitem>
206 <para>Export the content of the udev database.</para>
207 </listitem>
208 </varlistentry>
209 <varlistentry>
210 <term><option>-c</option></term>
211 <term><option>--cleanup-db</option></term>
212 <listitem>
213 <para>Cleanup the udev database.</para>
214 </listitem>
215 </varlistentry>
216 <varlistentry>
217 <term><option>-w<optional>SECONDS</optional></option></term>
218 <term><option>--wait-for-initialization<optional>=SECONDS</optional></option></term>
219 <listitem>
220 <para>Wait for device to be initialized. If argument <replaceable>SECONDS</replaceable>
221 is not specified, the default is to wait forever.</para>
222 </listitem>
223 </varlistentry>
224
225 <xi:include href="standard-options.xml" xpointer="help" />
226 <xi:include href="standard-options.xml" xpointer="no-pager" />
227 </variablelist>
228
229 <para>The generated output shows the current device database entry in a terse format. Each line shown
230 is prefixed with one of the following characters:</para>
231
232 <table>
233 <title><command>udevadm info</command> output prefixes</title>
234 <tgroup cols='2' align='left' colsep='1' rowsep='1'>
235 <colspec colname="prefix" />
236 <colspec colname="meaning" />
237 <thead>
238 <row>
239 <entry>Prefix</entry>
240 <entry>Meaning</entry>
241 </row>
242 </thead>
243 <tbody>
244 <row>
245 <entry><literal>P:</literal></entry>
246 <entry>Device path in <filename>/sys/</filename></entry>
247 </row>
248 <row>
249 <entry><literal>M:</literal></entry>
250 <entry>Device name in <filename>/sys/</filename> (i.e. the last component of <literal>P:</literal>)</entry>
251 </row>
252 <row>
253 <entry><literal>R:</literal></entry>
254 <entry>Device number in <filename>/sys/</filename> (i.e. the numeric suffix of the last component of <literal>P:</literal>)</entry>
255 </row>
256 <row>
257 <entry><literal>U:</literal></entry>
258 <entry>Kernel subsystem</entry>
259 </row>
260 <row>
261 <entry><literal>T:</literal></entry>
262 <entry>Kernel device type within subsystem</entry>
263 </row>
264 <row>
265 <entry><literal>D:</literal></entry>
266 <entry>Kernel device node major/minor</entry>
267 </row>
268 <row>
269 <entry><literal>I:</literal></entry>
270 <entry>Network interface index</entry>
271 </row>
272 <row>
273 <entry><literal>N:</literal></entry>
274 <entry>Kernel device node name</entry>
275 </row>
276 <row>
277 <entry><literal>L:</literal></entry>
278 <entry>Device node symlink priority</entry>
279 </row>
280 <row>
281 <entry><literal>S:</literal></entry>
282 <entry>Device node symlink</entry>
283 </row>
284 <row>
285 <entry><literal>Q:</literal></entry>
286 <entry>Block device sequence number (DISKSEQ)</entry>
287 </row>
288 <row>
289 <entry><literal>V:</literal></entry>
290 <entry>Attached driver</entry>
291 </row>
292 <row>
293 <entry><literal>E:</literal></entry>
294 <entry>Device property</entry>
295 </row>
296 </tbody>
297 </tgroup>
298 </table>
299 </refsect2>
300
301 <refsect2><title>udevadm trigger
302 <arg choice="opt"><replaceable>options</replaceable></arg>
303 <arg choice="opt"><replaceable>devpath</replaceable>|<replaceable>file</replaceable>|<replaceable>unit</replaceable></arg>
304 </title>
305 <para>Request device events from the kernel. Primarily used to replay events at system coldplug time.</para>
306
307 <para>Takes device specifications as positional arguments. See the description of <command>info</command>
308 above.</para>
309
310 <variablelist>
311 <varlistentry>
312 <term><option>-v</option></term>
313 <term><option>--verbose</option></term>
314 <listitem>
315 <para>Print the list of devices which will be triggered.</para>
316 </listitem>
317 </varlistentry>
318 <varlistentry>
319 <term><option>-n</option></term>
320 <term><option>--dry-run</option></term>
321 <listitem>
322 <para>Do not actually trigger the event.</para>
323 </listitem>
324 </varlistentry>
325 <varlistentry>
326 <term><option>-q</option></term>
327 <term><option>--quiet</option></term>
328 <listitem>
329 <para>Suppress error logging in triggering events.</para>
330 </listitem>
331 </varlistentry>
332 <varlistentry>
333 <term><option>-t</option></term>
334 <term><option>--type=<replaceable>TYPE</replaceable></option></term>
335 <listitem>
336 <para>Trigger a specific type of devices. Valid types are <literal>all</literal>,
337 <literal>devices</literal>, and <literal>subsystems</literal>. The default value is
338 <literal>devices</literal>.</para>
339 </listitem>
340 </varlistentry>
341 <varlistentry>
342 <term><option>-c</option></term>
343 <term><option>--action=<replaceable>ACTION</replaceable></option></term>
344 <listitem>
345 <para>Type of event to be triggered. Possible actions are <literal>add</literal>,
346 <literal>remove</literal>, <literal>change</literal>, <literal>move</literal>,
347 <literal>online</literal>, <literal>offline</literal>, <literal>bind</literal>,
348 and <literal>unbind</literal>. Also, the special value <literal>help</literal> can be used
349 to list the possible actions. The default value is <literal>change</literal>.
350 </para>
351 </listitem>
352 </varlistentry>
353 <varlistentry>
354 <term><option>--prioritized-subsystem=<replaceable>SUBSYSTEM<optional>,<replaceable>SUBSYSTEM</replaceable></optional></replaceable></option></term>
355 <listitem>
356 <para>Takes a comma separated list of subsystems. When triggering events for devices, the
357 devices from the specified subsystems and their parents are triggered first. For example,
358 if <option>--prioritized-subsystem=block,net</option>, then firstly all block devices and
359 their parents are triggered, in the next all network devices and their parents are
360 triggered, and lastly the other devices are triggered. This option can be specified
361 multiple times, and in that case the lists of the subsystems will be merged. That is,
362 <option>--prioritized-subsystem=block --prioritized-subsystem=net</option> is equivalent to
363 <option>--prioritized-subsystem=block,net</option>.</para>
364 </listitem>
365 </varlistentry>
366 <varlistentry>
367 <term><option>-s</option></term>
368 <term><option>--subsystem-match=<replaceable>SUBSYSTEM</replaceable></option></term>
369 <listitem>
370 <para>Trigger events for devices which belong to a
371 matching subsystem. This option supports shell style pattern matching.
372 When this option is specified more than once, then each matching result is ORed, that is,
373 all the devices in each subsystem are triggered.</para>
374 </listitem>
375 </varlistentry>
376 <varlistentry>
377 <term><option>-S</option></term>
378 <term><option>--subsystem-nomatch=<replaceable>SUBSYSTEM</replaceable></option></term>
379 <listitem>
380 <para>Do not trigger events for devices which belong to a matching subsystem. This option
381 supports shell style pattern matching. When this option is specified more than once,
382 then each matching result is ANDed, that is, devices which do not match all specified
383 subsystems are triggered.</para>
384 </listitem>
385 </varlistentry>
386 <varlistentry>
387 <term><option>-a</option></term>
388 <term><option>--attr-match=<replaceable>ATTRIBUTE</replaceable>=<replaceable>VALUE</replaceable></option></term>
389 <listitem>
390 <para>Trigger events for devices with a matching sysfs attribute. If a value is specified along
391 with the attribute name, the content of the attribute is matched against the given value using
392 shell style pattern matching. If no value is specified, the existence of the sysfs attribute is
393 checked. When this option is specified multiple times, then each matching result is ANDed,
394 that is, only devices which have all specified attributes are triggered.</para>
395 </listitem>
396 </varlistentry>
397 <varlistentry>
398 <term><option>-A</option></term>
399 <term><option>--attr-nomatch=<replaceable>ATTRIBUTE</replaceable>=<replaceable>VALUE</replaceable></option></term>
400 <listitem>
401 <para>Do not trigger events for devices with a matching sysfs attribute. If a value is specified
402 along with the attribute name, the content of the attribute is matched against the given value
403 using shell style pattern matching. If no value is specified, the existence of the sysfs attribute
404 is checked. When this option is specified multiple times, then each matching result is ANDed,
405 that is, only devices which have none of the specified attributes are triggered.</para>
406 </listitem>
407 </varlistentry>
408 <varlistentry>
409 <term><option>-p</option></term>
410 <term><option>--property-match=<replaceable>PROPERTY</replaceable>=<replaceable>VALUE</replaceable></option></term>
411 <listitem>
412 <para>Trigger events for devices with a matching property value. This option supports shell style
413 pattern matching. When this option is specified more than once, then each matching result is ORed,
414 that is, devices which have one of the specified properties are triggered.</para>
415 </listitem>
416 </varlistentry>
417 <varlistentry>
418 <term><option>-g</option></term>
419 <term><option>--tag-match=<replaceable>TAG</replaceable></option></term>
420 <listitem>
421 <para>Trigger events for devices with a matching tag. When this option is specified multiple times,
422 then each matching result is ANDed, that is, devices which have all specified tags are triggered.</para>
423 </listitem>
424 </varlistentry>
425 <varlistentry>
426 <term><option>-y</option></term>
427 <term><option>--sysname-match=<replaceable>NAME</replaceable></option></term>
428 <listitem>
429 <para>Trigger events for devices for which the last component (i.e. the filename) of the
430 <filename>/sys/</filename> path matches the specified <replaceable>PATH</replaceable>. This option
431 supports shell style pattern matching. When this option is specified more than once, then each
432 matching result is ORed, that is, all devices which have any of the specified
433 <replaceable>NAME</replaceable> are triggered.</para>
434 </listitem>
435 </varlistentry>
436 <varlistentry>
437 <term><option>--name-match=<replaceable>NAME</replaceable></option></term>
438 <listitem>
439 <para>Trigger events for devices with a matching device path. When this option is specified more than once,
440 then each matching result is ORed, that is, all specified devices are triggered.</para>
441 </listitem>
442 </varlistentry>
443 <varlistentry>
444 <term><option>-b</option></term>
445 <term><option>--parent-match=<replaceable>SYSPATH</replaceable></option></term>
446 <listitem>
447 <para>Trigger events for all children of a given device. When this option is specified more than once,
448 then each matching result is ORed, that is, all children of each specified device are triggered.</para>
449 </listitem>
450 </varlistentry>
451 <varlistentry>
452 <term><option>--initialized-match</option></term>
453 <term><option>--initialized-nomatch</option></term>
454 <listitem>
455 <para>When <option>--initialized-match</option> is specified, trigger events for devices
456 that are already initialized by <command>systemd-udevd</command>, and skip devices that
457 are not initialized yet.</para>
458 <para>When <option>--initialized-nomatch</option> is specified, trigger events for devices
459 that are not initialized by <command>systemd-udevd</command> yet, and skip devices that
460 are already initialized.</para>
461 <para>Typically, it is essential that applications which intend to use such a match, make
462 sure a suitable udev rule is installed that sets at least one property on devices that
463 shall be matched. See also Initialized Devices section below for more details.</para>
464 <para>WARNING: <option>--initialized-nomatch</option> can potentially save a significant
465 amount of time compared to re-triggering all devices in the system and e.g. can be used to
466 optimize boot time. However, this is not safe to be used in a boot sequence in general.
467 Especially, when udev rules for a device depend on its parent devices (e.g.
468 <literal>ATTRS</literal> or <literal>IMPORT{parent}</literal> keys, see
469 <citerefentry><refentrytitle>udev</refentrytitle><manvolnum>7</manvolnum></citerefentry>
470 for more details), the final state of the device becomes easily unstable with this option.
471 </para>
472 </listitem>
473 </varlistentry>
474 <varlistentry>
475 <term><option>-w</option></term>
476 <term><option>--settle</option></term>
477 <listitem>
478 <para>Apart from triggering events, also waits for those events to
479 finish. Note that this is different from calling <command>udevadm
480 settle</command>. <command>udevadm settle</command> waits for all
481 events to finish. This option only waits for events triggered by
482 the same command to finish.</para>
483 </listitem>
484 </varlistentry>
485 <varlistentry>
486 <term><option>--uuid</option></term>
487 <listitem>
488 <para>Trigger the synthetic device events, and associate a randomized UUID with each. These UUIDs
489 are printed to standard output, one line for each event. These UUIDs are included in the uevent
490 environment block (in the <literal>SYNTH_UUID=</literal> property) and may be used to track
491 delivery of the generated events.</para>
492 </listitem>
493 </varlistentry>
494 <varlistentry>
495 <term><option>--wait-daemon[=<replaceable>SECONDS</replaceable>]</option></term>
496 <listitem>
497 <para>Before triggering uevents, wait for systemd-udevd daemon to be initialized.
498 Optionally takes timeout value. Default timeout is 5 seconds. This is equivalent to invoking
499 <command>udevadm control --ping</command> before <command>udevadm trigger</command>.</para>
500 </listitem>
501 </varlistentry>
502
503 <xi:include href="standard-options.xml" xpointer="help" />
504 </variablelist>
505
506 <para>In addition, optional positional arguments can be used
507 to specify device names or sys paths. They must start with
508 <filename>/dev/</filename> or <filename>/sys/</filename>
509 respectively.</para>
510 </refsect2>
511
512 <refsect2><title>udevadm settle
513 <arg choice="opt"><replaceable>options</replaceable></arg>
514 </title>
515 <para>Watches the udev event queue, and exits if all current events are handled.</para>
516 <variablelist>
517 <varlistentry>
518 <term><option>-t</option></term>
519 <term><option>--timeout=<replaceable>SECONDS</replaceable></option></term>
520 <listitem>
521 <para>Maximum number of seconds to wait for the event
522 queue to become empty. The default value is 120 seconds. A
523 value of 0 will check if the queue is empty and always
524 return immediately. A non-zero value will return an exit
525 code of 0 if queue became empty before timeout was reached,
526 non-zero otherwise.</para>
527 </listitem>
528 </varlistentry>
529 <varlistentry>
530 <term><option>-E</option></term>
531 <term><option>--exit-if-exists=<replaceable>FILE</replaceable></option></term>
532 <listitem>
533 <para>Stop waiting if file exists.</para>
534 </listitem>
535 </varlistentry>
536
537 <xi:include href="standard-options.xml" xpointer="help" />
538 </variablelist>
539
540 <para>See
541 <citerefentry><refentrytitle>systemd-udev-settle.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
542 for more information.</para>
543 </refsect2>
544
545 <refsect2><title>udevadm control <replaceable>option</replaceable></title>
546 <para>Modify the internal state of the running udev daemon.</para>
547 <variablelist>
548 <varlistentry>
549 <term><option>-e</option></term>
550 <term><option>--exit</option></term>
551 <listitem>
552 <para>Signal and wait for systemd-udevd to exit. No option except for
553 <option>--timeout</option> can be specified after this option.
554 Note that <filename>systemd-udevd.service</filename> contains
555 <option>Restart=always</option> and so as a result, this option restarts systemd-udevd.
556 If you want to stop <filename>systemd-udevd.service</filename>, please use the following:
557 <programlisting>systemctl stop systemd-udevd-control.socket systemd-udevd-kernel.socket systemd-udevd.service</programlisting>
558 </para>
559 </listitem>
560 </varlistentry>
561 <varlistentry>
562 <term><option>-l</option></term>
563 <term><option>--log-level=<replaceable>value</replaceable></option></term>
564 <listitem>
565 <para>Set the internal log level of
566 <filename>systemd-udevd</filename>. Valid values are the
567 numerical syslog priorities or their textual
568 representations: <option>emerg</option>,
569 <option>alert</option>, <option>crit</option>,
570 <option>err</option>, <option>warning</option>,
571 <option>notice</option>, <option>info</option>, and
572 <option>debug</option>.</para>
573 </listitem>
574 </varlistentry>
575 <varlistentry>
576 <term><option>-s</option></term>
577 <term><option>--stop-exec-queue</option></term>
578 <listitem>
579 <para>Signal systemd-udevd to stop executing new events. Incoming events
580 will be queued.</para>
581 </listitem>
582 </varlistentry>
583 <varlistentry>
584 <term><option>-S</option></term>
585 <term><option>--start-exec-queue</option></term>
586 <listitem>
587 <para>Signal systemd-udevd to enable the execution of events.</para>
588 </listitem>
589 </varlistentry>
590 <varlistentry>
591 <term><option>-R</option></term>
592 <term><option>--reload</option></term>
593 <listitem>
594 <para>Signal systemd-udevd to reload the rules files and other databases like the kernel
595 module index. Reloading rules and databases does not apply any changes to already
596 existing devices; the new configuration will only be applied to new events.</para>
597 </listitem>
598 </varlistentry>
599 <varlistentry>
600 <term><option>-p</option></term>
601 <term><option>--property=<replaceable>KEY</replaceable>=<replaceable>value</replaceable></option></term>
602 <listitem>
603 <para>Set a global property for all events.</para>
604 </listitem>
605 </varlistentry>
606 <varlistentry>
607 <term><option>-m</option></term>
608 <term><option>--children-max=</option><replaceable>value</replaceable></term>
609 <listitem>
610 <para>Set the maximum number of events, systemd-udevd will handle at the same time. When 0 is
611 specified, then the maximum is determined based on the system resources.</para>
612 </listitem>
613 </varlistentry>
614 <varlistentry>
615 <term><option>--ping</option></term>
616 <listitem>
617 <para>Send a ping message to systemd-udevd and wait for the reply. This may be useful to check that
618 systemd-udevd daemon is running.</para>
619 </listitem>
620 </varlistentry>
621 <varlistentry>
622 <term><option>-t</option></term>
623 <term><option>--timeout=</option><replaceable>seconds</replaceable></term>
624 <listitem>
625 <para>The maximum number of seconds to wait for a reply from systemd-udevd.</para>
626 </listitem>
627 </varlistentry>
628
629 <xi:include href="standard-options.xml" xpointer="help" />
630 </variablelist>
631 </refsect2>
632
633 <refsect2><title>udevadm monitor
634 <arg choice="opt"><replaceable>options</replaceable></arg>
635 </title>
636 <para>Listens to the kernel uevents and events sent out by a udev rule
637 and prints the devpath of the event to the console. It can be used to analyze the
638 event timing, by comparing the timestamps of the kernel uevent and the udev event.
639 </para>
640 <variablelist>
641 <varlistentry>
642 <term><option>-k</option></term>
643 <term><option>--kernel</option></term>
644 <listitem>
645 <para>Print the kernel uevents.</para>
646 </listitem>
647 </varlistentry>
648 <varlistentry>
649 <term><option>-u</option></term>
650 <term><option>--udev</option></term>
651 <listitem>
652 <para>Print the udev event after the rule processing.</para>
653 </listitem>
654 </varlistentry>
655 <varlistentry>
656 <term><option>-p</option></term>
657 <term><option>--property</option></term>
658 <listitem>
659 <para>Also print the properties of the event.</para>
660 </listitem>
661 </varlistentry>
662 <varlistentry>
663 <term><option>-s</option></term>
664 <term><option>--subsystem-match=<replaceable>string[/string]</replaceable></option></term>
665 <listitem>
666 <para>Filter kernel uevents and udev events by subsystem[/devtype]. Only events with a matching subsystem value will pass.
667 When this option is specified more than once, then each matching result is ORed, that is, all devices in the specified
668 subsystems are monitored.</para>
669 </listitem>
670 </varlistentry>
671 <varlistentry>
672 <term><option>-t</option></term>
673 <term><option>--tag-match=<replaceable>string</replaceable></option></term>
674 <listitem>
675 <para>Filter udev events by tag. Only udev events with a given tag attached will pass.
676 When this option is specified more than once, then each matching result is ORed, that is, devices which have one of the
677 specified tags are monitored.</para>
678 </listitem>
679 </varlistentry>
680
681 <xi:include href="standard-options.xml" xpointer="help" />
682 </variablelist>
683 </refsect2>
684
685 <refsect2><title>udevadm test
686 <arg choice="opt"><replaceable>options</replaceable></arg>
687 <arg choice="opt"><replaceable>devpath</replaceable>|<replaceable>file</replaceable>|<replaceable>unit</replaceable></arg>
688 </title>
689 <para>Simulate a udev event run for the given device, and print debug output.</para>
690 <variablelist>
691 <varlistentry>
692 <term><option>-a</option></term>
693 <term><option>--action=<replaceable>ACTION</replaceable></option></term>
694 <listitem>
695 <para>Type of event to be simulated. Possible actions are <literal>add</literal>,
696 <literal>remove</literal>, <literal>change</literal>, <literal>move</literal>,
697 <literal>online</literal>, <literal>offline</literal>, <literal>bind</literal>,
698 and <literal>unbind</literal>. Also, the special value <literal>help</literal> can be used
699 to list the possible actions. The default value is <literal>add</literal>.</para>
700 </listitem>
701 </varlistentry>
702 <varlistentry>
703 <term><option>-N</option></term>
704 <term><option>--resolve-names=<constant>early</constant>|<constant>late</constant>|<constant>never</constant></option></term>
705 <listitem>
706 <para>Specify when udevadm should resolve names of users
707 and groups. When set to <constant>early</constant> (the
708 default), names will be resolved when the rules are
709 parsed. When set to <constant>late</constant>, names will
710 be resolved for every event. When set to
711 <constant>never</constant>, names will never be resolved
712 and all devices will be owned by root.</para>
713 </listitem>
714 </varlistentry>
715
716 <xi:include href="standard-options.xml" xpointer="help" />
717 </variablelist>
718 </refsect2>
719
720 <refsect2><title>udevadm test-builtin
721 <arg choice="opt"><replaceable>options</replaceable></arg>
722 <arg><replaceable>command</replaceable></arg>
723 <arg choice="opt"><replaceable>devpath</replaceable>|<replaceable>file</replaceable>|<replaceable>unit</replaceable></arg>
724 </title>
725 <para>Run a built-in command <replaceable>COMMAND</replaceable>
726 for device <replaceable>DEVPATH</replaceable>, and print debug
727 output.</para>
728 <variablelist>
729 <varlistentry>
730 <term><option>-a</option></term>
731 <term><option>--action=<replaceable>ACTION</replaceable></option></term>
732 <listitem>
733 <para>Type of event to be simulated. Possible actions are <literal>add</literal>,
734 <literal>remove</literal>, <literal>change</literal>, <literal>move</literal>,
735 <literal>online</literal>, <literal>offline</literal>, <literal>bind</literal>,
736 and <literal>unbind</literal>. Also, the special value <literal>help</literal> can be used
737 to list the possible actions. The default value is <literal>add</literal>.</para>
738 </listitem>
739 </varlistentry>
740
741 <xi:include href="standard-options.xml" xpointer="help" />
742 <xi:include href="standard-options.xml" xpointer="version" />
743 </variablelist>
744 </refsect2>
745
746 <refsect2>
747 <title>udevadm verify
748 <arg choice="opt"><replaceable>options</replaceable></arg>
749 <arg choice="opt" rep="repeat"><replaceable>file</replaceable></arg>
750
751 </title>
752
753 <para>Verify syntactic, semantic, and stylistic correctness of udev rules files.</para>
754
755 <para>Positional arguments could be used to specify one or more files to check.
756 If no files are specified, the udev rules are read from the files located in
757 the same udev/rules.d directories that are processed by the udev daemon.</para>
758
759 <para>The exit status is <constant>0</constant> if all specified udev
760 rules files are syntactically, semantically, and stylistically correct,
761 and a non-zero error code otherwise.</para>
762
763 <variablelist>
764 <varlistentry>
765 <term><option>-N</option></term>
766 <term><option>--resolve-names=<constant>early</constant>|<constant>never</constant></option></term>
767 <listitem>
768 <para>Specify when udevadm should resolve names of users
769 and groups. When set to <constant>early</constant> (the
770 default), names will be resolved when the rules are
771 parsed. When set to <constant>never</constant>, names will
772 never be resolved.</para>
773 </listitem>
774 </varlistentry>
775
776 <varlistentry>
777 <term><option>--root=<replaceable>PATH</replaceable></option></term>
778 <listitem>
779 <para>When looking for udev rules files located in udev/rules.d directories,
780 operate on files underneath the specified root path <replaceable>PATH</replaceable>.</para>
781 </listitem>
782 </varlistentry>
783
784 <varlistentry>
785 <term><option>--no-summary</option></term>
786 <listitem>
787 <para>Do not show summary.</para>
788 </listitem>
789 </varlistentry>
790
791 <varlistentry>
792 <term><option>--no-style</option></term>
793 <listitem>
794 <para>Ignore style issues. When specified, even if style issues are found in udev rules files,
795 the exit status is <constant>0</constant> if no syntactic or semantic errors are found.</para>
796 </listitem>
797 </varlistentry>
798
799 <xi:include href="standard-options.xml" xpointer="help" />
800 </variablelist>
801 </refsect2>
802
803 <refsect2>
804 <title>udevadm wait
805 <arg choice="opt"><replaceable>options</replaceable></arg>
806 <arg choice="opt"><replaceable>device|syspath</replaceable></arg>
807
808 </title>
809
810 <para>Wait for devices or device symlinks being created and initialized by
811 <command>systemd-udevd</command>. Each device path must start with
812 <literal>/dev/</literal> or <literal>/sys/</literal>, e.g. <literal>/dev/sda</literal>,
813 <literal>/dev/disk/by-path/pci-0000:3c:00.0-nvme-1-part1</literal>,
814 <literal>/sys/devices/pci0000:00/0000:00:1f.6/net/eth0</literal>, or
815 <literal>/sys/class/net/eth0</literal>. This can take multiple devices. This may be useful for
816 waiting for devices being processed by <command>systemd-udevd</command> after e.g. partitioning
817 or formatting the devices.</para>
818
819 <variablelist>
820 <varlistentry>
821 <term><option>-t</option></term>
822 <term><option>--timeout=<replaceable>SECONDS</replaceable></option></term>
823 <listitem>
824 <para>Maximum number of seconds to wait for the specified devices or device symlinks being
825 created, initialized, or removed. The default value is <literal>infinity</literal>.</para>
826 </listitem>
827 </varlistentry>
828
829 <varlistentry>
830 <term><option>--initialized=<replaceable>BOOL</replaceable></option></term>
831 <listitem>
832 <para>Check if <command>systemd-udevd</command> initialized devices. Defaults to true. When
833 false, the command only checks if the specified devices exist. Set false to this setting if
834 there is no udev rules for the specified devices, as the devices will never be considered
835 as initialized in that case. See Initialized Devices section below for more details.</para>
836 </listitem>
837 </varlistentry>
838
839 <varlistentry>
840 <term><option>--removed</option></term>
841 <listitem>
842 <para>When specified, the command wait for devices being removed instead of created or
843 initialized. If this is specified, <option>--initialized=</option> will be ignored.</para>
844 </listitem>
845 </varlistentry>
846
847 <varlistentry>
848 <term><option>--settle</option></term>
849 <listitem>
850 <para>When specified, also watches the udev event queue, and wait for all queued events
851 being processed by <command>systemd-udevd</command>.</para>
852 </listitem>
853 </varlistentry>
854
855 <xi:include href="standard-options.xml" xpointer="help" />
856 </variablelist>
857 </refsect2>
858
859 <refsect2>
860 <title>udevadm lock
861 <arg choice="opt"><replaceable>options</replaceable></arg>
862 <arg choice="opt"><replaceable>command</replaceable></arg>
863
864 </title>
865
866 <para><command>udevadm lock</command> takes an (advisory) exclusive lock on a block device (or all
867 specified devices), as per <ulink url="https://systemd.io/BLOCK_DEVICE_LOCKING">Locking Block Device
868 Access</ulink> and invokes a program with the locks taken. When the invoked program exits the locks
869 are automatically released and its return value is propagated as exit code of <command>udevadm
870 lock</command>.</para>
871
872 <para>This tool is in particular useful to ensure that
873 <citerefentry><refentrytitle>systemd-udevd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
874 does not probe a block device while changes are made to it, for example partitions created or file
875 systems formatted. Note that many tools that interface with block devices natively support taking
876 relevant locks, see for example
877 <citerefentry project='man-pages'><refentrytitle>sfdisk</refentrytitle><manvolnum>8</manvolnum></citerefentry>'s
878 <option>--lock</option> switch.</para>
879
880 <para>The command expects at least one block device specified via <option>--device=</option> or
881 <option>--backing=</option>, and a command line to execute as arguments.</para>
882
883 <variablelist>
884 <varlistentry>
885 <term><option>--device=<replaceable>DEVICE</replaceable></option></term>
886 <term><option>-d <replaceable>DEVICE</replaceable></option></term>
887
888 <listitem><para>Takes a path to a device node of the device to lock. This switch may be used
889 multiple times (and in combination with <option>--backing=</option>) in order to lock multiple
890 devices. If a partition block device node is specified the containing "whole" block device is
891 automatically determined and used for the lock, as per the specification. If multiple devices are
892 specified, they are deduplicated, sorted by the major/minor of their device nodes and then locked
893 in order.</para>
894
895 <para>This switch must be used at least once, to specify at least one device to
896 lock. (Alternatively, use <option>--backing=</option>, see below.)</para></listitem>
897 </varlistentry>
898
899 <varlistentry>
900 <term><option>--backing=<replaceable>PATH</replaceable></option></term>
901 <term><option>-b <replaceable>PATH</replaceable></option></term>
902
903 <listitem><para>If a path to a device node is specified, identical to
904 <option>--device=</option>. However, this switch alternatively accepts a path to a regular file or
905 directory, in which case the block device of the file system the file/directory resides on is
906 automatically determined and used as if it was specified with
907 <option>--device=</option>.</para></listitem>
908 </varlistentry>
909
910 <varlistentry>
911 <term><option>--timeout=<replaceable>SECS</replaceable></option></term>
912 <term><option>-t <replaceable>SECS</replaceable></option></term>
913
914 <listitem><para>Specifies how long to wait at most until all locks can be taken. Takes a value in
915 seconds, or in the usual supported time units, see
916 <citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry>. If
917 specified as zero the lock is attempted and if not successful the invocation will immediately
918 fail. If passed as <literal>infinity</literal> (the default) the invocation will wait indefinitely
919 until the lock can be acquired. If the lock cannot be taken in the specified time the specified
920 command will not be executed and the invocation will fail.</para></listitem>
921 </varlistentry>
922
923 <varlistentry>
924 <term><option>--print</option></term>
925 <term><option>-p</option></term>
926
927 <listitem><para>Instead of locking the specified devices and executing a command, just print the
928 device paths that would be locked, and execute no command. This command is useful to determine
929 the "whole" block device in case a partition block device is specified. The devices will be sorted
930 by their device node major number as primary ordering key and the minor number as secondary
931 ordering key (i.e. they are shown in the order they'd be locked). Note that the number of lines
932 printed here can be less than the number of <option>--device=</option> and
933 <option>--backing=</option> switches specified in case these resolve to the same "whole"
934 devices.</para></listitem>
935 </varlistentry>
936
937 <xi:include href="standard-options.xml" xpointer="help" />
938 </variablelist>
939 </refsect2>
940 </refsect1>
941
942 <refsect1>
943 <title>Initialized Devices</title>
944
945 <para>Initialized devices are those for which at least one udev rule already completed execution
946 – for any action but <literal>remove</literal> — that set a property or other device setting (and
947 thus has an entry in the udev device database). Devices are no longer considered initialized if a
948 <literal>remove</literal> action is seen for them (which removes their entry in the udev device
949 database). Note that devices that have no udev rules are never considered initialized, but might
950 still be announced via the sd-device API (or similar).</para>
951 </refsect1>
952
953 <refsect1>
954 <title>Example</title>
955
956 <example>
957 <title>Format a File System</title>
958
959 <para>Take a lock on the backing block device while creating a file system, to ensure that
960 <command>systemd-udevd</command> doesn't probe or announce the new superblock before it is
961 comprehensively written:</para>
962
963 <programlisting># udevadm lock --device=/dev/sda1 mkfs.ext4 /dev/sda1</programlisting>
964 </example>
965
966 <example>
967 <title>Format a RAID File System</title>
968
969 <para>Similar, but take locks on multiple devices at once:</para>
970
971 <programlisting># udevadm lock --device=/dev/sda1 --device=/dev/sdb1 mkfs.btrfs /dev/sda1 /dev/sdb1</programlisting>
972 </example>
973
974 <example>
975 <title>Copy in a File System</title>
976
977 <para>Take a lock on the backing block device while copying in a prepared file system image, to ensure
978 that <command>systemd-udevd</command> doesn't probe or announce the new superblock before it is fully
979 written:</para>
980
981 <programlisting># udevadm lock -d /dev/sda1 dd if=fs.raw of=/dev/sda1</programlisting>
982 </example>
983 </refsect1>
984
985 <refsect1>
986 <title>See Also</title>
987 <para><citerefentry>
988 <refentrytitle>udev</refentrytitle><manvolnum>7</manvolnum>
989 </citerefentry>,
990 <citerefentry>
991 <refentrytitle>systemd-udevd.service</refentrytitle><manvolnum>8</manvolnum>
992 </citerefentry></para>
993 </refsect1>
994 </refentry>