I have a new 13" Macbook Pro running Mavericks. This computer is connected to an external USB drive which I use for my Time Machine backups and for external storage Time Machine backups occur a few times per day and the drive is largely inactive for most of the day.
When I am rushing to a meeting, to the server room or I'm heading home at the end of the day, I would like to do the following:
- Close the lid on my Macbook, quickly.
- Have the Mac automatically unmount all external drives, as quickly as possible, and forcibly if required. I'm willing to wait a few seconds for the all of lights to turn off.
Is there a way to get the computer to automatically unmount all external drives as soon as I close the lid on my Mac?
Currently if I forget to unmount the external drives, my Mac chastises me later with the error "The disk was not ejected properly. If possible, always eject a disk before unplugging it or turning it off."
I know it is best practice to always unmount a disk cleanly before removing the disk interface, but I'm looking for an automated solution. I am not very concerned if one Time Machine backup image is interrupted or corrupted, as one of the next subsequent backups will work and I very rarely ever need to restore from backup. Since the filesystem is a journaling filesystem, the journal transparently takes care of many other filesystem corruption errors.
Best Answer
There are a number of apps that can run scripts on sleep:
A bash script such as the following will unmount all specified disks:
To unmount all volumes except
/
:or more cleanly…