Prevent Boot Sequence Hanging in Debian 10 fstab

debianfstabmountnfsv4

I have a Debian 10 machine which has a nfs mountpoint specified in fstab.

This is the line

10.0.0.2:/mnt/md0    /mnt/md0    nfs4    _netdev,auto,nofail    0    0

I thought nofail would prevent my boot sequence hanging for (precicely) 1:32 while a time out takes place while the system is looking for the nfs drive. However this doesn't appear to be the correct opion, as it is not mentioned in my systems man pages. A search suggested nobootwait might be an alternative but again this is not mentioned in the man pages. There doesn't appear to be any relevant option, unless I am looking in the wrong document?

Is there any way to specify that the drive should be automatically mounted, when it is present, and only when it is present. Both at boot time, and additionally, if the drive is "somehow seen" later on.

eg; If I boot my workstation, and the drive is not present (server not booted) it should not wait an additional minute and a half to boot.

then; If I boot the server at a later time, is there any way to automatically detect/mount the nfs drive? I guess this could be done with some kind of cron script which pings the network address 10.0.0.2? (My server IP.)

Best Answer

For automatically mounting NFS when present, autofs can be used (autofs)

As mentioned in man fstab(5)

nofail

do not report errors for this device if it does not exist.

AFAIK nobootwait was only for ubuntu-based distros (which is not a valid option anymore)

You can use x-systemd.device-timeout= (more info systemd.mount)

x-systemd.device-timeout=

Configure how long systemd should wait for a device to show up before giving up on an entry from /etc/fstab. Specify a time in seconds or explicitly append a unit such as "s", "min", "h", "ms".

Note that this option can only be used in /etc/fstab, and will be ignored when part of the Options= setting in a unit file.

The default device timeout is 90 seconds, so a disconnected external device with only nofailwill make your boot take 90 seconds longer, unless you reconfigure the timeout as shown. Make sure not to set the timeout to 0, as this translates to infinite timeout.

Related Question