(Reproduce & Troubleshoot Series)
When an NFS client accesses an inode that no longer available on the NFS server, the stale file handle error (ESTALE) occurs. Common reasons:
vm1$ exportfs -v
/srv/nfs 192.0.0.0/24(sync,wdelay,hide,no_subtree_check,sec=sys,rw,secure,root_squash,no_all_squash)vm2$ df -h
Filesystem Size Used Available Use% Mounted on
192.0.0.10:/srv/nfs 5.6G 221.0M 5.1G 4% /mnt/nfsIf the NFS server deletes a directory which currently opened by the NFS client, the inode held by the client becomes unavailable. The further operation of the client on the inode fails with ‘Stale file handle’ error.
Server.
vm1$ mkdir /srv/nfs/testvm1$ rm -rf /srv/nfs/testClient.
vm2$ cd /mnt/nfs/testvm2$ ls
ls: .: Stale file handleWhile the NFS client currently opens a directory, if the NFS server unexport the directory and export another directory, the further request from the client to the inode fails with ‘Stale file handle’ error.
Server.
vm1$ exportfs -v
/srv/nfs 192.0.0.0/24(sync,wdelay,hide,no_subtree_check,fsid=1,sec=sys,rw,secure,root_squash,no_all_squash)vm1$ mkdir /srv/nfs1
vm1$ vi /etc/exports
# ---------------------------------------------------------------------- #
# /srv/nfs 192.0.0.0/24(rw,sync,no_subtree_check,fsid=1) # old directory
/srv/nfs1 192.0.0.0/24(rw,sync,no_subtree_check,fsid=1) # new directory
# ---------------------------------------------------------------------- #
vm1$ exportfs -va
exporting 192.0.0.0/24:/srv/nfs1Client.
vm2$ cd /mnt/nfsvm2$ ls
ls: .: Stale file handle