[systemd-devel] mounts with "nofail" can be unmounted on shutdown before "After=*-fs.target" units

Lennart Poettering lennart at poettering.net
Mon Jul 1 12:21:03 UTC 2024


On Sa, 29.06.24 19:26, MichaIng (micha at dietpi.com) wrote:

> Hey guys, I have question regarding a certain behaviour of the systemd mount
> generator.
>
> Mounts do not have `Before=*-fs.target` if the `nofail` mount option is
> added to their `/etc/fstab` entry.
>
> From the man page I see that this is intended behaviour:
> - https://www.freedesktop.org/software/systemd/man/latest/systemd.mount.html#Default%20Dependencies
> - https://www.freedesktop.org/software/systemd/man/latest/systemd.mount.html#noauto
>
> First of all, I see the reason why it seems to be not important for mounts
> to start before certain targets, if one explicitly declares that it is okay
> for them to fail. But I do not see a downside of adding `Before=*-fs.target`
> either.

To be able to mount a block-based munt we need to wait for that device
to show up first. That can take ages, and given you used "nofail" it
might even be expected to fail entirely (i.e. timeout). But we
shouldn#t delay things for stuff that quite possibly can fail.

Similar, a mount make take ages if network bound and something is
wrong with the network.

Hence "nofail" disables the ordering, it means "if this mount is there
or not doesnt really matter for anything else". Both at startup and at
shutdown, and all the time inbetween

Lennart

--
Lennart Poettering, Berlin


More information about the systemd-devel mailing list