psyrendust

A mix of code and life, by Larry Gordon

ejectAllVolumes

Eject all mounted volumes from your Mac

Eject All Volumes is a Dashboard widget that will unmount any volume that you are connected to. It will eject USB, Firewire, CD-ROM, DVD, and network mounted volumes. The script will exclude “Macintosh HD” from the unmount action. Volume names that contain spaces are supported (eg. “The Volume Name” or “SEAGATE 1″).


Table of Contents


Issues

I use a Macbook Pro for work. We have a large number of network volumes that I have to connect to on a daily basis. I also connect several USB HD’s to my laptop, most of which are usually split into multiple volumes.

On a daily basis I’ll have to following connected to my computer:

  • MagSave Power Connector
  • DVI Monitor (24″ Cinema Display)
  • Ethernet Cable
  • FireWire 400 Cable (connected to the Cinema Display)
  • USB 2.0 Cable (connected to the Cinema Display)
  • WD External USB 2.0 HD
  • Several Network Volumes

Here is a sample list of volumes that I may be connected to:

Last login: Thu Jun  5 14:14:34 on ttys000
larryx:~ lgordon$ ls -l /Volumes/
total 72
drwx------   1 lgordon  staff  16384 Jun  5 10:37 MRM Interactive
drwx------   1 lgordon  staff  16384 May 19 13:04 MRM Jobs
lrwxr-xr-x   1 root     admin      1 Jun  3 01:17 Macintosh HD -> /
drwxrwxr-x  18 lgordon  staff    680 Jun  3 17:11 Media
dr-x------@ 18 lgordon  staff    568 May 29 13:12 Public
drwxrwxr-x  19 lgordon  staff    714 May 14 12:38 Storage
drwxrwxr-x  23 lgordon  staff    850 May 27 23:45 Work

There are a lot of times where I’m in a hurry to get somewhere and I unplug all of my cables, thus resulting in this error:

Device Removal Error (Mac)

Or you try to safely eject a volume only to be greated with the following prompt:

Eject Prompt (Mac)


Solution

I wanted to be able to eject all of the mounted volumes safely in one action. This had to work under the following criterias:

  • Safely disconnect mounted network volumes.
  • Safely disconnect mounted external hard drives (USB and FireWire).
  • Handle volume names that containe spaces (eg. “MRM Interactive”).
  • Don’t try to disconnect “Macintosh HD”.
  • Do it all in one action!

If for some reason there is a problem with ejecting a mounted volume, the script will pass a message to terminal. This may occur if you are currently working on a file that lives on the mounted volume. Simply stop and/or close all actions to the mounted volume and run the script again.


Change Log

ejectAllVolumes widget v1.1.0
ejectAllVolumes widget v1.0.1
ejectAllVolumes v1.0.1
ejectAllVolumes v1.0.0


Download

ejectAllVolumes is released under the MIT License.

Script File

Download ejectAllVolumes 1.0.1 (Zip file)
Download ejectAllVolumes 1.0.0 (Zip file)

Dashboard Widget

Eject All Volumes

Download ejectAllVolumes widget 1.1.0 (Zip file)
Download ejectAllVolumes widget 1.0.1 (Zip file)


Use

Place the file somewhere on your HD.

From Finder:

  1. Double-click the file to run the script.
  2. A new Terminal window will open.
  3. The script will run.
  4. Once the process is complete it will say “complete” in Terminal
  5. Quit Terminal

From Terminal:

  1. Open Terminal
  2. cd to the location you saved the script.
  3. Type ./ejectAllVolumes
  4. The script will run.
  5. Once the process is complete it will say “complete” in Terminal
  6. Quit Terminal

Double-click the file to run or run the script from Terminal

2 Comments so far

  1. […] This is an update to the ejectAllVolumes Dashboard Widget. […]

  2. Robert August 23rd, 2008 12:35 pm

    The widget doesn’t work for me. I followed the directions (”From Finder”) and it completed as stated but the “Eject” button on the widget does nothing.

Leave a reply