[systemd-devel] systemd-udevd and services with DefaultDependencies=no

Andrei Borzenkov arvidjaar at gmail.com
Mon Nov 25 13:50:49 UTC 2024


On Mon, Nov 25, 2024 at 4:39 PM Thomas HUMMEL <thomas.hummel at pasteur.fr> wrote:
>
> Hello,
>
> I've got a somehow silly question:
>
> Am I right to think that a service unit I wrote meant to format and
> mount a localdisk at boot having the following properties :
>
> Wants=local-fs.target
> Before=local-fs.target
>
> + DefaultDepenencies=no may be racing against udevd in a way the device
> (/dev/nvme0) would not be there yet ?
>

Yes.

> If so, would adding After=systemd-udevd suffice ?
>

No.

Either invoke your service from within udev rule (SYSTEMD_WANTS or
even systemctl start), or configure your service with

Requires=dev-nvme0.device
After=dev-nvme0.device

Actually, you probably want to do it even when invoking by udev rules.

This assumes that /dev/nvme0 is reasonably stable. You may want to use
some other available /dev/disk/by-... stable alias.


More information about the systemd-devel mailing list