How to check filesystem of path

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 --filesystem --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.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s