Reproduce NFS Stale File Handle

1 Overview

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)

vm1$ showmount -a
192.0.0.10:/srv/nfs
192.0.0.20:/srv/nfs
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 Reproduce Stale File

3.1 Delete while Open

If the server deletes a file or directory while the client currently has open, the inode held by client become invalid. The further actions to the inode will fail with ‘Stale file handle’ error.

Server.

vm1$ mkdir /srv/nfs/test
vm1$ rm -rf /srv/nfs/test

Client.

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