如何解决过时的nfs句柄?


8

我曾经注意到,当我的桌面通过NFS连接时关闭家庭服务器时,我在输入家庭目录时一直收到“过时的NFS句柄警告”,这引起了在那些文件夹中查找的某些程序的问题。

如何在不重新启动计算机的情况下解决此问题?

Debian压榨/ Wheezy


您正在运行什么操作系统和/或发行版?
朱迪·C

我正在使用Debian Squeeze
yakamok

Answers:


4

在Debian Squeeze / Wheezy上:

强制卸载本地安装

umount -f /mnt/dir

然后重启nfs

/etc/init.d/nfs-common restart

如果您可以强制卸载文件系统,我会感到惊讶-因此,我怀疑上面的方法是否有效。
David Goodwin

umount -f对我不起作用,但是umount -lf对我有用!
FreeSoftwareServers

2

试试这个shell脚本。对我有用:

#!/bin/bash
# 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"
#EOF

根据我的经验,这似乎是50:50的更改,这还不够,需要重新启动计算机。我期待看到更好的脚本,也许可以将其放入crontab中。我们经常遇到此类问题,每天使用一台以上的机器。
索林

0

我通常会发出这些命令(如root):

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

您可能并不需要所有这些,这取决于系统的工作方式。


这是哪个发行版的?
yakamok'4
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.