Fixing Mountain Lion’s Deep Sleep Issues

Not too long ago, I wrote about having a SMountain Lion Yawningleep/Wake issue on my Macbook Air’s Mountain Lion installation. In summary, my laptop won’t wake up when it enters hibernate as part of safe sleep and the issue can be quickly reproduced by forcing it to hibernate each time it sleeps.

It appears I have solved the problem by reinstalling OS X. I did tried reinstalling it before, but apparently there’s a broken system-level configuration that get brought back by the Migration Assistant after I copy my files back. So this time I only migrate only my files and application but leave out all other stuff.

Here are the steps that you can also try if you’re experiencing a similar problem.

Prerequisites

Make sure that you have these ready before you start wiping your hard drive.

  • a copy of Mountain Lion installer in an external drive.
  • a copy of the latest combo update (10.8.2 at this time of writing). You definitely need the combo update and not the incremental update.
  • your Time Machine backup drive updated to the last minute.

Reinstall Steps

  1. Reboot your machine and hold the Option (⌥) button before the gray screen appears until you get a selection of drives to boot from.
  2. Choose to boot from the Recovery Partition.
  3. Open Disk Utility and erase your internal drive (primary system partition). Be sure to format it as HFS+ Journaled. Do not erase the recovery partition!
  4. Plug in your external drive which contains the OS X Installer and Combo Update.
  5. After your internal drive is formatted, open Terminal to copy the OS X installer app and combo update into your main drive. Do something like this:
    cd "/Volumes/Macintosh HD"
    mkdir Installers
    cd Installers
    cp "/Volumes/{your-external-drive}/{your-folder}/Install OS X Mountain Lion.app" .
    cp "/Volumes/{your-external-drive}/{your-folder}/OSXUpdCombo10.8.2.dmg" .
  6. Run the OS X installer app from the Terminal – you’ll need the Terminal since booting from the Recovery Partition doesn’t give you the normal Finder.
    ./"Install OS X Mountain Lion.app/Contents/MacOS/Install OS X Mountain Lion"
  7. Follow the instruction on the screen to install OS X as per normal.
  8. If the installer got stuck at “rebooting your computer”, just restart your computer yourself from the Apple menu.
  9. After restart, follow the on-screen instruction as per normal.
  10. When installation is completed, do not migrate your data nor setup iCloud – not yet. Just create a new temporary administrator account that you will delete afterwards.
  11. Login as the temporary account and install the combo update that you’ve copied to your main drive earlier.

Post-install checks

At this point, you will have a “clean” installation of OS X with its latest updates. Before migrating your data or applications back, you’ll need to do some sanity checks before proceeding to make sure that reinstalling fixes the problem. If the test fails at this point, this is definitely either Apple’s bug or hardware issue. It can’t be blamed to 3rd party applications or drivers since these aren’t even installed yet.

Open Terminal and type this

sudo pmset -g

Enter your password if prompted. Then lookup the value of “hibernatemode” and take a note of it. This should be either 0, 3, or 25. Likely will be 3 for portables and 0 for desktops.

Pmset hibernatemode

Having recorded the current hibernation mode, then follow these steps if you’re using a portable Mac. If you’re using a desktop, choose Sleep from the Apple menu instead of closing the lid.

  1. Charge the laptop until the battery is full.
  2. Disconnect any other attached devices from the unit – this includes external monitors, external hard drives. Also turn off Bluetooth to ensure that no other devices are connected.
  3. In the Terminal, type:
    sudo pmset -a hibernatemode 25
  4. Close the laptop’s lid.
  5. Wait for about a minute.
  6. Disconnect the power brick from the unit.
  7. With the power brick still disconnected, lift the laptop’s lid.
  8. Try pressing the keyboard (spacebar works best) or clicking the trackpad – see if the machine wakes up.

If the machine wakes up by a simple keyboard press or trackpad click, it’s all good. If key presses does not wake up the unit, you can hold the power button for about 10 seconds then release it to force the unit to reboot. You might have a hardware issue, which then you should take it to to Apple for repair or warranty claim. It would be a good time to do that too, since your personal data are already erased from the machine and you can be sure that the repair technicians can’t access your data.

If the test was successful, restore the hibernation mode using the following Terminal command:

After that change the hibernation mode to 25 using the following command:

sudo pmset -a hibernatemode {original value}

If you like more information about this command, type man pmset in the Terminal.

Data Migration

Now you’re ready to copy your data back. You use the Migration Assistant app to do this, but you need to do it in a special way so that the broken operation system configuration files doesn’t get carried back into the machine.

  1. Plug in your Time Machine drive (or otherwise mount it if its on the network)
  2. Start Migration Assistant (in the utilities folder) to restore your data back.
  3. Follow the instructions on your screen. Be sure to migrate only user data and applications – don’t migrate anything else.  One of these are likely the one that caused the sleep/wake issues.

Migration Assistant Uncheck Others

You should see a screen similar to the above screenshot in the middle of Migration Assistant dialogs. Uncheck “Settings” and “Other files and folders” checkboxes so that only the important stuff gets migrated. You can always copy these back manually from your Time Machine drive if you need it.

Post-migration

When your files and applications are migrated, you should run through the post-install checks again to make sure that hibernation still works and migration didn’t break it again. Also do this test again after you have setup iCloud (somebody reported in the Apple Forums that iCloud, particularly Back to My Mac or Find My Mac are the ones that breaks hibernation) just to be sure.

 ICloud causing hibernation issues

In addition, you might need to install Java and/or Adobe Flash if you use them. Also Microsoft Office 2011 likely needs to be reinstalled, as well as other applications that uses a custom installer.

Good luck and let me know how it goes!

Tags: , , , ,

  • Jason Foreman

    Interestingly I did a complete re-install of OSX and by the way…good advice..partition your hardrive into three.  One for media the other for OSX & Apps, the other as the User.  When I reinstall OSX all my settings including keychains are intact including the serials for my software.  All yo need do is install your apps.

    Make sure that in the user account you change the user lcation to the one you hae set up.  Copy all you data from the current user first to the new partition and then you’re good to go.

    Back to OSX hibernation…it worked fine then one day it my MBP (2011 late) would not wake up again.  I’ve set the hibernate mode to 25 so hope this works OK.

  • Vicki Brown

    Yikes!
    There needs to be a better way than “wipe and reinstall”.

%d bloggers like this: