特定のディレクトリが NFS ファイルシステムのマウント ポイントであるかどうかを判断できる sh/bash スクリプトを作成したいと考えています。
たとえば、次のようなもの
$ mkdir localdir
$ mkdir remotedir
$ mount host:/share ./remotedir
$ classify_dirs.sh
--> localdir is local
--> remotedir is an NFS mount point
この質問は事実上 how-can-i-tell-if-a-file-is-on-a-remote-filesystem-with-perl の複製です
簡単な答えは、stat
コマンドを使用することです
例えば
$ stat -f -L -c %T localdir
ext2/ext3
$ stat -f -L -c %T remotedir
nfs
その場合、ディレクトリのタイプが「nfs」で、親ディレクトリがそうでない場合、そのディレクトリは NFS マウント ポイントです。