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

Matt Kinni matt at cipixia.com
Thu Aug 22 13:14:23 UTC 2024


Hi Micha,

On 2024-07-01 at 06:09 (-0700), MichaIng wrote:
> Basically, what I am missing, is a way to have mounts attempted at boot,
> properly ordered into boot schedule, without affecting the following
> boot (and shutdown) schedule in any way on failure, but have them
> properly ordered into shutdown cycled when their mount succeeded, or if
> they were manually mounted later.
> 

I've faced longtime issues where sometimes my nfs mounts would attempt
to unmount themselves at shutdown before the user session ends (ie. out
of order) thereby hanging the shutdown, but I never drew the connection
to the "nofail" parameter before I read your message (and I used that on
all my mounts). This caused me to re-evaluate my /etc/fstab and come up
with a better setup.

I now have things like this, which I think accomplishes the desired result:

fileserv.home:/homedirs/matt   /home/matt       nfs proto=tcp,nfsvers=4.2,sec=krb5,rw,async,dirsync,acdirmax=3,x-systemd.automount,retry=0,x-systemd.mount-timeout=3,x-gvfs-hide
fileserv.home:/media/downloads /media/downloads nfs proto=tcp,nfsvers=4.2,sec=krb5,rw,async,dirsync,acdirmax=3,noauto,retry=0,x-systemd.mount-timeout=3,user
fileserv.home:/media/public    /media/public    nfs proto=tcp,nfsvers=4.2,sec=krb5,rw,async,dirsync,acdirmax=3,noauto,retry=0,x-systemd.mount-timeout=3,user

Removing "nofail" but adding either "noauto" or "x-systemd.automount" leads
to "Before=remote-fs.target" being added to the systemd generated mounts
(thereby ensuring the proper ordering on shutdown), but can't actually
hang the startup because they aren't hard dependencies of it.  I did testing
by rebooting the system while playing a video from one of my media mounts,
and all of the mounts (both the automounted home directory and the one I 
hand mounted afterwards) were unmounted only after the user session stopped.

As to this concern:
> But automounts have the dedicated issue that they hang the system for 90 
> seconds (default timeout) if the network share server or network is down

If you see above, I changed the timeout to 3 seconds on my automount and
that seems to do the trick :)

Cheers,


-- 
Matt



More information about the systemd-devel mailing list