Nfs – Fix the “Stale file handle” fault as a regular user

nfsuser-permissions

I have an ubuntu system which I'm controlling with commands as a regular user over ssh. On that machine I have an fstab entry for an NFS share. I can mount and unmount the folder because I have the user option set in the fstab entry.

The problem is that the NFS SERVER is shutdown nightly (not going to change) resulting in a Stale file handle error on the client.

As a sudo user I could simply force an umount/mount for the NFS share but this isnt possible as I'm controlling the machine as a regular user over ssh and I dont intent to pipe the password.

So the question is:
How, as a regular user, can I unmount/remount or otherwise fix my Stale file handle fault?

Best Answer

There are a couple ways to resolve this, but none are optimal. Ideally you'd want to unmount the share before the NFS server goes down (which could be done with something like an SNMP trap or custom socket program, or any number of other methods).

I think in this case, my preferred action would be to cron the unmounting, assuming the NFS server is shut down and booted around the same time frame every day. If the NFS server goes down sporadically, I'd instead look into using SNMP traps or informs. (A writeup on them is available here.)