Thursday, August 27, 2015

[Linux] Stale NFS file handle

This problem happens when listing or creating a file within a NFS. In my case, I was creating a controlfile for a standby database. I saw this error:

SQL> alter database create standby controlfile as '/stage/solusoft/backup/ESCOGRD.ctl';
alter database create standby controlfile as '/stage/solusoft/backup/ESCOGRD.ctl'
*
ERROR at line 1:
ORA-01580: error creating control backup file
/stage/solusoft/backup/ESCOGRD.ctl
ORA-27037: unable to obtain file status
SVR4 Error: 151: Stale NFS file handle
Additional information: 1

Although it sounds strange, it's pretty simple. The stale occurs because a referenced object (file or directory) is removed by another host, but you still hold the reference of the object.

The best approach to solve this issue is to remount the directory using the following commands as the root user:
# umount -f /local/mountpoint
# mount -t nfs hostname:/shared/path /local/mountpoint

If you have the fstab entry, you can use the following commands as the root user:
# umount -f /local/mounpoint
# mount /local/mountpoint

You will be able to read and write normally on your NFS. 

Issue solved!