Come posso risolvere un handle nfs obsoleto?


8

Ho notato una volta quando ho chiuso il mio server di casa mentre il mio desktop era collegato tramite NFS che continuavo a ricevere "avviso di gestione NFS obsoleto" quando entravo nella mia home directory, questo causava problemi con alcuni programmi che guardavano in quelle cartelle.

Come posso risolvere questo problema senza riavviare il mio computer?

Debian Squeeze / Wheezy


Quale sistema operativo e / o distribuzione stai eseguendo?
Jodie C,

Sto usando Debian Squeeze
yakamok il

Risposte:


4

Su Debian Squeeze / Wheezy:

Forza lo smontaggio del montaggio locale

umount -f /mnt/dir

Quindi riavviare nfs

/etc/init.d/nfs-common restart

Sarei sorpreso se potessi forzare lo smontaggio di un filesystem - quindi dubito che quanto sopra funzionerà.
David Goodwin,

umount -f non ha funzionato per me, ma umount -lf ha funzionato!
FreeSoftwareServers

2

Prova questo script di shell. Funziona bene per me:

#!/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

Sulla base della mia esperienza, sembra che questo sia un cambiamento di 50:50 perché questo non sia sufficiente e un riavvio della macchina è necessario. Non vedo l'ora di vedere una sceneggiatura migliore, forse una da inserire nel crontab. Incontriamo questo tipo di problema molto spesso, con più di una macchina al giorno.
Sorin,

0

Solitamente emetterei questi comandi (come root):

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

Potrebbe non essere necessario tutto ciò, a seconda di come funziona il sistema.


Per quale Distro è questo?
yakamok,
Utilizzando il nostro sito, riconosci di aver letto e compreso le nostre Informativa sui cookie e Informativa sulla privacy.
Licensed under cc by-sa 3.0 with attribution required.