[systemd-devel] /etc/fstab dependences migrated between units due to automount feature

Daniel Otero otero.o.daniel at gmail.com
Sun Sep 1 23:30:13 UTC 2019


On Sat, Aug 31, 2019 at 1:44 AM Michael Chapman <mike at very.puzzling.org> wrote:
> Even with `noauto`, the manual dependency isn't needed. The dependencies I
> described were all about the block device, not the filesystem, so when the
> filesystem is actually mounted isn't relevant.

Probably, I didn't explain myself right, so let me try to explain it
again. This is my /etc/crypttab:

    dataA          UUID=96709c5c-6a09-4c5f-9a0c-911c4d5fb994    /key1    noauto
    dataB          UUID=3b8f42f4-41d9-49eb-ba8c-6900ba524cb5   /key2    noauto

My initial /etc/fstab entry was:

    /dev/mapper/dataA                /Data        btrfs
noauto,nofail,rw,relatime,space_cache    0 0

But with that configuration, only the dataA crypto device is unlocked
on mount. So I added the
`x-systemd.requires=systemd-cryptsetup at dataB.service` mount option,
and now everything works.

    /dev/mapper/dataA                /Data        btrfs
noauto,nofail,rw,relatime,space_cache,x-systemd.requires=systemd-cryptsetup at dataB.service
   0 0

With this setup, no disk is decrypted on boot, and only when I try to
mount the Data partition, the partitions are decrypted and the
filesystem is correctly mounted. Which is exactly what I want.

The problem arises when I try to add the icing on the cake:
`x-systemd.automount`. This option makes the partitions be decrypted
on boot, which is not what I would like.

> When these fstab options were added, the use case that originally brought
> them up was dependencies between mount units:
>
>   https://bugzilla.redhat.com/show_bug.cgi?id=812826
>   https://bugzilla.redhat.com/show_bug.cgi?id=1164334
>   https://github.com/systemd/systemd/commit/3519d230c8bafe834b2dac26ace49fcfba139823
>
> If a particular fstab entry has both x-systemd.automount and
> x-systemd.requires=something.mount, then the Requires= dependency would
> have to be applied on the corresponding automount unit.

That's the part I don't understand. If the dependencies are between
mount units, why are they fired on boot, and not when the actual mount
occurs?

> So I'm not sure how systemd can cater for your request. It would be weird
> for dependencies on only _some_ unit types to be transferred from the
> mount unit to the automount unit.

I guess that if in some cases the dependencies need to be on the
automount side, the only solution I see is having a different fstab
options to affect the mount units. But I understand that maybe that's
not to everyone's liking.

Anyway, thanks a lot for your time.


More information about the systemd-devel mailing list