0

I have a home network with two Debian Stretch PCs. In each one, I have a directory called share, shared via NFS, where I put stuff I want to copy from the other PC through NFS. After auto-mounting on boot, there's a problem if the other PC goes off: any window (Nautilus, Firefox "open" or "save as", Terminal "ls"...) that shows the ~/home directory (where share is) freezes, waiting for the mounted share. Is there a way to auto-unmount, if any window finds out that the share is not accessible anymore? How do home networks usually address this issue?

Rodrigo
  • 1,832

1 Answers1

0

You should use soft mount option for your nfs mount, which should solve your issue with applications hanging when trying to access unavailable nfs server.

hard/soft mount options control nfs recovery behavior. man nfs explains:

Determines the recovery behavior of the NFS client after an NFS request times out. If neither option is specified (or if the hard option is specified), NFS requests are retried indefinitely. If the soft option is specified, then the NFS client fails an NFS request after retrans retransmissions have been sent, causing the NFS client to return an error to the calling application.

Additionally, AutoFS is commonly used to implement on demand automatic mounting/unmounting.

sebasth
  • 14,872
  • "NB: A so-called "soft" timeout can cause silent data corruption in certain cases. As such, use the soft option only when client responsiveness is more important than data integrity. Using NFS over TCP or increasing the value of the retrans option may mitigate some of the risks of using the soft option." This doesn't seem good enough to me. AutoFS seems to be my only hope here. – Rodrigo Sep 12 '18 at 22:19
  • You don’t need AutoFS here, systemd automounts provide pretty much the same functionality (see your previous question). – Stephen Kitt Sep 13 '18 at 07:20