Sunday, December 18, 2011

usb external drive - misc

Occasionally, the problem of "stale nfs file handles" arises on an external drive. This is a strange error which I believe has to do with a file changing without it's time stamp being updated. I have no idea which index or hash this offends, but it seems to occur with external USB drives on occasion, in such a way that prevents mounting the drive. What to do? My first thought was to run fsck, but without mounting, we can't be sure of the "dev" name to provide fsck, and neither can we run fsck when the device with stale handles is mounted.

The best way to break this impasse is to use udevmonitor or, if now under the dreaded "systemd", udevadm monitor --environment --udev", to get the block device name. Then just verify it's unmounted, and fsck it. Let's say we plug-in our our USB drive with stale NFS file handles, and it becomes labeled "/dev/sdc" by the system when it's detected...

SysV

# udevadmin monitor [plug-in device]
# umount /dev/sdc
# fsck /dev/sdc

SystemD

# udevadm monitor --environment --udev [plug-in device]
# umount /dev/sdc
# fsck /dev/sdc

No comments: