Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a Ubuntu Server, a NAS, and I am using CIFS protocol to mount. I ran into a situation where I had repeats of the same mount. The below is the output of me running the 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)

At this point, if I umount 3 times, I will finally dismount everything.

How would I be able to prevent this stacked mounting, either in mount options or in smb.conf on the NAS?

If not, can I get a warning when I try to mount on top of something?

Thanks!


Hi I wrote a short bash script to check. I've tested on Mac. Use at own risk :).

#!/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
share|improve this question

1 Answer 1

You can use /etc/fstab to mount or even just to configure the mount (and use noauto). Then use mount -a or mount /home/s3backup/mnt/FOO to mount it.

Another alternative is to use an alias for mount that will check if the filesystem is already mounted or if the mountpoint already has a FS mounted at that point.

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.