How do I determine if a directory is a mounted NFS mount point in shellscript

0 votes
asked Jan 20, 2009 by andrewr

I want to write a sh/bash script that can determine whether a particular directory is a mount point for an NFS filesystem.

eg something like

$ mkdir localdir
$ mkdir remotedir
$ mount host:/share ./remotedir
 -->  localdir is local
 -->  remotedir is an NFS mount point

1 Answer

0 votes
answered Jan 20, 2009 by andrewr

This question is effectively a dup of how-can-i-tell-if-a-file-is-on-a-remote-filesystem-with-perl

The short answer is to use the stat command


$ stat -f -L -c %T localdir
$ stat -f -L -c %T remotedir

Then a directory is an NFS mount point if its type is 'nfs' and its parent directory isn't.

Welcome to Q&A, where you can ask questions and receive answers from other members of the community.
Website Online Counter