If you have nfs on your system you might find this script handy. I look after several machines and periodically I may have to reboot one of them during normal working hours. This usually has to be done as quickly as possible.
As I have remote directories mounted all over the place, I do not want to have to rely on the rebooting process to take care of the nfs unmounting. I would rather do it myself; besides it’s faster than letting the machine do it.
I just run the script (which is on all the machines) and all the nfs mounts get unmounted, allowing me to do a faster reboot.
The script holds a list of machines that I have nfs mounts on. A for loop loops around this list, doing a grep of each host through the df command. The nfs directories that are mounted are in the form of:
machine:remote_directory
This string is held in the variable NFS_MACHINE. This variable is then used in the umount command.
Here’s the script.
$ pg nfsdown
#!/bin/sh
# nfsdown
LIST="methalpha accounts warehouse dwaggs"
for LOOP in $LIST
do
NFS_MACHINE=`df -k | grep $LOOP | awk ‘{print $1}’`
if [ "$NFS_MACHINE" != "" ]; then
umount $LOOP
fi
done
18.188.50.29