i have in my Local Network a NAS with NFS Shares. How to handle that ma Laptop connect automagically to the NFS Share? I tried a Entry in the fstab File but when i outside the local network my Client needs up to 5 Minutes to boot because he is waiting for the NFS Timeout.

Is there any Solution that detect that my Laptop is on the local Network and mount than?


  • In the options field of the line in fstab, try adding the bg option. This should minimize boot delays when the share isn't accessible. Oct 19, 2017 at 16:41

2 Answers 2


A way to execute a command on boot is to put it into /etc/cron.d/nfsmount with the content:

@reboot root /bin/sleep 7 && /bin/ping -c 1 -W 1 > /dev/null && /bin/mount /foo

On reboot it wait 7 seconds, then do one ping with a timeout in 1 second, and if it went good then mount NFS with the parameters specified in /etc/fstab.

In /etc/fstab you should have the option noauto: /foo nfs noauto 0 0

If you have systemd you might want to look at systemd.automount.

  • wow! this works!!! many many many many many thanks. you are my hero
    – holger94
    Oct 19, 2017 at 19:47

you can give a shot to monit that will monitor the nfs mount then can take action.

from the manual :

CHECK FILESYSTEM <unique name> PATH <string> 

path is the path to the device/disk, mount point or NFS/CIFS/FUSE connection string. If the filesystem becomes unavailable, Monit will call the service's start method if defined. If Monit runs in passive mode or the start method is not defined, Monit will just send an alert on error.

For example you can use a rule like this one :

check filesystem nfsDisk1 with path nfs://<yournfsexport>
       if does not exist then exec "ping host && mount..."

if ping fails will not try to mount

Note that you need to remove your mount from fstab to let monit handle the mount

Then to optimise you can do something similar for the detection of your local network and then make your first rule depends on it

Have fun with monit

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .