NFS Stale File Handle

(Reproduce & Troubleshoot Series)

1 Overview

When an NFS client accesses an inode that no longer available on the NFS server, the stale file handle error (ESTALE) occurs. Common reasons:

2 Lab

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/nfs

3 NFS Directory Deleted

3.1 Reproduce

If 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/test
vm1$ rm -rf /srv/nfs/test

Client.

vm2$ cd /mnt/nfs/test
vm2$ ls
ls: .: Stale file handle

4 NFS Directory Changed

4.1 Reproduce

While 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/nfs1

Client.

vm2$ cd /mnt/nfs
vm2$ ls
ls: .: Stale file handle

5 References