I noticed once when I shut down my home server while my desktop was connected via NFS that I kept getting "stale NFS handle warning" when entering my home dir, this caused issues with some programs that looked in those folders.

How do I resolve this issue without restarting my machine?

Debian Squeeze/Wheezy

  • What OS and/or distribution are you running?
    – Jodie C
    Apr 12, 2012 at 11:36
  • I am using Debian Squeeze
    – yakamok
    Apr 12, 2012 at 11:39

3 Answers 3


On Debian Squeeze/Wheezy:

Force unmount the local mount

umount -f /mnt/dir

Then restart nfs

/etc/init.d/nfs-common restart
  • I'd be surprised if you can force the unmount of a filesystem - so I doubt the above will work. Mar 24, 2013 at 18:36
  • umount -f didn't work for me, but umount -lf did! Sep 21, 2016 at 13:29

Try this shell script. Works good for me:

# Purpose:
# Detect Stale File handle and remove it
# Script created: July 29, 2015 by Birgit Ducarroz
# Last modification: --

# Detect Stale file handle and write output into a variable and then into a file
mounts=`df 2>&1 | grep 'Stale file handle' |awk '{print ""$2"" }' > NFS_stales.txt`
# Remove : ‘ and ’ characters from the output
sed -r -i 's/://' NFS_stales.txt && sed -r -i 's/‘//' NFS_stales.txt && sed -r -i 's/’//' NFS_stales.txt

# Not used: replace space by a new line
# stales=`cat NFS_stales.txt && sed -r -i ':a;N;$!ba;s/ /\n /g' NFS_stales.txt`

# read NFS_stales.txt output file line by line then unmount stale by stale.
#    IFS='' (or IFS=) prevents leading/trailing whitespace from being trimmed.
#    -r prevents backslash escapes from being interpreted.
#    || [[ -n $line ]] prevents the last line from being ignored if it doesn't end with a \n (since read returns a non-zero exit code when it encounters EOF).

while IFS='' read -r line || [[ -n "$line" ]]; do
    echo "Unmounting due to NFS Stale file handle: $line"
    umount -fl $line
done < "NFS_stales.txt"
  • Based on my experience it it seems to be a 50:50 change for this not to be enough, and a machine reboot being needed. I am looking forward to see a better script, maybe one to put in the crontab. We encounter this kind of problem very often, with more than one machine per day.
    – sorin
    Jan 26, 2016 at 17:38

I would usually issue those commands (as root):

service nis restart
service autofs restart
service nfs restart
service portmap restart

You may not need all of those, depending on how your system works.

  • Which Distro is this for?
    – yakamok
    Apr 14, 2012 at 8:02

You must log in to answer this question.

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