[Techtalk] argh... NFS headache...
Conor Daly
conor.daly at oceanfree.net
Sun Oct 27 00:12:35 EST 2002
On Sat, Oct 26, 2002 at 02:10:30AM +0100 or so it is rumoured hereabouts,
/dev/null thought:
> >
> > when i try to mount the laptop from the desktop machine, i get
> >
> > mount: hamish:/home failed, reason given by server: Permission denied
I've seen this error before where there are spurious entries in
/var/lib/nfs/rmtab. I ended up hacking a quick script to clean out
defunct entries from rmtab which seems to clear this error. Essentially,
rmtab keeps track of nfs mounts across reboots of the nfs server (It's a
bit of a pain to discover your /home directory is a "stale nfs handle"
when you want to save your work all cos the server rebooted while you were
working). It your machine has an entry in the server's rmtab, it's nfs
requests will be honoured. Unfortunately, if a client machine goes down
while the nfs server is off air, it's rmtab entries will remain and will
block another client from using them (especially in a DHCP environment
where a client may get the same IP addy as a previous client). I call
this script from the "start" section of the /etc/rc.d/init.d/nfs script
and it pings hosts listed in rmtab and retains their entries if they
respond.
Conor
#######################################################################
[cdaly at genesis cdaly]$ more /etc/rc.d/init.d/clean_rmtab
#!/bin/bash
# clean_rmtab
#
# Author: Conor Daly <conor.daly at oceanfree.net>
# License: GPL
#
# A little hack to keep nfs's rmtab file clean. rmtab keeps track
# of nfs mounts across reboots. Anything listed there gets to keep
# its file handle after an nfs restart. When an export gets umounted,
# its entry in rmtab is removed. However, if the client doesn't umount
# the export (eg. a hard reset), the entry remains in the rmtab. This
# can lead to problems. The simplest solution seems to be to ping each
# host listed in rmtab and if the host is up, copy those lines to a tmp
# file. Once all hosts listed have been tested, the tmp file will
# contain entries only for those hosts that are up. The tmp file
# replaces rmtab.
# define both the rmtab and the tmp file and create the tmp file
RMTAB=/var/lib/nfs/rmtab
RMTABTMP=/tmp/rmtab$$.tmp
touch $RMTABTMP
# loop through the hosts listed in $RMTAB
for HOST_NAME in `cat $RMTAB | cut -f1 -d":" | sort -u`; do
# See if $HOST_NAME is alive
ping -c1 $HOST_NAME > /dev/null 2>&1
STATUS=$?
if [ $STATUS -eq 0 ]; then
# if so, copy all references into $RMTABTMP
grep $HOST_NAME $RMTAB >> $RMTABTMP
fi
done
# then replace the original $RMTAB with the clean version
mv -f $RMTABTMP $RMTAB
########################################################################
[cdaly at genesis cdaly]$ more /etc/rc.d/init.d/nfs
[much stuff snipped]
# See how we were called.
case "$1" in
start)
# Start daemons.
/etc/rc.d/init.d/clean_rmtab # Call rmtab cleanup
action "Starting NFS services: " /usr/sbin/exportfs -r
[further actions...]
--
Conor Daly <conor.daly at oceanfree.net>
Domestic Sysadmin :-)
---------------------
Faenor.cod.ie
12:14am up 57 days, 4:42, 0 users, load average: 0.08, 0.02, 0.01
Hobbiton.cod.ie
12:03am up 57 days, 4:12, 1 user, load average: 0.10, 0.12, 0.06
More information about the Techtalk
mailing list