4

I've been reading up on systemd and doing a little probing regarding device unit-files.

According to the man pages:

systemd will dynamically create device units for all kernel devices that are marked with the "systemd" udev tag (by default all block and network devices, and a few others). This may be used to define dependencies between devices and other units. To tag a udev device, use "TAG+="systemd"" in the udev rules file, see udev(7) for details.

I have tried looking in /lib/systemd/system, as described in the Debian Wiki:

Unit files provided by Debian are located in the /lib/systemd/system directory.

But these are nowhere to be found.

Yet

~$ sudo systemctl list-units --type=device

does display devices units (such as disks, sound card, ethernet controller etc...)

I would like to know where I can find device unit files in Debian? or if these do not exist then why not and how is systemd handling these units in Debian?

Any clarifications/comments/insights would be much appreciated.

1 Answer 1

8

The answer is in the first sentence you quoted. "systemd will dynamically create device units". It says "create", not just "start". Through integration with the udev daemon, once the kernel tells udev about a new device, a .device unit will be synthesized on the fly. (And similarly, if a device disappears, the .device unit will be destroyed as well.)

It is the unit itself that gets dynamically created (so it only exists in memory inside systemd), not a unit file. So it's basically the same mechanism as for dynamically created .scope units or transient .service units (and unlike .mount unit files that are created by a generator based on /etc/fstab).

There's thus no unit file anywhere on disk. You can see that systemctl status some.device doesn't refer to any unit files and systemctl show some.device doesn't list any FragmentPath.

1
  • Exactly it does not reffer to any unit file I noticed that while I was probing systemctl device units. Thanks a lot for the clarification. This answer is spot on! Commented Mar 4, 2020 at 15:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .