I’m setting up a recovery service that re-encrypts a LUKS volume (mmcblk0p2
) if systemd-cryptsetup@data.service
fails. This service, encrypt@data.service
, runs a script that exists with 1
whenever the volume is encrypted. The service contains:
OnSuccess=fsck@dev-mapper-%i.service
OnFailure=systemd-cryptsetup@%i.service
Now this works to the part that the device mapper is created if I truncate the partition (dd if=/dev/zero of=/dev/mmcblk0p2
) and reboot, but fsck@dev-mapper-data.service
BindsTo
dev-mapper-data.device
and systemd keeps saying the dependency is unmet whilst the mapper is available as /dev/mapper/data
.
$ ls -l /dev/mapper/data
lrwxrwxrwx 1 root root 7 Aug 7 12:07 /dev/mapper/data -> ../dm-1
$ systemctl list-dependencies fsck@dev-mapper-data.service | cat
fsck@dev-mapper-data.service
○ ├─dev-mapper-data.device
● ├─encrypt@data.service
I’ve read I can add a udev tag to make systemd recognize the device, but my rules seem to do nothing, nor does it react to udevadm trigger /dev/mapper/data
.
KERNEL=="dm-[0-9]", SUBSYSTEM=="block", TAG+="systemd"
What am I missing or doing wrong?