Easy? Why doesn't this script eject a partition

i can tell the finder to eject/unmount a server volume, or firewire volume…but why doesn’t it work w/ a secondary system partition. my drive is partitioned into two volumes…both volumes have 10.3.7 installed…this should be easy, right?

here’s what i’m working with (Backup is the name of the volume i’m trying to unmount)
tell application “Finder” to eject “Backup”

I think you’ll find that you can’t eject a partition even if you attempt to do it directly from the Finder. The meaning of the verb “eject” is tied to removable drives. In general, mounted partitions are not intended to be removable.

I suggest either trying to find another scriptable application that will unmount the partition, or else try to come up with a way to do it with a shell command.

Unfortunately, it doesn’t look like Apple’s Disk Utility is scriptable…

hmmm…so use something like Quickeys to physically drag the partition to the trash?

I didn’t realize the Finder let you get away with dragging partitions to the eject icon. Very interesting! I’d say it’s probably a bug, but who knows.

Maybe somebody else will be able to come up with something less drastic than scripting a drag to the icon. Thats seems kind of flimsy. I bet you can do this somehow with a UNIX command line tool.

Daniel

So I dug around and with the help of some internet clues I discovered that hdiutil can be used to unmount regular ol’ volumes. I thought it was only for disk images.

An example to unmount a volume (partition or not) named “MyPartitionName”:


UnmountPartition("/Volumes/MyPartitionName")

on UnmountPartition(partitionPath)
	do shell script "hdiutil unmount " & partitionPath
end

Hope this works for you!

Premature success. That actually seems to unmount all the volumes on the partition (except the boot volume, thankfully!).

Just for the heck of it, have you tried:

tell application "Finder" to eject disk "Backup"

The original code didn’t use the ‘disk’ object so you were essentially trying to eject a string.

Can’t hurt to try.

Finder doesn’t seem to have a problem interpreting “string” as a disk name in the context of the eject command.

Adding “disk” didn’t make any difference in my tests. Finder quietly refuses to eject a partition.