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

Click here to return to the 'Automatically eject/mount disks on sleep/wake' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Automatically eject/mount disks on sleep/wake
Authored by: egg1000 on Jun 13, '08 03:17:47AM

Slight problems with this tip.....

1) It doesn't work, the device eject warning still occurs.
2) It increases the amount of time your mac takes to sleep by alot!
3) It creates a whirly sound on wake, hoorah!

Otherwise useless, now, can someone please advise on how to reverse the changes? I would be very grateful.



[ Reply to This | # ]
I finally got Sleepwatcher to work
Authored by: tomhayes on Dec 16, '09 03:16:05PM

I recently purchased a SmartStrip power outlet for my computer setup to turn off devices when the computer went to sleep.

It worked - except for my Hitachi Simpletech 2GB drive. The external drive has a "power on auto" feature where you plug it into the wall and then into to the computer and only when both the wall outlet and the computer are on does the drive come on.

When the computer went to sleep the Powerstrip would turn off power to the hard drive and the USB port on the Mac would sense that the drive was removed and it would trigger some sort of event where the computer would immediately wake from sleep and I'd get a Device Removal Warning.

I then plugged the external drive into one of the "Always Powered" outlets, but it had the same issue.

I downloaded SleepWatcher ( and installed SleepWatcher and the Sleepwatcher start-up items program.

I created a file in my home directory as named .sleep and chmod r+x it. (note this thread kept talking about Desktop/.sleep , it should be in your home directory which is commonly refereed to as "~" or something like /bootdrive/usr/yourusername)

.Sleep contained the following command:
osascript -e 'tell application "Finder" to eject "2TB"'

Where 2TB was the name of my external drive.

When the computer went to sleep Sleepwatcher started and finder started to eject the drive and the computer went to sleep. The drive did not completely unmount before the computer went to sleep and it triggered some event that would wake up the Mac. The external drive would turn on and mount again with the Device Removal Warning effectively stopping sleep.

So I modified .sleep to contain:
osascript -e 'tell application "Finder" to eject "2TB"'
osascript -e 'tell application "Finder" to delay 10'

Now the drive unmounts, finder waits 10 seconds and then the computer sleeps. It works like a charm.

I created a file called .wakeup that contains:
backupsVolume=`diskutil list | awk '/ 2TB / {print $6}'`
if [ ! -z "$backupsVolume" ]
diskutil mount $backupsVolume

This mounts the drive when the computer wakes from sleep.

Thank you to Sleepwatcher, this thread, and ( for helping me with this.

P.S. I am running this on a Mac pro with Snow Leopard.

[ Reply to This | # ]