我有一个Ubuntu服务器,一个NAS,我正在使用CIFS协议进行安装。 我遇到了重复同一个坐骑的情况。 下面是我运行mount的输出:
//10.0.1.38/FOO on /home/s3backup/mnt/FOO type cifs (rw,mand) //10.0.1.38/FOO on /home/s3backup/mnt/FOO type cifs (rw,mand) //10.0.1.38/FOO on /home/s3backup/mnt/FOO type cifs (rw,mand)
在这一点上,如果我下三次,我将终于下决心。
我怎样才能防止这种堆叠安装,无论是在安装选项或NAS上的smb.conf?
如果不是的话,当我尝试安装在某个东西上时,能否收到警告?
谢谢!
嗨,我写了一个简短的bash脚本来检查。 我在Mac上testing过。 使用自己的风险:)。
#!/bin/bash # USAGE: hasmount.sh /home/me # retcode 0 has mount # retcode 1 no mount # retcode 2 is not directory if [ ! -d $1 ]; then exit 2 fi n_matches=`mount | grep " \`pushd $1;pwd\` " | wc -l` n_matches=`echo $n_matches` if [ "$n_matches" = "0" ]; then exit 1 else exit 0 fi
您可以使用/ etc / fstab来挂载,甚至只是configuration挂载(并使用noauto )。 然后使用mount -a或mount /home/s3backup/mnt/FOO来挂载它。
另一种方法是使用别名进行挂载,以检查文件系统是否已经挂载,或挂载点是否已经安装了FS。