Debian – No Device Unit Files in Systemd

debiansystemdsystemd-unit

I've been reading up in 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 no where 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.

Thanks
MK. Rahal

Best Answer

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.

Related Question