If you have a MacBook system that you regularly use at a desk such as in an office work space, then you may have a number of peripheral storage devices set up to manage backups and work-specific data, whether attached directly to the system or through a Thunderbolt, FireWire, or USB docking device. These can be convenient when you need them, but quite the opposite when you're packing up to depart.
The main reason for this is OS X's requirement that you manually unmount each drive that's attached to the system by either dragging it to the trash, clicking the eject button next to it in the Finder sidebar, or using the Eject function in the system or contextual menus. If you have multiple drives attached, you will need to systematically eject each one or chance interrupting communication with the drive, which may result in data loss.
While this isn't as much of an issue with desktop systems, with a laptop it is often easy to close the lid and pull the plugs to quickly be on your way, only to wake the system to a number of warnings about not having properly ejected your disks.
Luckily, with the use of Terminal commands and Apple's Automator utility you can set up a hot key to quickly unmount all drives from your system, which should speed up your escape.
To do this, first open the Automator utility in the OS X Applications folder, and then follow this procedure:
- Create a new Service work flow
- Set the service to receive "No Input" but work in "All Applications"
- Locate and drag the Run Shell Script action to the work flow window
- Change the default "cat" command to the following two commands (the first removes all "ejectable" media like optical disks, and the second unmounts all drives except for those in use, such as the boot drive):
diskutil eject /Volumes/*
diskutil unmountDisk /Volumes/*
- Save the service with an appropriate name (such as EjectAll)
At this point you can test the work flow to see if it ejects your disks for you (it should). Since the work flow is a service that is available for all applications, it should now be available in the Services submenu of the application menu (next to the Apple menu) for the foremost program. Additionally, you can set a custom hot key to invoke this service at any time. To do this, go to the Keyboard system preferences and select the Services section in the Keyboard Shortcuts tab. In here, locate the new service by the name you gave it (it should be listed under General) and click the "Add shortcut" button to assign a hot-key sequence to it.
With this done, you can now invoke the hot-key sequence or select the service from the application menu to quickly unmount and eject all attached drives and have your system ready to go.