0

NFS server: Ubuntu 14.04 server

NFS client: Ubuntu 14.04 desktop 64 bit

On Client I mounted the NFS share mount -v -t nfs NFSSERVER_IP:/servernfsfolder ~/clientnfs

Mount was successful and I was able to see all the NFS shared files in my ~/clientnfs folder via file explorer.

Issue: Suppose NFS server go offline while I have the NFS share mounted on my client, my client's nautilus will hang, also I cannot do an 'ls' in my home directory.

How can I make my NFS client machine to unmount the NFS share automatically when my server goes offline ?

1

This looks a little old, so I'm not sure if you've already found an answer, but I've recently solved a similar issue.

This problem is compounded by multiple issues:

  1. The new files browser always pulls information about the various filesystems that are available to it - meaning if you have 5 mounted shares, whether they are SSH, CIFS, or NFS and are visible under the "network" section of the places pane (left side), they will always have an fread() called on them.
  2. Some of these shares, will take longer to respond - even with proper credentials, and will make it appear that nautilus has hung when opening it up after a period of inactivity, or if a server goes away.
  3. Many other applications cause nautilus fread()s - I witnessed this doing an strace on the nautilus process, but this issue seems to be connected only when something requests a full list (like a file open window).
  4. Any time you open nautilus up (by just clicking on the file folder icon in your panel) it does a scan of the folders in your home directory and the contents inside. If you make your mount point something like /home/$user/server_mount then nautilus will hang when the server becomes unavailable.

Note, this also affects other applications like Evolution. Receiving calendar events, or replying to a message would cause Evolution to 'dim' as it was waiting. I'm guessing it was requesting a full file listing for the attachment button, but I didn't investigate that further.

My quick solution for myself, was to just unmount the network shares I had connected to. For now, I'll only connect when I need to access the resources, then unmount when I'm done.

You're semi-permanently attached, so your solution will be a bit different, and its something I've done in the past.

  1. To handle reattaching after the server comes back up, you'll want to use an automounter - like autofs
  2. To handle the nautilus hangs when the server isn't available, relocate the mount point somewhere that isn't a default starting point for nautilus, like a sub-directory. /home/$user/mounts/server_mount
  3. You'll need to have your mount gracefully fail back to your application in a timely fashion when the sever goes away. To do that, you'll want to add the soft,retrans=1,retry=0,intr switches to your mount. If memory serves me correctly, the retrans,retry values only work with NFS over UDP, which is the default. If you're using it over TCP, then the timeout values will be based on the TCP stack settings.

HTH

| improve this answer | |

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.