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

mount -t cifs // -o password='' /mnt/tera_nas

rsync -av --super --delete --recursive /home/ /mnt/tera_nas/home/

# sleep 5m (i want to avoid using this)

# Bash shell snippet to check if mounted Samba share is not busy before issuing umount command

umount /mnt/tera_nas/
share|improve this question
Are you asking for us to write the "Bash shell snippet to check if mounted Samba share is not busy before issuing umount command" portion of that script? – Evan Anderson Jun 24 '09 at 17:13
up vote 3 down vote accepted

I would just lazy unmount it, using the -l flag. This will remove the mount point from the filesystem (so no new operations can start), and will finish the proper unmount once it is no longer busy.

share|improve this answer
As per umount -l /mnt/tera_nas Did the trick for me. Thank you. – cgomezsilva Jun 30 '09 at 18:10

you could lsof to see if it has any open file descriptors

share|improve this answer
Agreed. I'd do lsof -n | grep mountpoint – Matt Simmons Jun 24 '09 at 17:41

you could use "fuser -m mountpoint" to see if anyone is accessing the path.

share|improve this answer

Let umount do the work for you:

while ! $(umount /mnt/tera_nas/ 2>/dev/null)
    echo "not yet"
    sleep 5m
echo "now it is"

You could shorten the sleep time, but I wouldn't eliminate it. It serves a different role here than in your question.

share|improve this answer

2Dennis Williamson:

I'd rather use

umount -l /mnt/tera_nas

at the end.

share|improve this answer

Use automount to do this for you automatically, the mountpoint /mnt/tera_nas/home/ will be mounted automatically when it is accessed, then unmounted once it is no longer needed.

# /etc/auto.master
/mnt auto.mnt

# /etc/auto.mnt
tera_nas -t cifs,password='' ://

Then service autofs restart

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.