View Full Version : Is there a way eject a Network mount

07-21-2009, 02:07 AM
I have created a scheduled backup to a disk image on a network volume. SD mount the Network volume and then the disk image without issue. However, even thought the disk image is ejected after the copy, the network volume is not eject. I would also like the Network volume ejected after the copy is completed.

I have created a simple apple script to eject the network volume, but can't figure out a way to run the script AFTER the disk image is ejected. Run script after copy, runs before the disc image is ejected, so the script fails.

Is there a way to eject the network volume after the target disk image is ejected?


07-21-2009, 02:44 AM
One way would be to unmount the network volume after sleeping in the background long enough for the disk image volume to unmount. Are you running your script with the "Run shell script after copy completes" option?

07-21-2009, 09:31 AM
sjk's right here - you'd have to run a shell script, in the background, to do it. Something along the lines of:

nohup /bin/bash -c "sleep 30; diskutil eject /some/volume" &

07-21-2009, 04:30 PM
Thanks for saying it more clearly and writing an example script.

07-21-2009, 11:00 PM
Thanks sjk.

Yes, I am trying to use "Run shell script after copy completes", but I am running an apple script, not a shell script.

I have never run a shell script before, so I will have to research that a bit. Dnanian, do you have a recommendation on how to create the shell script? Do, I just create a text file?


07-22-2009, 12:32 AM
Yes, shell scripts can be created with your favorite text editor. TextEdit would work fine, saving as Plain Text instead of Rich Text. You'd need to make the script executable and might want to change its extension from .txt (e.g. to .sh).

A simple shell script could use osascript (http://developer.apple.com/documentation/Darwin/Reference/Manpages/man1/osascript.1.html) to run your AppleScript.

Or, if your AppleScript is a compiled executable command then SD!'s "Run shell script after copy completes" option should be able to run it.

I'm intentionally terse with details here but plenty can be found with a bit of searching.

07-22-2009, 12:58 AM
sjk's right here - you'd have to run a shell script, in the background, to do it. Something along the lines of:

nohup /bin/bash -c "sleep 30; diskutil eject /some/volume" &

I created a text files with the script as discribed, but it results in an error:

| 09:51:36 PM | Info | ...ACTION: Running shell script eject Drobo2
| 09:51:36 PM | Info | ......COMMAND => Invoking After Copy shell script: /Users/garysumlak/Documents/!Shell Scripts/eject Drobo2
| 09:51:36 PM | Error | sh: /Users/garysumlak/Documents/!Shell Scripts/eject Drobo2: Permission denied
| 09:51:36 PM | Error | ****FAILED****: result=32256 errno=0 (Unknown error: 0)

I am thinking I have to use SUDO, but have no idea how to do this.



07-22-2009, 02:49 AM
You probably just need to make it executable (SuperDuper! run the script as root already).

Do chmod +x '/Users/garysumlak/Documents/!Shell Scripts/eject Drobo2' in a Terminal window.

07-22-2009, 09:40 PM
Thanks Chris. I added ".sh" to the file and changed the attribute to executable.

Although I do not get errors anymore, the network drive does not get unmounted.

Basically, my intent is to NOT have the network drive mounted after the copy is completed.

Maybe I should explain my situation:

I have a Drobo attached to FW800 on a PowerMac G5 Quad.

I create a NetWork Backup folder on the Drobo as the destination for disc image backups from SD.

NOTE: I do NOT share the Drobo volume

I go to each Mac in our home office, mount the Drobo via "Connect As..." into the Admin account of the Drobo's host Mac.

Create an alias of the Drobo volume on the Desktop, so the Admin ID and Password will be automatically entered when the alias is used to access the Drobo. I found SD would not mount the Drobo automatically if I did not create the Alias.

With the Network drive mounted, create the SD copy event and schedule for the backup.

(What I would like to happen) After SD has completed the copy and unmounted the Disc Image, SD unmounts the Drobo volume.

What, happens is, SD works perfectly, mounting the Drobo volume, mounts the backup disk image, completes the copy, unmounts the disk image, and then SD quits. However, the Drobo volume is still mounted.

The log show no errors and the script was executed.

| 03:41:33 PM | Info | ...ACTION: Running shell script eject Drobo2.sh
| 03:41:33 PM | Info | ......COMMAND => Invoking After Copy shell script: /Users/garysumlak/Documents/!Shell Scripts/eject Drobo2.sh
| 03:41:33 PM | Info | ...ACTION: Unmounting G52KDP User Folders
| 03:41:33 PM | Info | ......COMMAND => Unmounting '/Volumes/Drobo2/Network Backups/SuperDuper/G52KDP User Folders.sparseimage'
| 03:41:37 PM | Info | "disk1" unmounted.
| 03:41:37 PM | Info | "disk1" ejected.
| 03:41:37 PM | Info | Copy complete.

I am wondering, does SD have to wait for the script to complete before it goes on to the next step - i.e. unmounting the disk image? I know this was the case with using the apple script.

The main reason I want to unmount the Drobo volume is that if I turn of the Quad, any Mac connect to the Drobo will lock up because the Drobo is no longer available.

Here is the script I am using:

nohup /bin/bash -c "sleep 30; diskutil unmount Drobo2" &

Any suggestions would be greatly appreciated.


07-22-2009, 10:12 PM
You can't unmount "Drobo2". You have to unmount the actual mount point - e.g. /Volumes/Drobo2, if that's where it's mounted. Try this in Terminal before you do it in the script.

07-22-2009, 11:48 PM
Thanks dnanian. Add "Volumes" worked perfectly!

The schedule copy now unmounts the Drobo as needed.