• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 255
  • Last Modified:

NFS - File system issue on client when server is gone

Hi Guys,

I have a question on a issue that follows us for years, and we have never stopped to think about how to fix.

We have many NFS clients using a NFS server for backup purposes. The clients runs cPanel, and we see that when the NFS server have some problem for any reason, like hardware failure, nfs service is down, network issue or whatever, it happens that the client cannot see the /backup anymore, and if you do a "df -h" the shell is stuck. Other issues are that we cannot create any account on cPanel, the server start to be loaded, Webmail crashes, etc.

My question is, how do I set the fstab on clients to mount the NFS partition in a way that anything that happens to the server, the partition is either unmounted or anything that could not affect the client OS ?

Thank you !
1 Solution
Try adding _netdev (the 1st character is an underscore/underline) to the Options section of the fstab entries.
maxihostAuthor Commented:
Like this ?

189.1.174.XXX:/backup/lvmh4     /backup nfs     _netdev        0 0
maxihostAuthor Commented:
I dont think thats what we are looking for.

From https://help.ubuntu.com/community/NFSv4Howto
where the auto option mounts on startup and the _netdev option can be used by scripts to mount the filesystem when the network is available. Under NFSv3 (type nfs) the _netdev option will tell the system to wait to mount until the network is available. With a type of nfs4 this option is ignored, but can be used with mount -O _netdev in scripts later. Currently Ubuntu Server does not come with the scripts needed to auto-mount nfs4 entries in /etc/fstab after the network is up.
7 new features that'll make your work life better

It’s our mission to create a product that solves the huge challenges you face at work every day. In case you missed it, here are 7 delightful things we've added recently to monday to make it even more awesome.

Perhaps the "shell is stuck" as you described because the client is still trying to connect to a network device that it does not know is a network device, and _netdev tells the system that it is a network device.

It's worth a try.
Seth SimmonsSr. Systems AdministratorCommented:
_netdev is used for startup to ensure the network is up before it tries to mount; this is not the question that was asked

the question is what if something happens after the system is running and ends up with a stale nfs mount - how to recover

a bit difficult to try this automatically; you might be able to check for a stale mount with a script but you would have to run it often to detect it.  if it recovers on it's own then the mount would recover, but the process might not.  doing a umount -l (lazy unmount) on that mount point will remove it safely so df won't hang
Why not use autofs?

The remote filesystem will only be (auto)mounted when it's being used and unmounted when not used.

If the nfs server becomes unavailable, this will only influence clients that are actually using the nfs mount at that time.
maxihostAuthor Commented:

I have contacted cPanel and their suggestion was,

My first suggestion would be to put NFS mounts into a dedicated sub-directory below the root directory, for example, using the existing '/mnt' directory then mount the NFS share as '/mnt/backup' there or whatever you want the mount name to be. This will prevent some processes and scripts which perform lstat() calls on the contents of the root directory from hanging on the NFS mount if it were directly mounted to a location in the root directory.

I would also recommend mounting the NFS mount with the 'soft' option, and using the 'retrans' and 'timeo' options to tune the retransmission and I/O time-outs to fit your needs. The 'nfs' manual page (man nfs) provides details about what these options do. Please keep in mind that such NFS mounts are only suitable for purposes such as a backup storage location, not database storage, home directories, etc.

What do you think ?
Agree with Cpanel's suggestion but i doubt putting _netdev along with this will work.

maxihostAuthor Commented:
Found solution contacting cPanel.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now