Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:

// on /home/s3backup/mnt/FOO type cifs (rw,mand)
// on /home/s3backup/mnt/FOO type cifs (rw,mand)
// 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?


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

# USAGE: /home/me
# retcode 0 has mount
# retcode 1 no mount
# retcode 2 is not directory

if [ ! -d $1 ]; then
    exit 2

n_matches=`mount | grep " \`pushd $1;pwd\` " | wc -l`
n_matches=`echo $n_matches`
if [ "$n_matches" = "0" ]; then
    exit 1
    exit 0
share|improve this question

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


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.