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