/etc/fstab: meaning of "nofail" if "noauto" is already specified
Solution 1
Just for the record:
For an external USB disk which is usually not connected at startup, I have an fstab entry
/dev/disk/by-label/data /data xfs noauto,user,noatime 0 0
When booting there is no error as noauto
keeps the system from trying to mount. When I try to mount manually without the drive connected, I immediately get the error
~$ mount /data
mount: special device /dev/disk/by-label/data does not exist
~$
If I change the line in fstab to
/dev/disk/by-label/data /data xfs noauto,nofail,user,noatime 0 0
there is no error reported, even when the drive is not available:
~$ mount /data
~$
System: Ubuntu 16.04 with systemd.
Solution 2
noauto
will still return an error (stderr) during boot if the source is not available.
nofail
will remove the errorcheck.
nofail
without a x-systemd.device-timeout=
specified will default to a 90 second timeout though when the source is not available and you or a process attempt to mount it manually.
Note:x-systemd.device-timeout=0
sets infinite timeout.
Edit: Citation
nofail
Do not report errors for this device if it does not exist.
http://man7.org/linux/man-pages/man8/mount.8.html
Related videos on Youtube
![Tom Hale](https://lh4.googleusercontent.com/-kpRTzH5zyzs/AAAAAAAAAAI/AAAAAAAAAAA/ICc26Nac6mY/photo.jpg?sz=256)
Tom Hale
Updated on September 18, 2022Comments
-
Tom Hale almost 2 years
From my understanding of
/etc/systemd
options,noauto
means that the device will not be mounted at boot time (or withmount -a
).Is there any situation where adding
nofail
changes the behaviour ifnoauto
is already given, or is it totally redundant?man
systemd.mount(5)
says:With
noauto
, this mount will not be added as a dependency for local-fs.target or remote-fs.target. This means that it will not be mounted automatically during boot, unless it is pulled in by some other unit.With
nofail
, this mount will be only wanted, not required, by local-fs.target or remote-fs.target. This means that the boot will continue even if this mount point is not mounted successfully.What about automount situations?
-
ridgy over 7 yearsThat's not correct. If 'noauto' is set, the
mount -a
issued at startup will not try to mount and therefore there will be no waiting for the device. If you specifynoauto
, and try to mount the drive later on manually, you will get an error if it is not available. Withnofail
there will be no error message, even when the device is not available. What do you mean with 'automount situations'? -
Tom Hale over 7 yearsSince you ask here: I could see that one way the line would get "executed without
mount -a
, is with autofs andcd /mnt/autofs-directory
. I'm wondering if nofail has any effect in that case. -
m_krsic over 7 years@ridgy What isn't correct? If
noauto
is is setmount -a
issued at startup will not try to mount it, but a check is performed to see if the source is there. -
Tom Hale over 7 years@m_krsic Have you tried this personally, or do you have a reference? Why would it bother checking something that it's not going to mount anyway?