Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I determine whether a given directory on a Linux machine is from an NFS mounted drive or not?

share|improve this question
You can always look at the output of mount. It will list all the mounts on the system. You'll be able to tell if your folder is on one of the mounts based off the folder path. – MaQleod May 8 '12 at 17:46
up vote 5 down vote accepted

You could use the stat utility with -f to say you're looking for information about the filesystem.

For example:

$ stat -f -c %T .
$ stat -f -c %T /sys
$ stat -f -c %T /proc
$ if [[ $(stat -f -c %T /proc) == proc ]] ; then echo Good ; fi

(See the man page for the different formatting options, and sorry I don't have an NFS mount handy.)

share|improve this answer

You could use df -t nfs <directory>, which will produce output like

$ df /home/aland/ -t nfs
Filesystem           1K-blocks      Used Available Use% Mounted on
nfs_oscar:/home      1255425376 874128064 316496736  74% /home

if directory belogs to NFS mount, and nothing otherwise:

$ df /root/ -t nfs
Filesystem           1K-blocks      Used Available Use% Mounted on

Edit: simpler way: df -T <directory> (flag -P is used to disable pretty formatting to facilitate tailing and awking):

$ df /home/aland/ -TP  | tail -n -1 | awk '{print $2}'
share|improve this answer

I would simple use the default tool mountpoint:

       mountpoint - see if a directory is a mountpoint

       mountpoint [-d|-q] directory

Since you are talking specifically about NFS, this means you have also access to showmount, except this work the other way around (from a host instead of a directory):

       showmount - show mount information for an NFS server

       showmount [ -adehv ] [ --all ] [ --directories ] [ --exports ] [ --help ] [ --version ] [ host ]
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .