📅 2016-Mar-07 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ nfs, stat ⬩ 📚 Archive
There are times when I find it useful to know which filesystem a directory belongs to. For example, I find that Git is very slow in directories that are in NFS mounts. So, I like to disable Git-related actions in my shell when the PWD
is in a NFS mount.
An easy way to check the filesystem of a path is:
stat --dereference --file-system --format="%T" /path/to/check
Or the shorter version:
stat -L -f -c "%T" /path/to/check
On a directory in a NFS mount, this returns me nfs
. On a locally mounted directory, it returns ext2/ext3
. You can use this return value in your shell scripts to control what happens based on the filesystem.
If you find this type of lookup useful, you might want to create a shell alias for it.