Twitter

nfs-status.sh: quickly check and fix NFS

NFS are a very cool feature, no doubt about that. But NFS reliability is more questionable and a hung NFS is not easy to spot and can have dramatic consequences by creating a huge load on your system which may eventually die. Also, depending on how/who manages your systems, you may eventually find mounted NFS not in fstab (which will then not be remounted at boot) or unmounted NFS even if they are correctly declared in fstab.

As responsible of the systems, you want to be able to quickly be able to:
  • Find which NFS is in a hung state
  • Quickly umount these hung NFS
  • Find NFS configuration issues (NFS in fstab but umounted or nounted NFS not in fstab)

This is to achieve these goals that I have dev nfs-status.sh; let's have a look at a first output:
[root@prod01]# ./nfs-status.sh

------------------------------------------------------------------------------
Mount Point   | NFS                               | Status       | in fstab  |
-----------------------------------------------------------------------------
/nfs1         | 10.11.12.13:/nfsserver/nfs1       | Hung         |          |
/nfs2         | 10.11.12.13:/nfsserver/nfs2       | Healthy      |          |
/nfs3         | 10.11.12.13:/nfsserver/nfs3       | Not Mounted  |          |
/nfs4         | 10.11.12.13:/nfsserver/nfs4       | Healthy      |    xxx    |
/nfs5         | 10.11.12.13:/nfsserver/nfs5       | Healthy      |          |
/nfs6         | 10.11.12.13:/nfsserver/nfs6       | Not Mounted  |          |
------------------------------------------------------------------------------
[root@prod01]# echo $?
1
[root@prod01]#
The above output is self-explanatory enough not to have to comment it extensively; you can quickly see that /nfs1 is hung (this is tested with the stat -t command), that /nfs4 it not in fstab and that /nfs3 and /nfs6 are not mounted but should be mounted as they are in fstab.

Also, you can know how many NFS are hung usiong the return code of the script, it here shows that 1 NFS is hung. This makes it easy to check if all NFS are good before starting a maintenance and then not doing the maintenance if a NFS is hing using && and || as below:
# ./nfs-status.sh || exit 123
The script also has options to umount the hung NFS, show the mount command, mount the umounted NFS
  • --show: Show the umount commands to umount the hung NFS
  • --mount: Mount the unmounted NFS
  • --umount: Umount the hung NFS
  • --fstab: For non standard fstab, default is: /etc/fstab


Where to download ?

You can download nfs-status.sh from my public git repo or using the direct link to the source code from the Scripts menu on top of this page.

In case of issue/question, as usual, feel free to post a comment down below, contact me by email or linkedin chat.

I have been using this script for a little while and it has always been a situation it has been very useful !

2 comments:

  1. Hi Fred , I am Aaditya Dabli , nfs is not hang after taking nfs-status and checking with df and ls command but its still shows nfs filesystem /xyz is hang on this host . Can you please suggest for this

    ReplyDelete
    Replies
    1. Can you do:

      # stat -t /xyz

      And paste the result here

      Delete

CUDA: Getting started on Google Colab

While getting started with CUDA on Windows or on WSL (same on Linux) requires to install some stuff, it is not the case when using Google...