Score:0

How can I cause systemd to wait starting a unit until a certain condition is fullfilled

cn flag

I'm still struggling to understand boot sequence dependency configuration in systemd unit files. I've read the manual (systemd.unit).

I tried to add dependencies using the After= and Requires= lines to my unit configuration file. However it still regulary fails during system startup because systemd starts it too early before a needed resource (in my case a LUKS encrypted volume) has become available. In my tests it looked like systemd is ignoring these configuration lines. The content of these lines is also not listed when using the command:

systemctl list-dependencies

to check for configured dependencies. Example: My device volume is /dev/dm-6. How can I specify that systemd should wait with starting my unit until this device has finally appeared?

If I start my unit manually in a terminal window after boot using this command:

systemctl start name_of_my_unit

it works fine.

Score:0
gy flag

I am also facing something similar where the service is getting started before the Luks device under /dev/mapper is getting created.

When I do "systemctl start myservice" it works fine.

Score:0
cn flag

RequiresMountsFor=/mnt/volume

Where the path is in the required mount point.

pefu avatar
cn flag
I can't use RequiresMountFor= because in my case the problem is the device, which is only mounted later on within the unit. More specific: The LUKS device and the cryptsetup is handled in a Xen dom0 domain and the systemd unit in question is starting a virtual machine to which this device has to be attached to before starting.
Score:0
es flag

systemd.device might be what you want

A unit configuration file whose name ends in ".device" encodes information about a device unit as exposed in the sysfs/udev(7) device tree. This may be used to define dependencies between devices and other units. ... Device units are named after the /sys/ and /dev/ paths they control. Example: the device /dev/sda5 is exposed in systemd as dev-sda5.device

Links

Score:0
sa flag

May be you should check ExecStartPre= and ExecCondition=. Looks like they able to solve your issue.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.