08 March 2006
I have autofs setup to mount my backup server at home via NFS when requested, and an overnight cron job does just that to dump files while I'm sleeping. In the morning, it's done, but for some reason the automount doesn't timeout properly and unmount everything. It just leaves the active NFS mounts.
To work around this, I have a hibernate scriptlet which sends a SIGUSR to the automount process (a couple of times actually), and that should convince it to expire and unmount, but it doesn't always. When the machine wakes up, the NFS mounts are still registered, but I'm on a different network, and that backup server is far from accessible. Attempts to unmount the shares just fail,
df blocks, and other tools, like
gnome-system-monitor (or whatever) block as well. This usually left me stuck rebooting to make the mounts go away -- even trying to force an unmount didn't work.
I found some maneuvers which do work to kill off these estranged mounts, though. I convince the machine that the backup server is denying connections using
iptables, then a subsequent unmount request gives up trying to contact the server and removes the mounts:
iptables -A OUTPUT -d 192.168.1.3 -j REJECT
umount -t nfs -a
umount -t nfs -a #twice for good measure
iptables -D OUTPUT -d 192.168.1.3 -j REJECT
I have to do this too often, so I just made myself a little script I can run when the need arises. Really, I wish I could get automount to behave properly and expire its mounts at timeout, so I don't have to hack around it.