#!/bin/sh
mount -t cifs //192.168.5.90/share -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/
Asked
Active
Viewed 2,504 times
2

cgomezsilva
- 23
- 1
- 5
-
1Are 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
6 Answers
3
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.

wearearobot
- 56
- 3
-
As per http://serverfault.com/users/1293/dennis-williamson: umount -l /mnt/tera_nas Did the trick for me. Thank you. – cgomezsilva Jun 30 '09 at 18:10
2
Let umount do the work for you:
while ! $(umount /mnt/tera_nas/ 2>/dev/null)
do
echo "not yet"
sleep 5m
done
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.

Dennis Williamson
- 62,149
- 16
- 116
- 151
1
1
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='' ://192.168.5.90/share
Then service autofs restart

Dave Cheney
- 18,567
- 8
- 49
- 56