1UDEVADM(8)                          udevadm                         UDEVADM(8)
2
3
4

NAME

6       udevadm - udev management tool
7

SYNOPSIS

9       udevadm [--debug] [--version] [--help]
10
11       udevadm info [options] [devpath]
12
13       udevadm trigger [options] [devpath]
14
15       udevadm settle [options]
16
17       udevadm control option
18
19       udevadm monitor [options]
20
21       udevadm test [options] devpath
22
23       udevadm test-builtin [options] command devpath
24
25       udevadm wait [options] device|syspath
26
27       udevadm lock [options] command
28

DESCRIPTION

30       udevadm expects a command and command specific options. It controls the
31       runtime behavior of systemd-udevd, requests kernel events, manages the
32       event queue, and provides simple debugging mechanisms.
33

OPTIONS

35       -d, --debug
36           Print debug messages to standard error. This option is implied in
37           udevadm test and udevadm test-builtin commands.
38
39       -h, --help
40           Print a short help text and exit.
41
42   udevadm info [options] [devpath|file|unit...]
43       Query the udev database for device information.
44
45       Positional arguments should be used to specify one or more devices.
46       Each one may be a device name (in which case it must start with /dev/),
47       a sys path (in which case it must start with /sys/), or a systemd
48       device unit name (in which case it must end with ".device", see
49       systemd.device(5)).
50
51       -q, --query=TYPE
52           Query the database for the specified type of device data. Valid
53           TYPEs are: name, symlink, path, property, all.
54
55       --property=NAME
56           When showing device properties using the --query=property option,
57           limit display to properties specified in the argument. The argument
58           should be a comma-separated list of property names. If not
59           specified, all known properties are shown.
60
61       --value
62           When showing device properties using the --query=property option,
63           print only their values, and skip the property name and "=".
64
65           Cannot be used together with -x/--export or -P/--export-prefix.
66
67       -p, --path=DEVPATH
68           The /sys/ path of the device to query, e.g.
69           [/sys/]/class/block/sda. This option is an alternative to the
70           positional argument with a /sys/ prefix.  udevadm info
71           --path=/class/block/sda is equivalent to udevadm info
72           /sys/class/block/sda.
73
74       -n, --name=FILE
75           The name of the device node or a symlink to query, e.g.
76           [/dev/]/sda. This option is an alternative to the positional
77           argument with a /dev/ prefix.  udevadm info --name=sda is
78           equivalent to udevadm info /dev/sda.
79
80       -r, --root
81           Print absolute paths in name or symlink query.
82
83       -a, --attribute-walk
84           Print all sysfs properties of the specified device that can be used
85           in udev rules to match the specified device. It prints all devices
86           along the chain, up to the root of sysfs that can be used in udev
87           rules.
88
89       -t, --tree
90           Display a sysfs tree. This recursively iterates through the sysfs
91           hierarchy and displays it in a tree structure. If a path is
92           specified only the subtree below and its parent directories are
93           shown. This will show both device and subsystem items.
94
95       -x, --export
96           Print output as key/value pairs. Values are enclosed in single
97           quotes. This takes effects only when --query=property or
98           --device-id-of-file=FILE is specified.
99
100       -P, --export-prefix=NAME
101           Add a prefix to the key name of exported values. This implies
102           --export.
103
104       -d, --device-id-of-file=FILE
105           Print major/minor numbers of the underlying device, where the file
106           lives on. If this is specified, all positional arguments are
107           ignored.
108
109       -e, --export-db
110           Export the content of the udev database.
111
112       -c, --cleanup-db
113           Cleanup the udev database.
114
115       -w[SECONDS], --wait-for-initialization[=SECONDS]
116           Wait for device to be initialized. If argument SECONDS is not
117           specified, the default is to wait forever.
118
119       -h, --help
120           Print a short help text and exit.
121
122       --no-pager
123           Do not pipe output into a pager.
124
125       The generated output shows the current device database entry in a terse
126       format. Each line shown is prefixed with one of the following
127       characters:
128
129       Table 1. udevadm info output prefixes
130       ┌───────┬────────────────────────────┐
131Prefix Meaning                    
132       ├───────┼────────────────────────────┤
133       │"P:"   │ Device path in /sys/       │
134       ├───────┼────────────────────────────┤
135       │"M:"   │ Device name in /sys/ (i.e. │
136       │       │ the last component of      │
137       │       │ "P:")                      │
138       ├───────┼────────────────────────────┤
139       │"R:"   │ Device number in /sys/     │
140       │       │ (i.e. the numeric suffix   │
141       │       │ of the last component of   │
142       │       │ "P:")                      │
143       ├───────┼────────────────────────────┤
144       │"U:"   │ Kernel subsystem           │
145       ├───────┼────────────────────────────┤
146       │"T:"   │ Kernel device type within  │
147       │       │ subsystem                  │
148       ├───────┼────────────────────────────┤
149       │"D:"   │ Kernel device node         │
150       │       │ major/minor                │
151       ├───────┼────────────────────────────┤
152       │"I:"   │ Network interface index    │
153       ├───────┼────────────────────────────┤
154       │"N:"   │ Kernel device node name    │
155       ├───────┼────────────────────────────┤
156       │"L:"   │ Device node symlink        │
157       │       │ priority                   │
158       ├───────┼────────────────────────────┤
159       │"S:"   │ Device node symlink        │
160       ├───────┼────────────────────────────┤
161       │"Q:"   │ Block device sequence      │
162       │       │ number (DISKSEQ)           │
163       ├───────┼────────────────────────────┤
164       │"V:"   │ Attached driver            │
165       ├───────┼────────────────────────────┤
166       │"E:"   │ Device property            │
167       └───────┴────────────────────────────┘
168
169   udevadm trigger [options] [devpath|file|unit]
170       Request device events from the kernel. Primarily used to replay events
171       at system coldplug time.
172
173       Takes device specifications as positional arguments. See the
174       description of info above.
175
176       -v, --verbose
177           Print the list of devices which will be triggered.
178
179       -n, --dry-run
180           Do not actually trigger the event.
181
182       -q, --quiet
183           Suppress error logging in triggering events.
184
185       -t, --type=TYPE
186           Trigger a specific type of devices. Valid types are "all",
187           "devices", and "subsystems". The default value is "devices".
188
189       -c, --action=ACTION
190           Type of event to be triggered. Possible actions are "add",
191           "remove", "change", "move", "online", "offline", "bind", and
192           "unbind". Also, the special value "help" can be used to list the
193           possible actions. The default value is "change".
194
195       --prioritized-subsystem=SUBSYSTEM[,SUBSYSTEM...]
196           Takes a comma separated list of subsystems. When triggering events
197           for devices, the devices from the specified subsystems and their
198           parents are triggered first. For example, if
199           --prioritized-subsystem=block,net, then firstly all block devices
200           and their parents are triggered, in the next all network devices
201           and their parents are triggered, and lastly the other devices are
202           triggered. This option can be specified multiple times, and in that
203           case the lists of the subsystems will be merged. That is,
204           --prioritized-subsystem=block --prioritized-subsystem=net is
205           equivalent to --prioritized-subsystem=block,net.
206
207       -s, --subsystem-match=SUBSYSTEM
208           Trigger events for devices which belong to a matching subsystem.
209           This option supports shell style pattern matching. When this option
210           is specified more than once, then each matching result is ORed,
211           that is, all the devices in each subsystem are triggered.
212
213       -S, --subsystem-nomatch=SUBSYSTEM
214           Do not trigger events for devices which belong to a matching
215           subsystem. This option supports shell style pattern matching. When
216           this option is specified more than once, then each matching result
217           is ANDed, that is, devices which do not match all specified
218           subsystems are triggered.
219
220       -a, --attr-match=ATTRIBUTE=VALUE
221           Trigger events for devices with a matching sysfs attribute. If a
222           value is specified along with the attribute name, the content of
223           the attribute is matched against the given value using shell style
224           pattern matching. If no value is specified, the existence of the
225           sysfs attribute is checked. When this option is specified multiple
226           times, then each matching result is ANDed, that is, only devices
227           which have all specified attributes are triggered.
228
229       -A, --attr-nomatch=ATTRIBUTE=VALUE
230           Do not trigger events for devices with a matching sysfs attribute.
231           If a value is specified along with the attribute name, the content
232           of the attribute is matched against the given value using shell
233           style pattern matching. If no value is specified, the existence of
234           the sysfs attribute is checked. When this option is specified
235           multiple times, then each matching result is ANDed, that is, only
236           devices which have none of the specified attributes are triggered.
237
238       -p, --property-match=PROPERTY=VALUE
239           Trigger events for devices with a matching property value. This
240           option supports shell style pattern matching. When this option is
241           specified more than once, then each matching result is ORed, that
242           is, devices which have one of the specified properties are
243           triggered.
244
245       -g, --tag-match=TAG
246           Trigger events for devices with a matching tag. When this option is
247           specified multiple times, then each matching result is ANDed, that
248           is, devices which have all specified tags are triggered.
249
250       -y, --sysname-match=NAME
251           Trigger events for devices for which the last component (i.e. the
252           filename) of the /sys/ path matches the specified PATH. This option
253           supports shell style pattern matching. When this option is
254           specified more than once, then each matching result is ORed, that
255           is, all devices which have any of the specified NAME are triggered.
256
257       --name-match=NAME
258           Trigger events for devices with a matching device path. When this
259           option is specified more than once, then each matching result is
260           ORed, that is, all specified devices are triggered.
261
262       -b, --parent-match=SYSPATH
263           Trigger events for all children of a given device. When this option
264           is specified more than once, then each matching result is ORed,
265           that is, all children of each specified device are triggered.
266
267       --initialized-match, --initialized-nomatch
268           When --initialized-match is specified, trigger events for devices
269           that are already initialized by systemd-udevd, and skip devices
270           that are not initialized yet.
271
272           When --initialized-nomatch is specified, trigger events for devices
273           that are not initialized by systemd-udevd yet, and skip devices
274           that are already initialized.
275
276           Typically, it is essential that applications which intend to use
277           such a match, make sure a suitable udev rule is installed that sets
278           at least one property on devices that shall be matched. See also
279           Initialized Devices section below for more details.
280
281           WARNING: --initialized-nomatch can potentially save a significant
282           amount of time compared to re-triggering all devices in the system
283           and e.g. can be used to optimize boot time. However, this is not
284           safe to be used in a boot sequence in general. Especially, when
285           udev rules for a device depend on its parent devices (e.g.  "ATTRS"
286           or "IMPORT{parent}" keys, see udev(7) for more details), the final
287           state of the device becomes easily unstable with this option.
288
289       -w, --settle
290           Apart from triggering events, also waits for those events to
291           finish. Note that this is different from calling udevadm settle.
292           udevadm settle waits for all events to finish. This option only
293           waits for events triggered by the same command to finish.
294
295       --uuid
296           Trigger the synthetic device events, and associate a randomized
297           UUID with each. These UUIDs are printed to standard output, one
298           line for each event. These UUIDs are included in the uevent
299           environment block (in the "SYNTH_UUID=" property) and may be used
300           to track delivery of the generated events.
301
302       --wait-daemon[=SECONDS]
303           Before triggering uevents, wait for systemd-udevd daemon to be
304           initialized. Optionally takes timeout value. Default timeout is 5
305           seconds. This is equivalent to invoke invoking udevadm control
306           --ping before udevadm trigger.
307
308       -h, --help
309           Print a short help text and exit.
310
311       In addition, optional positional arguments can be used to specify
312       device names or sys paths. They must start with /dev/ or /sys/
313       respectively.
314
315   udevadm settle [options]
316       Watches the udev event queue, and exits if all current events are
317       handled.
318
319       -t, --timeout=SECONDS
320           Maximum number of seconds to wait for the event queue to become
321           empty. The default value is 120 seconds. A value of 0 will check if
322           the queue is empty and always return immediately. A non-zero value
323           will return an exit code of 0 if queue became empty before timeout
324           was reached, non-zero otherwise.
325
326       -E, --exit-if-exists=FILE
327           Stop waiting if file exists.
328
329       -h, --help
330           Print a short help text and exit.
331
332       See systemd-udev-settle.service(8) for more information.
333
334   udevadm control option
335       Modify the internal state of the running udev daemon.
336
337       -e, --exit
338           Signal and wait for systemd-udevd to exit. No option except for
339           --timeout can be specified after this option. Note that
340           systemd-udevd.service contains Restart=always and so as a result,
341           this option restarts systemd-udevd. If you want to stop
342           systemd-udevd.service, please use the following:
343
344               systemctl stop systemd-udevd-control.socket systemd-udevd-kernel.socket systemd-udevd.service
345
346
347       -l, --log-level=value
348           Set the internal log level of systemd-udevd. Valid values are the
349           numerical syslog priorities or their textual representations:
350           emerg, alert, crit, err, warning, notice, info, and debug.
351
352       -s, --stop-exec-queue
353           Signal systemd-udevd to stop executing new events. Incoming events
354           will be queued.
355
356       -S, --start-exec-queue
357           Signal systemd-udevd to enable the execution of events.
358
359       -R, --reload
360           Signal systemd-udevd to reload the rules files and other databases
361           like the kernel module index. Reloading rules and databases does
362           not apply any changes to already existing devices; the new
363           configuration will only be applied to new events.
364
365       -p, --property=KEY=value
366           Set a global property for all events.
367
368       -m, --children-max=value
369           Set the maximum number of events, systemd-udevd will handle at the
370           same time.
371
372       --ping
373           Send a ping message to systemd-udevd and wait for the reply. This
374           may be useful to check that systemd-udevd daemon is running.
375
376       -t, --timeout=seconds
377           The maximum number of seconds to wait for a reply from
378           systemd-udevd.
379
380       -h, --help
381           Print a short help text and exit.
382
383   udevadm monitor [options]
384       Listens to the kernel uevents and events sent out by a udev rule and
385       prints the devpath of the event to the console. It can be used to
386       analyze the event timing, by comparing the timestamps of the kernel
387       uevent and the udev event.
388
389       -k, --kernel
390           Print the kernel uevents.
391
392       -u, --udev
393           Print the udev event after the rule processing.
394
395       -p, --property
396           Also print the properties of the event.
397
398       -s, --subsystem-match=string[/string]
399           Filter kernel uevents and udev events by subsystem[/devtype]. Only
400           events with a matching subsystem value will pass. When this option
401           is specified more than once, then each matching result is ORed,
402           that is, all devices in the specified subsystems are monitored.
403
404       -t, --tag-match=string
405           Filter udev events by tag. Only udev events with a given tag
406           attached will pass. When this option is specified more than once,
407           then each matching result is ORed, that is, devices which have one
408           of the specified tags are monitored.
409
410       -h, --help
411           Print a short help text and exit.
412
413   udevadm test [options] [devpath|file|unit]
414       Simulate a udev event run for the given device, and print debug output.
415
416       -a, --action=ACTION
417           Type of event to be simulated. Possible actions are "add",
418           "remove", "change", "move", "online", "offline", "bind", and
419           "unbind". Also, the special value "help" can be used to list the
420           possible actions. The default value is "add".
421
422       -N, --resolve-names=early|late|never
423           Specify when udevadm should resolve names of users and groups. When
424           set to early (the default), names will be resolved when the rules
425           are parsed. When set to late, names will be resolved for every
426           event. When set to never, names will never be resolved and all
427           devices will be owned by root.
428
429       -h, --help
430           Print a short help text and exit.
431
432   udevadm test-builtin [options] [command] [devpath|file|unit]
433       Run a built-in command COMMAND for device DEVPATH, and print debug
434       output.
435
436       -a, --action=ACTION
437           Type of event to be simulated. Possible actions are "add",
438           "remove", "change", "move", "online", "offline", "bind", and
439           "unbind". Also, the special value "help" can be used to list the
440           possible actions. The default value is "add".
441
442       -h, --help
443           Print a short help text and exit.
444
445   udevadm wait [options] [device|syspath] ...
446       Wait for devices or device symlinks being created and initialized by
447       systemd-udevd. Each device path must start with "/dev/" or "/sys/",
448       e.g.  "/dev/sda", "/dev/disk/by-path/pci-0000:3c:00.0-nvme-1-part1",
449       "/sys/devices/pci0000:00/0000:00:1f.6/net/eth0", or
450       "/sys/class/net/eth0". This can take multiple devices. This may be
451       useful for waiting for devices being processed by systemd-udevd after
452       e.g. partitioning or formatting the devices.
453
454       -t, --timeout=SECONDS
455           Maximum number of seconds to wait for the specified devices or
456           device symlinks being created, initialized, or removed. The default
457           value is "infinity".
458
459       --initialized=BOOL
460           Check if systemd-udevd initialized devices. Defaults to true. When
461           false, the command only checks if the specified devices exist. Set
462           false to this setting if there is no udev rules for the specified
463           devices, as the devices will never be considered as initialized in
464           that case. See Initialized Devices section below for more details.
465
466       --removed
467           When specified, the command wait for devices being removed instead
468           of created or initialized. If this is specified, --initialized=
469           will be ignored.
470
471       --settle
472           When specified, also watches the udev event queue, and wait for all
473           queued events being processed by systemd-udevd.
474
475       -h, --help
476           Print a short help text and exit.
477
478   udevadm lock [options] [command] ...
479       udevadm lock takes an (advisory) exclusive lock on a block device (or
480       all specified devices), as per Locking Block Device Access[1] and
481       invokes a program with the locks taken. When the invoked program exits
482       the locks are automatically released and its return value is propagated
483       as exit code of udevadm lock.
484
485       This tool is in particular useful to ensure that systemd-
486       udevd.service(8) does not probe a block device while changes are made
487       to it, for example partitions created or file systems formatted. Note
488       that many tools that interface with block devices natively support
489       taking relevant locks, see for example sfdisk(8)'s --lock switch.
490
491       The command expects at least one block device specified via --device=
492       or --backing=, and a command line to execute as arguments.
493
494       --device=DEVICE, -d DEVICE
495           Takes a path to a device node of the device to lock. This switch
496           may be used multiple times (and in combination with --backing=) in
497           order to lock multiple devices. If a partition block device node is
498           specified the containing "whole" block device is automatically
499           determined and used for the lock, as per the specification. If
500           multiple devices are specified, they are deduplicated, sorted by
501           the major/minor of their device nodes and then locked in order.
502
503           This switch must be used at least once, to specify at least one
504           device to lock. (Alternatively, use --backing=, see below.)
505
506       --backing=PATH, -b PATH
507           If a path to a device node is specified, identical to --device=.
508           However, this switch alternatively accepts a path to a regular file
509           or directory, in which case the block device of the file system the
510           file/directory resides on is automatically determined and used as
511           if it was specified with --device=.
512
513       --timeout=SECS, -t SECS
514           Specifies how long to wait at most until all locks can be taken.
515           Takes a value in seconds, or in the usual supported time units, see
516           systemd.time(7). If specified as zero the lock is attempted and if
517           not successful the invocation will immediately fail. If passed as
518           "infinity" (the default) the invocation will wait indefinitely
519           until the lock can be acquired. If the lock cannot be taken in the
520           specified time the specified command will not be executed and the
521           invocation will fail.
522
523       --print, -p
524           Instead of locking the specified devices and executing a command,
525           just print the device paths that would be locked, and execute no
526           command. This command is useful to determine the "whole" block
527           device in case a partition block device is specified. The devices
528           will be sorted by their device node major number as primary
529           ordering key and the minor number as secondary ordering key (i.e.
530           they are shown in the order they'd be locked). Note that the number
531           of lines printed here can be less than the number of --device= and
532           --backing= switches specified in case these resolve to the same
533           "whole" devices.
534
535       -h, --help
536           Print a short help text and exit.
537

INITIALIZED DEVICES

539       Initialized devices are those for which at least one udev rule already
540       completed execution – for any action but "remove" — that set a property
541       or other device setting (and thus has an entry in the udev device
542       database). Devices are no longer considered initialized if a "remove"
543       action is seen for them (which removes their entry in the udev device
544       database). Note that devices that have no udev rules are never
545       considered initialized, but might still be announced via the sd-device
546       API (or similar).
547

EXAMPLE

549       Example 1. Format a File System
550
551       Take a lock on the backing block device while creating a file system,
552       to ensure that systemd-udevd doesn't probe or announce the new
553       superblock before it is comprehensively written:
554
555           # udevadm lock --device=/dev/sda1 mkfs.ext4 /dev/sda1
556
557       Example 2. Format a RAID File System
558
559       Similar, but take locks on multiple devices at once:
560
561           # udevadm lock --device=/dev/sda1 --device=/dev/sdb1 mkfs.btrfs /dev/sda1 /dev/sdb1
562
563       Example 3. Copy in a File System
564
565       Take a lock on the backing block device while copying in a prepared
566       file system image, to ensure that systemd-udevd doesn't probe or
567       announce the new superblock before it is fully written:
568
569           # udevadm lock -d /dev/sda1 dd if=fs.raw of=/dev/sda1
570

SEE ALSO

572       udev(7), systemd-udevd.service(8)
573

NOTES

575        1. Locking Block Device Access
576           https://systemd.io/BLOCK_DEVICE_LOCKING
577
578
579
580systemd 253                                                         UDEVADM(8)
Impressum