2

I have a NAS. On my Linux desktop, I mount a partition of the NAS via NFS.

The NAS isn't always switched on. When I need to use it, then I switch it on and use mount -a on my desktop.

The related entry on my /etc/fstab is:

192.168.1.110:/mnt/HD/HD_a2 /mnt/nas nfs rw,noatime,nodiratime 0 0

When the NAS is switched on, mount -a works fine and mounts the NAS partition.

However, when the NAS is not switched on, mount -a would hang, for very long (I'm not sure if it ever returns...). At this point when I switch on my NAS, the mount will succeed and return.

How can I get mount -a to return (without mounting the NAS partition of course) if the NAS is not switched on instead of waiting?

  • Maybe the use of 'nofail' option is what you want : man7.org/linux/man-pages/man5/fstab.5.html, I don't try – Dom Jan 4 '16 at 15:52
  • 2
    I would avoid using /etc/fstab for transitory/temporary mounts like this. You can end up with a hung system stuck in IO wait. That is exactly what autofs was intended for. Look into the ghost option if you need to mount directory to remain visible. Also, you can artificially lower the timeouts and retries of nfs itself in the mount options to fail faster if your laptop and NAS get disconnected from each other. – Aaron Jan 5 '16 at 4:36
2

If you want to use fstab, you can use the timeo parameter. But it's not the most elegant way to do it.

autofs is the proper way to handle NFS shares. You can find a good start here:

If you have trouble configure it, just let me know where you got stuck.

  • Thanks! Managed to get autofs working. Minor question though... how can I "trigger" the mounting? I see that one way is if I do ls /mnt/nas where /mnt/nas is the mount point (does not exist before mounting). But if I use Nemo (file manager for Linux Mint) and traverse to /mnt, it would be empty and I would not be able to traverse further. – Edwin Lee Jan 7 '16 at 1:34
  • Hi! Glad I could help! I don't know about Nemo, but if autofs works using ls it should work using Nemo also. I suggest talking to other Nemo users to see about their experiences. – Sergiu Tot Jan 8 '16 at 7:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.