Problem
I have an NFS server and some volume/directories are shared from this server to other servers. One day I performed some tasks on the NFS server and during this activity, I removed a mount point /test which was shared with other servers.
Before removing the mount point I had stopped the NFS service and after re-mounting the /test I started the NFS service.
When I check the mount point on client systems, df -h showed the Stale file handle error as shown below:
[root@dbappweb.com ~]# df -h /home/test df: ‘/home/test’: Stale file handle
I tried fuser, also tried to umount forcefully but not become successful.
[root@dbappweb.com ~]# fuser -kcu /home/test Cannot stat /home/test: Stale file handle
[root@dbappweb.com ~]# umount nfs_server:/test umount.nfs4: /home/test: device is busy
[root@dbappweb.com ~]# umount -f /home/test umount.nfs4: /home/test: device is busy
Reason
This has happened because the NFS service stopped on the NFS server without umounting the NFS volume first on client systems. This may also happen in the case of the NFS server rebooted without the client umounting the NFS volumes first.
Solution
Use the -l option with umount command to umount the NFS volume showing ‘Stale file handle’ and it will be successfully umounted.
[root@dbappweb.com ~]# umount -lf /home/test
After successful umounting, remount the volume again.
[root@dbappweb.com ~]# mount nfs_server:/test /home/test
And server started working fine with NFS mounted volume.
[root@dbappweb.com ~]# df -h /home/test
Filesystem Size Used Avail Use% Mounted on
nfs_server:/test 1.0T 320G 680G 32% /home/test
Use umount –help or umount -h to get more details about umount command.
[root@dbappweb.com ~]# umount --help
[root@dbappweb.com ~]# umount -h
Usage:
umount [-hV]
umount -a [options]
umount [options] |
Options:
-a, --all unmount all filesystems
-A, --all-targets unmount all mountpoins for the given device
in the current namespace
-c, --no-canonicalize don't canonicalize paths
-d, --detach-loop if mounted loop device, also free this loop device
--fake dry run; skip the umount(2) syscall
-f, --force force unmount (in case of an unreachable NFS system)
-i, --internal-only don't call the umount. helpers
-n, --no-mtab don't write to /etc/mtab
-l, --lazy detach the filesystem now, and cleanup all later
-O, --test-opts limit the set of filesystems (use with -a)
-R, --recursive recursively unmount a target with all its children
-r, --read-only In case unmounting fails, try to remount read-only
-t, --types limit the set of filesystem types
-v, --verbose say what is being done
-h, --help display this help and exit
-V, --version output version information and exit
For more details see umount(8).
[root@dbappweb.com ~]#
Last Updated: July 30, 2020