2

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 Answer 1

2

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

3
  • "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" - thanks for this suggestion. I just had a really hard time figuring out why the heck geany would not start when I realized that other applications were affected as well. I mounted a nfs share to $HOME/nfs ... Wow, in 2021, network timeouts seem still to be unknown...
    – spawn
    Mar 11, 2021 at 20:43
  • The suggestion of soft,retrans=1,retry=0,intr saved me from the terminal hangs. For anyone who's curious to know more, some explanations about these params can be found here: freebsd.org/cgi/…. N.B.: the ref is for freebsd so the parameters are slightly different.
    – Boson Bear
    May 2, 2022 at 14:07
  • As of today, default is UDP for the mount itself, and TCP for communication with the NFS server - see nfs(5). intr/nointr are ignored now.
    – braoult
    Jan 25 at 8:20

You must log in to answer this question.

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