views:

153

answers:

1

Is there a way to eject all the mounted hard drive volumes on an OS X computer from the command line? Applescript is OK if I can wrap that in a shell script.

+1  A: 

In Terminal try:

  • umount -a (All the filesystems described via getfsent(3) are unmounted.)
  • umount -A (All the currently mounted filesystems except the root unmounted.)

Fore more information see man umount.

Update:

Seems like you can also use this:

diskutil unmountDisk /dev/disk*

Didn't test it, though. If it doesn't work, try to use "unmount" instead of "unmountDisk".

Oh, I also found the eject argument (instead of unmountDisk). That might also be of interest.

Update 2:

diskutil eject /dev/* seems what you are looking for (see comments).

BastiBense
that's doesn't work for some reason
dan
Why not? Any error messages? If so, please post them here. Also did you try the "-A" option (capital A).
BastiBense
I tried umount -a, and a finder window opened, but that was it. I'll have to try the other commands tonight when I'm back where my external hard drives are.
dan
`diskutils eject /path/to/volume` worked
dan