Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

nlynch77

macrumors member
Original poster
Mar 18, 2013
46
2
Hello again MacRumors. Some time ago I installed an SSD in my 2011 MacBook Pro and moved the old HDD to the Optibay. All was good - except that it would never spin down. And if it did (after the 1 minute timer I set with pmset disksleep 1) it would quickly spin back up again for some reason or another. So enter my solution, remapping the eject key for dynamic, user-controlled disk startup/shutdown! Sadly, it takes a very roundabout way to make it happen.

First, KeyRemap4Macbook, the program that makes this possible. Many thanks to the author! When you install, find "remap eject key" in the options. I remap'd eject to F13, but any unused button would do.

Second, BetterTouchTool, which everyone should already have. When BTT is installed, add a new keyboard option so that F13 will activate an applescript (attached).

Third (optional), an Automator action that allows you to post stuff to the Mountain Lion/Mavericks Notification Center. Makes this hack very aesthetic and functional.

Make sure to enter your username and password in the script (so you don't need to authenticate every time)
If you do not care about pretty Notification Center pop-ups, only download the Sample.zip, and remove any lines that have "tell application "___" to activate"

These files I posted will work from anywhere (I think) so bury them deep in your Documents folder and forget.
 

Attachments

  • Mounted.app.zip
    1.5 MB · Views: 135
  • Mounting.app.zip
    1.5 MB · Views: 112
  • Unmounted.app.zip
    1.5 MB · Views: 100
  • Unmounting.app.zip
    1.5 MB · Views: 122
  • Sample.zip
    2.5 KB · Views: 115

Intell

macrumors P6
Jan 24, 2010
18,955
509
Inside
Why don't you just make a launchdaemon that will eject, not unmount, the drive when none of its volumes are mounted? That way the system will automatically suppress its spinups within a few seconds. You want to use the diskutil eject command instead of the unmount command because the eject causes it to stop spinning immediately. I could possibly rewrite and package my current solution for easy distribution.
 

nlynch77

macrumors member
Original poster
Mar 18, 2013
46
2
I would love to see an alternate way to do this, mine is rather clunky. The reason I chose to eject immediately is because the command diskutil unmount [diskname] doesn't immediately spin the drive down, whereas eject does, as well as ejecting any other partitions on the drive. When I (rarely) need to use the drive, I want to be able to press one button to turn it on, then one button to turn it off.

A launchdaemon would be continuously running/checking the state of the drive, and I would need to use Finder to eject the drive, and the eject button doesn't eject anything other than CD's for some stupid reason.
 

subwelt

macrumors newbie
Jul 4, 2012
23
0
Germany
I am also about to put a SSD into my 2011 MBP and move the HD to the optibay. I tried to work through a 68-page long thread about the procedure and sort of gave up. Then I found this little thread which is a lot more digestible.
So this is it for a problem that thousands of people must have? Manually switching the drive on and of? Actually I quite like it. The HD is only for storage anyway.
But still I am puzzled. Is that what everyone is doing? Or are there other more orthodox solutions? Is everyone affected?
I will try it out as soon as my slate arrives. Thanks for sharing nlynch77.
I am not knowledgeable enough to try the Intell solution without further explanations.
 

Maydon0z

macrumors newbie
Mar 23, 2013
25
0
The sound of silence

I know my post will revive this old thread, but I found a solution to spin down the Optibay harddisk in Mavericks.

I combined the OP steps with another post I found here on the forums. Here are the steps needed to have the desired silence with just one keyboard click :cool:

1- Get Karabiner and change the eject key to "F13".
2- Open AppleScript Editor and paste this:

set myVolumeLabel to "HDD"

tell application "Finder"
set diskDev to do shell script "diskutil list | grep \"" & myVolumeLabel & "\" | grep -o 'disk[0-9]*' "
if not (disk myVolumeLabel exists) then
do shell script "diskutil mountDisk " & diskDev
else
do shell script "diskutil eject " & diskDev
end if
end tell

Change the HDD to your Optibay harddisk name.
Save the script as a script in a folder you like, i chose Applications.

3- Get BetterTouchTool and assign the eject key (which is now F13) the action to start the script you just saved in step 2.

Now, this will eject the optibay harddisk if it is spinning and will mount it when you need it. Step 4 could be to hide the icons of Karabiner and BetterTouchTool to clean the menubar, but this is optional.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.