Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Quickly eject all disks from the command line UNIX
Instead of using the following to eject all disks:
osascript -e 'tell "Finder" to eject (every disk)' 
I've found that this is much faster:
find /Volumes -maxdepth 1 -not -user root -print0 | xargs -0 diskutil eject 
Run this command from Terminal, or in a shell script, to eject all your local disks.

To eject network volumes, this code works:
find /Volumes -maxdepth 1 -not -user root -print0 | xargs -0 umount 
[kirkmc adds: The problem with this hint is that each line of code works for different types of volumes. If you have both local and network volumes, you need to use both; you could, of course, stick them together with a semi-colon separating them so they are, in effect, a single command.. In my tests, it's not really faster than the osascript code above, but I'm posting it because some may find it useful. If you have different results in speed or efficacy, please post in the comments.]
    •    
  • Currently 1.80 / 5
  You rated: 1 / 5 (5 votes cast)
 
[7,876 views]  

Quickly eject all disks from the command line | 2 comments | Create New Account
Click here to return to the 'Quickly eject all disks from the command line ' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Quickly eject all disks from the command line
Authored by: S Barman on Sep 05, '12 08:43:04AM

Unless something changed in Mountain Lion (I have not upgraded, yet), then you can just "eject" a network drive to unmount it.



[ Reply to This | # ]
Quickly eject all disks from the command line
Authored by: Lri on Sep 06, '12 05:54:20AM

find /Volumes -maxdepth 1 -not -user root -a -not -name '.*' -print0 | xargs -0 diskutil eject wouldn't match /Volumes/.DS_Store.

I didn't see any difference in their speed either.



[ Reply to This | # ]