12

I've done some quick Googling but didn't find an answer. I've put an SSD in my MacBook, and at the same time moved the original hard drive to the optical drive bay. I'm running the OS and most of my daily apps off the SSD so the hard drive is really just for storing stuff I need now and then.

Now I'd like to disable (as in power off or "force sleep") the hard drive when I don't need it. Tried unmounting the disk using diskutil unmountDisk but it kept spinning for like 10 minutes. Maybe that's to be expected, but I'd imagined it would stop instantly on unmount. Also, it would be nice to have it disabled by default, and only mount it (= power on) when I need it.

10 Answers 10

-1

Because Apple doesn't want you to do this... sorry, this bay is basically limited to "DVD" functionalities. So what this means is that it will "act" and control the drive just like a DVD drive and not an hard drive. Macbook's are way more custom than people think... You may also learn at the same time that the power output for this bay is limited and many hard drive's are not supported.

4
  • Ah OK I see... Guess simply unmounting it will have to do then. Off to script the unmount process... Thanks!
    – cpak
    Mar 9, 2011 at 10:13
  • I have the same question for Windows 7, is it possible there?
    – danny
    May 21, 2011 at 21:09
  • I would like to see some references to back this up. The optical bay uses as a sata connection, not unlike the one for the main storage. I don't see why it'll be treated in any special way. OP, you can try testing this by putting the SSD in the optical bay, and the HDD in the main bay.
    – Alexander
    Mar 5, 2015 at 4:48
  • No to this!!! The only way Apple crippled the optical drive bay was that they used a SATA II port (like in the 2010 MacBook Pro). There is no difference in ATA ports and the commands you can send to them. That's only limited by what the OS allows you to do and macOS doesn't support this.
    – Allan
    Oct 30, 2020 at 15:51
13

I do not agree with deijmaster. A SATA port is a SATA port. It does not make any difference to the OS that it's usually used for DVD.

I have also moved my HDD to the optical bay.

The best thing I have found so far to reduce noise is:

  • Make sure that you enable disk sleep in Energy preferences.
  • Then, run in Terminal:

    sudo pmset -a disksleep 1
    

To sleep the disk after only 1 minute.

Also, if you disable Spotlight on this drive, the drive will not spin up when you open Spotlight. To disable spotlight:

sudo mdutil -i off /Volumes/TSA-Data 

(Or the conventional way: drag the drive (all partitions) from the Finder sidebar to the list of places that Spotlight excludes, in the Spotlight Preferences)

It still spins up some times without obvious reason.

9

I made the following compact script with help from earlier answers. The script mounts and opens the secondary drive (disk1, here "HDD") if it isn't mounted, and ejects it if it is mounted.

I also reduced the the idle time to 1 min (in terminal: sudo pmset -a disksleep 1) and placed "HDD" in the list of Spotlight exceptions where it reappears every time it's mounted.

Then, the disk won't start too often but will go back to rest quickly, when mounted of course. Note also that unmounted disks can start when using e.g. system info and disk utility.


Use the correct disk name instead of "HDD" below!

The script MountHDD.scpt:

tell application "Finder"   
if not (exists the disk "HDD") then   
do shell script "diskutil mountDisk 'disk1'"      
tell application "Finder"                 
activate    
make new Finder window     
set target of Finder window 1 to disk "HDD"    
end tell    
else   
do shell script "diskutil eject 'disk1'"      
end if   
end tell   

Save the script as a program (.app) and place the program in Dock!

Note that the disk still spinns up (unmounted) at boot and wake up. Run the app once/twice (mounted/unmounted) to sleep it. if you do nothing it will spin the idle time (1 min if sudo pmset -a disksleep 1 is used) and then stop.

4

So I also did some of the Googling and found nothing that really helped. After combining some stuff I found running

hdiutil eject disk1

in Terminal to work. If you get info in Disk Utility you can see if the drive you want to eject is disk0 or disk1 or whatever. I find some times the disk will spin back up if I do things like open Disk Utility again.

4

My final solution was to create an Automator application which I run from Spotlight.

  • One for ejecting the HD;

    Run Shell Script: diskutil eject 'disk1'

  • Another for mounting the HD;

    Run Shell Script: diskutil mountDisk 'disk1'

Where disk1 is the name of the disk you want to spin down/force to sleep/eject. This name is found in "System Information".

1
  • I have the same scripts on my system, but none of them appear to turn off the 2ndary drive - it's always spinning, even when unmounted! Definitely drains battery WAY faster than an idle DVD drive...
    – Demis
    Nov 8, 2015 at 5:15
2

Here is simple apple script:

set answer to the button returned of (display dialog "Your second HDD wants to?" with icon caution buttons {"Wait", "Sleep", "WakeUp"})

if answer = "Sleep" then
    do shell script "hdiutil eject disk1"
else if answer = "WakeUp" then
    do shell script "diskutil mountDisk disk1"
end if
2

I found that I also had to run mdutil -d /Volumes/<hard disk> to get it to stop searching the drive as well, since doing a stop on indexing did not prevent it from searching it since it had been indexed once already.

Now I can hit spotlight and the second drive stays spun down.

1

Format second disk in optic drive as standard Mac OS journaled like a external drive. Then move it into the private section of spotlight. You can also unmount it on disk utility since OS will not be present on that disk which means no terminal. Disk will only spin up when you click on it.

1

I've made applescripts to both mount and unmount my drive.

Regular HDD in my optical bay. Macbook Pro (late 2006). OSX Lion

Drive spins down and stays that way unless you open disk utility, resume from sleep, or remount the drive. Spotlight doesn't cause the drive to spin up. Neither does trying to access any alias on the drive.


-If there's running processes open that prevent the drive from ejecting, the script opens Activity monitor and runs lsof in a Terminal window.

-You can then decide if the process should be killed.

-A dialog box asks for user confirmation to kill.

I run these from the applescript menu. You can enable it like this:

  1. Open AppleScript Editor.app (Applications -> Utilities).
  2. Open Preferences….
  3. Check "Show Script menu in menu bar".

Mount drive

on run
    try

        do shell script "diskutil mountDisk disk1"

    on error

    end try
end run

Unmount drive

on run

    try

        do shell script "hdiutil eject disk1"

    on error

        tell application "System Events"
            set termOpen to count (processes whose name is "Terminal")
            set amOpen to count (processes whose name is "Activity Monitor")
        end tell


        tell application "Terminal"
            activate
            set newTab to do script "lsof /Volumes/'HFS HD'"
        end tell

        tell application "Activity Monitor"
            activate
        end tell

        delay 3

        set question to display dialog "Kill running?" buttons {"Yes", "No"} default button 2
        set answer to button returned of question

        if answer is equal to "Yes" then
            do shell script "lsof -P | grep '/Volumes/HFS HD'  | awk '{print $2}' | xargs kill -9"
            do shell script "hdiutil eject disk1"
        end if


        tell application "Activity Monitor"
            if amOpen is 0 then
                quit
            end if
        end tell

        tell application "Terminal"
            if termOpen is 0 then
                quit
            else
                close (first window whose selected tab is newTab) saving no
            end if
        end tell



    end try
end run

Works perfect for me, hopefully you also have success!

1
  • Does this actually "Turn Off" the drive? For me, unmounting (in various ways - diskutil, hdutil etc.) still leaves the HDD spinning.
    – Demis
    Nov 8, 2015 at 5:16
0

As for other posters, this worked for me.

  • I run the commands in Terminal when I want
  • I did not have to disable Spotlight in any way
  • I can instantly spotlight the drive once it is mounted

I will try some of the suggestions on automating it or simplifying it.

// unmount
hdiutil eject disk1

// mount
diskutil mountDisk disk1

Setup: MacbookPro 7,1 13 inches with Mountain Lion 10.8.3. The secondary hard drive in place of the dvd drive, the main drive being a SSD

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .