How do I forcibly unmount when I'm getting stale nfs file handles?
Got myself into a tricky situation. Have aufs mounted at /mnt/1
aufs on /mnt/1 type aufs (rw,relatime,si=daab1cec23213eea)
I can't unmount the thing:
sudo umount -f /mnt/1
umount2: Stale NFS file handle
umount: /mnt/1: Stale NFS file handle
umount2: Stale NFS file handle
umount2: Stale NFS file handle
How do I unmount the mount point? (without rebooting the system)
(Note: aufs is on top of an openafs system rather than NFS.)
from man 8 umount
:
-f Force unmount (in case of an unreachable NFS system).
(Requires kernel 2.1.116 or later.)
-l Lazy unmount. Detach the filesystem from the filesystem hierar-
chy now, and cleanup all references to the filesystem as soon
as it is not busy anymore. (Requires kernel 2.4.11 or later.)
If sudo umount -f /mnt/1
does not work, you can try sudo umount -l /mnt/1
.
Alright, I have found a solution for my issue (same as the question). This is what did NOT work for me:
mount -t nfs -o remount /mnt/1
umount /mnt/1
umount -f /mnt/1
umount -l /mnt/1
Here is what DID work for me:
umount -lf /mnt/1
If this does not work for you, ensure that you kill all processes currently tied to the mounted directory:
lsof | grep /mnt/1
fuser -k /mnt/1
The -l
(lazy) option tells umount
not to clean things up now. Without this option the mount point will be busy. Check out @Xupeng's answer for the man
page details on the umount options.
You can unmount this, despite stale file handle, with:
fusermount -u /mnt/1