Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

2 Answers 2

up vote 4 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 .
ext2/ext3
$ stat -f -c %T /sys
sysfs
$ stat -f -c %T /proc
proc
$ if [[ $(stat -f -c %T /proc) == proc ]] ; then echo Good ; fi
Good

(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}'
nfs
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.