I'd like to verify an application's behavior when trying to read from a bad filesystem (most notably: a hung NFS mount where reads might just hang forever if left unchecked).
Is there an easy way to locally reproduce this behavior? Be great if I could just force-mount something that doesn't exist, or mount a local ram disk and corrupt it, or lock it from reads such that it hangs rather than erroring out, or something of the sort. It should be something I could do reproducibly as part of a small integration test.
mkdir /tmp/nfs
/tmp/nfs *(sync,sync,ro,no_subtree_check,fsid=0468884e-fdab-11e9-8ee6-4b007bc13e45)
to /etc/exports
sudo exportfs -ra
mkdir /tmp/hang
mount -t nfs -o vers=3 localhost:/tmp/nfs /tmp/hang
ls /tmp/hang
- everything is fine.ls /tmp/hang
- it will hang.ls
command will release.An alternative to shutting down the NFS server is to block the client via iptables
. This has the advantage that you can set up multiple network interfaces, mount multiple clients via different interfaces, and then selectively block clients by blocking network interfaces with iptables
.