Automate the unmount of a disk at startup?

Hi,

I have searched through the forums but cannot find the (basic) help I need.
I would like to be able to automate the unmounting of one of my internal HDs at startup and also create something I can put in the Dock to mount it again if necessary.
So far in my script I have:

dskutil unmount/Volumes/CLONE

(but I get a syntax error)

Thanks in advance!
Dickie

Model: Mac Pro
AppleScript: 2.1.1
Operating System: Mac OS X (10.4)

tell application "Finder"
	eject disk "CLONE"
end tell

Thanks for your speedy reply!
I’ve just created the script & it compiled OK but it doesn’t work - my disk is still there.
Would it be because it needs to be unmounted (rather than ejected) which is something Finder doesnt appear to be able to do…???

/ponder

And you put it in your startup items?

Finder’s eject is similar to doing a umount, but to try the other method the script should read

do shell script "dskutil unmount/Volumes/CLONE"

Thanks again.
Yep, tried that (and put them in my startup items) but on startup they just launch so the script is up on my screen but the disks are still there…

Shouldn’t “dskutil” be “diskutil”?

This is a bit of a stab in the dark since I only have one internal drive (and I use TinkerTool System to mount externals on startup instead of log in), but is it possible that your script is triggered before the volume has finished mounting? Have you tried a delay?

You’re right - diskutil it was.
This looks better now, but how do I add in a delay line?

If that’s the problem, then:


delay 1--second (increase until it works)

do shell script "dskutil unmount/Volumes/CLONE"

No - still doesn’t unmount the disk.
Script editor is being launched on startup but the script didn’t appear to have run or be running so I ran it manually (it delayed for 15 secs) but then nothing.
Any other ideas?

Hi,

save the script as application, then it runs without involving Script Editor

Hi

this without “disk” in it works for me

tell application “Finder”
eject “CLONE”
end tell

Thanks StephanK & Budgie but neither worked.
I saved as an application then ran it. It delayed but then didn’t unmount the disk.
Same when I changed the script and followed your suggestion Budgie (although I do think it does need to be an ‘unmount’ and not an eject).
If you can think of anything els then please let me know.
Thanks all for all your help.
Dickie

capitalj’s sytnax is quite wrong

do shell script "dskutil unmount/Volumes/CLONE"

the correct syntax is:

do shell script "diskutil unmount '/Volumes/my CLONE'"

It’s diskutil, after unmount must be a space character and
if the name of the volume contains also a space, the single quotes are necessary.

Note: using diskutil unmount can take a few seconds until the volume disappears from the desktop

Oops - typo, sorry. And I typed “dskutil” after pointing out that error earlier! How embarrassing.

Stefan, thanks very much! You’re spot on. I’ll forgive your typo!
(It’s just a shame the script takes a while to run as this almost defeats the object)
Thanks again mate.

Couple of comments.

¢ If your Clone is a backup partition on your internal hard disk that isn’t going to help much with a disk failure. It better be a second hard drive.

¢ You can’t unmount a disk that isn’t mounted, and since this one is part of your internal disk(s) it must show before you can unmount it unfortunately. There is no way I know of to leave an instruction not to mount a disk at startup because that’s all happening pre-system – the hardware/firmware is looking after it.

Adam, thanks for your comments. Yes, my CLONE is a partition of a SECONDARY drive (if a disk goes then you’re gonna lose the lot!)
Its just a shame that the system boots up and the disk is mounted for a good 15 seconds (which is actually a long time if you’re counting) before the script can actually unmount it - would be great if i could get the script to run before the log-on screen is displayed.
Thanks again
Dickie

You might want to consider TinkerTool System (€7) which has a setting to mount disks on startup. Then your script could unmount the clone faster.