tomhoppe.com

Racing, Web Development, Photography, and Beer...Stuff that matters.

Monday, September 22, 2008

How to make a MacBook Pro hibernate

Since I've had the MacBook Pro I've been wanting it to "hibernate" instead of "sleep" when I close the lid. There are times when I've shut the lid, stuck it into my backpack, just to not look at it again for 3 days over a long weekend. During that time, even in regular sleep mode, the battery dies as the laptop is not all the way off. My Thinkpad on the other hand can fully hibernate, in which it turns itself all the way off and stores its current state to the hdd.

Turns out that the MacBooks have the same mode, but its not an option in the menu. After a little digging, I've found a site that tells you what to do. I've outlined the steps below for "mac noobs" such as myself.

  • Go to Finder, Utilities, Terminal
  • type pmset -g | grep hibernate
  • You should see that your hibernate is set for mode 3. This means when it sleeps, your items are saved to the RAM and power stays on. What you want is to set that to mode 5 which will function just like windows hibernate, and actually turn your laptop all the way off while saving where your state to the hdd.
  • Create two aliases, one to enable mode 5, and another to set back to 3 if you want.
  • Type alias hibernateon="sudo pmset -a hibernatemode 5"
  • Type alias hibernateoff="sudo pmset -a hibernatemode 3"
  • Now when you type hibernateon, it will set that mode to 5. Once you do that, type pmset -g | grep hibernate again to confirm that you are on mode 5
  • Your laptop is now set to hibernate like windows when you close the lid. If you ever want to revert back, run terminal again and type hibernateoff

Labels: ,

3 Comments:

Anonymous Anonymous said...

Great tip. I don't know what exactly would mode 5 do though. Will it empty the RAM, why is it better?

October 9, 2008 at 5:29 AM  
Blogger dowroa said...

The man page for pmset isn't too bad, but I am confused as I don't have a clue what mode "5" is:

sudo pmset -a hibernatemode X

Where X is:
0 : NO hibernate - does not write RAM to disk and power off EVER
1 : QUICK hibernate - writes RAM to disk and powers off IMMEDIATELY
2 : LAST RESORT hibernate - keeps power to RAM until battery is low, then writes to disk as a last resort to save your data
3 : HYBRID hibernate - writes RAM to disk right away, then leaves RAM powered until battery is low

The "-a" in the pmset command means it will apply this setting to ALL power profiles. If you want to do it for battery only, use the "-b" option. Charger (wall power) only, use "-c". Or UPS is "-u".

Just a note about #3: If you put your computer to sleep, it will start writing the RAM to disk. If you try to wake it up while doing that, it won't respond. Wait a minute, or until the power light starts blinking on the front of your laptop. Once it blinks, you can press the power button or open the lid to wake it back up.

October 27, 2008 at 7:34 PM  
Blogger Tom Hoppe said...

5 - This is the same as mode 1, but it's for those using secure virtual memory (in System Preferences -> Security).

So you can use 1 or 5, depending on your settings.

I like the comment about using the -b or -c instead of -a if you want different profiles for power cord or battery. I personally like mine to be all the same. I don't ever shut down the mac anymore, just hibernate it all the time.

October 28, 2008 at 9:18 AM  

Post a Comment

<< Home