Make my Macbook Pro Hibernate

Filed Under Apple on 2008-02-25, 08:41

Bunki suspends to RAM to enable quick startup

I don’t like to waste battery life, especially when traveling. I love the Hibernate feature in Windows, and have all of my laptops set to hibernate when the lid is closed. The few extra seconds it takes to wake up is worth the saved battery life in my eyes. For those that don’t know here are the different states of the Macbook Pro:

  • On – Computer is awake, screen is on, battery is being consumed based on your power settings
  • Off – Computer is using no power from the battery
  • Sleep – Computer has turned off the screen and has suspended the operating system to RAM (volatile memory).
  • Hibernation – Computer has turned off most hardware and has suspended the operating system to the harddrive

Usually when you close the lid of your MBP, it will be put to sleep, and wake up quite quickly when you open the lid again. While it’s sleeping it’s still consuming battery power, albeit a small amount compared to normal usage. When the battery reaches a certain low level, the MBP will automatically switch to hibernation mode and basically shut off so you don’t lose any of your work. Sleep is great for when you’re actively using your computer, but when you want to stretch out battery life for as long as possible, you want to hibernate. Also to note is that it appears that the newer Macbook Pros also write information to the harddrive when sleeping so that when the battery drops to dangerous levels it can jump instantly into hibernation. Apple calls this “Safe Sleep”. (More info on all the technical stuff here)

A few examples of why you would want to hibernate with your laptop:

  • You’re about to head to the airport on an international flight and you want to use your machine during the flight but still leave enough juice to be able to pull up a map/email/info when you get to your destination.
  • You toss your laptop in a bag and may or may not use it on a weekend trip but don’t want to worry about charging it.
  • You want to conserve every little bit of power you can.

And when you would want to stick with sleep:

  • Your laptop isn’t running off battery power
  • You will be opening and closing your lid quite often
  • You’re running around but actively using your laptop (conferences, meetings, etc.)

Basically you sacrifice the speed of restoring your machine to gain a little bit of battery power or vice versa. Personally I like to get every last bit of electricity that I can.

After some searching I came across a post that explained how to basically force your MBP into hibernation when the lid is closed. It requires a quick bit of work in terminal, but is painfully simple.

In Terminal/iTerm/etc run the following command to determine your current sleep mode:
pmset -g | grep hibernate

This should return one of the following:

  • 0 – Legacy sleep mode. It will save everything to RAM upon sleeping but does not support “Safe Sleep”. Very fast sleep.
  • 1 – Legacy “Safe Sleep”. This is the “Safe Sleep”. Everything your laptop goes into sleep, it will save everything to harddisk. Slow on Sleep and Startup.
  • 3 – Default. As described above, when sleeping, contents are saved to RAM. When battery runs out, hibernate occurs.
  • 5 – Behaves as 1 but applicable only for modern Mac that uses “Secure virtual memory”.
  • 7 – Behaves as 3 but applicable only for modern Mac that uses “Secure virtual memory”.

Now edit and save your /Users/username/.bash_profile file with the following lines:

alias hibernateon="sudo pmset -a hibernatemode 5"
alias hibernateoff="sudo pmset -a hibernatemode 0"

hibernateon and hibernateoff can be any text you want, you just need to remember what you used

Execute the following:

source .bash_profile

Now you have a handy little command that will let you enable and disable instant hibernation on a whim. Whenever you want your machine to hibernate when you close the lid, just drop to a terminal window and type “hibernateon”. When you’d prefer your laptop to just sleep, type “hibernateoff”.

Tagged: ,


Comments

  • Vahan Hartooni

    So if I ever want to set everything to default, I just set the hibernate to 3, right? (BTW I’m using the MacBook Pro w/ core 2 duo)

  • Vahan Hartooni

    So if I ever want to set everything to default, I just set the hibernate to 3, right? (BTW I'm using the MacBook Pro w/ core 2 duo)

  • http://www.geeked.info Ed

    Check to see if you’re using Secure Virtual Memory (System Prefs -> Security) and then set hibernatemode back to 3 or 7

  • http://www.geeked.info Ed

    Check to see if you're using Secure Virtual Memory (System Prefs -> Security) and then set hibernatemode back to 3 or 7

  • Patrick

    Could you please explain this step in more detail:

    Now edit and save your /Users/username/.bash_profile file with the following lines:

    alias hibernateon=”sudo pmset -a hibernatemode 5″
    alias hibernateoff=”sudo pmset -a hibernatemode 0″

    I’m having trouble finding that file.

    Thanks!

  • http://www.geeked.info Ed

    .bash_profile (notice the period) is a “hidden” file in your home directory. Try the following command:

    pico ~/.bash_profile

    and then add the two alias lines

  • Patrick

    Could you please explain this step in more detail:

    Now edit and save your /Users/username/.bash_profile file with the following lines:

    alias hibernateon=”sudo pmset -a hibernatemode 5″
    alias hibernateoff=”sudo pmset -a hibernatemode 0″

    I'm having trouble finding that file.

    Thanks!

  • http://www.geeked.info Ed

    .bash_profile (notice the period) is a “hidden” file in your home directory. Try the following command:

    pico ~/.bash_profile

    and then add the two alias lines

  • Andreas

    excellent tweak!

  • Andreas

    excellent tweak!

  • Mark B

    “I’m having trouble finding that file.”

    There is no .bash_profile by default with Leopard. Just touch ~/.bash_profile and your done.

  • Mark B

    “I’m having trouble finding that file.”

    There is no .bash_profile by default with Leopard. Just touch ~/.bash_profile and your done.

  • Sunnz

    It also works if you put it in ~/.profile which comes with Leopard/Tiger by default. I guess it is a BSD thing… all both OpenBSD and FreeBSD had its default shell reading ~/.profile

  • Sunnz

    It also works if you put it in ~/.profile which comes with Leopard/Tiger by default. I guess it is a BSD thing… all both OpenBSD and FreeBSD had its default shell reading ~/.profile

  • waine

    May I advise you “smartsleep” (http://www.jinx.de/SmartSleep.html) – and you’ll find a sleep, eventually.

    best,
    waine

  • waine

    May I advise you “smartsleep” (http://www.jinx.de/SmartSleep.html) – and you'll find a sleep, eventually.

    best,
    waine

  • philou

    Thanks waine for the very useful SmartSleep app.

    I found another tiny cool tool to disable the sleep mode on Apple Laptops. Works also if You close the lid of your machine. InsomniaX is also able to change the sleep mode very easy and quick and You can set a hotkey to enable and disable the tool…

    http://semaja2.net/insomniaxinfo/

    Hope it’d be useful to all of You :)

    Greetings from Berlin (Germany)

  • philou

    Thanks waine for the very useful SmartSleep app.

    I found another tiny cool tool to disable the sleep mode on Apple Laptops. Works also if You close the lid of your machine. InsomniaX is also able to change the sleep mode very easy and quick and You can set a hotkey to enable and disable the tool…

    http://semaja2.net/insomniaxinfo/

    Hope it'd be useful to all of You :)

    Greetings from Berlin (Germany)

  • sam smiht

    I have just bought a MacBook Air!

    No option to hibernate,and all this command line stuff to achieve what is a menu option in windows and has been for years in windows!

    Boy these things are supposed to be easy on a mac

    A Joke! P.S. I am a .NET programmer, but things should be easy.

    Apple add a simple hibernate option in menu!

  • sam smiht

    I have just bought a MacBook Air!

    No option to hibernate,and all this command line stuff to achieve what is a menu option in windows and has been for years in windows!

    Boy these things are supposed to be easy on a mac

    A Joke! P.S. I am a .NET programmer, but things should be easy.

    Apple add a simple hibernate option in menu!

  • http://startearnnow.99k.org Jonathan

    I am doing this with both my windows and mac machines and in windows it necessary to shut it down once a month atleast to clear system cache to speed up the performance. In mac, there is no fear. You can always hibernate than shuting it down. It not only saves battery, but also reduces the startup delay.

  • http://startearnnow.99k.org Jonathan

    I am doing this with both my windows and mac machines and in windows it necessary to shut it down once a month atleast to clear system cache to speed up the performance. In mac, there is no fear. You can always hibernate than shuting it down. It not only saves battery, but also reduces the startup delay.

  • Sidu

    Or, just use “SmartSleep”

  • Sidu

    Or, just use “SmartSleep”

  • James

    I just got my got MBP this past Monday. I came across your tip and it worked like a charm. Right now, I want to learn the little details about the Mac OS because I just swtiched from Windows. I am little shy in using programs like SmartSleep or InsomniaX just yet. So, please keep posting tips like this for others to find. Thank you.

  • James

    I just got my got MBP this past Monday. I came across your tip and it worked like a charm. Right now, I want to learn the little details about the Mac OS because I just swtiched from Windows. I am little shy in using programs like SmartSleep or InsomniaX just yet. So, please keep posting tips like this for others to find. Thank you.

  • http://blog.kaputtendorf.de Sven

    This Hibernation Tool does not need any administrative rights and is easier to use in contrary to the “sudo” commands above:
    http://blog.kaputtendorf.de/2007/08/17/hibernation-tool-for-mac-os/

  • http://blog.kaputtendorf.de Sven

    This Hibernation Tool does not need any administrative rights and is easier to use in contrary to the “sudo” commands above:
    http://blog.kaputtendorf.de/2007/08/17/hibernation-tool-for-mac-os/

  • Eileen

    sven,

    I downloaded that application that you suggested. I have always been a PC user and when I try and get out of hibernate, all I had to do was press a key to re-start the machine. I wasn't able to do that this time. How do I wake up my computer from hibernate mode using the tool you suggested above?

    Thanks,Eileen

  • Fabio

    I am having some problem with hibernatemode on my macbook (10.5.6). I wrote the alias lines to my .bash_profile. the first time I put mac to hibernate it works fine, but, the second time the macbook doesn't hibernate, the screen turn off and the sleep light turn on .. so, I need to hold on Power button some seconds to power off and start it again … This happen just the second time, the first time works great … If I power off or restart the mac after the first time, I am able to hibernate again …

    Does somebody have some idea?

  • Tom G

    I would try the Hibernation Tool mentioned above. It works great for single uses too since the script automatically reverts the sleep setting to 0. Otherwise the Smart Sleep preference pane works well too. As for the bash, I would try to rewrite the alias. That's a strange problem that I haven't seen myself. Anyway, options 1 and 2 are the simplest unless you really dig terminal.

  • http://www.markwheadon.com Mark Wheadon

    Or, if you'd like the machine to go back to its normal hibernate behaviour after it's been hibernated, without having to remember to run hibernateoff, then how about:

    http://www.markwheadon.com/blog/2009/01/hiberna…

    Cheers,

    Mark

  • http://detaer.com/ Detaer

    http://www.jinx.de/SmartSleep.html

    I have been using this, I am still looking for a single button to initiate hibernation rather than having to change system settings.

  • http://detaer.com/ Detaer

    Ohh look and here is an app to put the macbook directly to sleep!
    http://blog.kaputtendorf.de/2007/08/17/hibernat…
    Thanks for posting your link here Mark Wheadon, you are my epal.

  • max13

    Than I put pmset -g | grep hibernate in terminal, It's return me nothing. What should I do to fix that?

  • Mai

    hmm so when i put in the last execute file it said no such file exists but when i typed in 'hibernateon' it still allowed me to hibernate…did i do something wrong?

  • http://blog.osama-gma.net/ Osama Gamal

    I tweaked your command a little to satisfy my needs :D

    alias hibernate=”sudo pmset -a hibernatemode 5; sudo shutdown -s now && sudo pmset -a hibernatemode 3″

    Check my full article here: http://blog.osama-gma.net/?p=232

    Thanks, you helped me a lot ;)

  • JP

    Worked like a gem – fast, easy, effective! Surprisingly so.

  • Gerald

    i used the link above …. http://semaja2.net/insomniaxinfo/ … and downloaded the app there. its muuuch simpler. it added an icon in my applications folder and all i do is click the icon there. it asks me “do you want to hibernate” and i click yes and boom it goes into hibernation. i have a macbook pro that i just bought a couple of days ago. this is my first mac and it is going very well for me.

  • Gerald

    i used the link above …. http://semaja2.net/insomniaxinfo/ … and downloaded the app there. its muuuch simpler. it added an icon in my applications folder and all i do is click the icon there. it asks me “do you want to hibernate” and i click yes and boom it goes into hibernation. i have a macbook pro that i just bought a couple of days ago. this is my first mac and it is going very well for me.

  • gadgetmo

    on iMac, it uses 2 watts when off, and 3 watts when sleeping.

  • Anonymous

    These are wonderful! Thank you for sharing
    wallets for men
    wallet
    lv tivoli
    lv sunglasses
    key wallet

  • Bri

    Be sure to read man pmset for your system. Thing have changed a bit. For my MBP running 10.6.x I need hibernate 25.

    The man page also says:

    We do not recommend modifying hibernation settings. Any changes you make
    are not supported. If you choose to do so anyway, we recommend using one
    of these three settings. For your sake and mine, please don’t use any-
    thing other 0, 3, or 25.

  • http://profiles.google.com/gonzobrains Jeff Gonzales

    Why is this such a chore in Mac OS? My MacBook is set on 3, but everytime it runs out of battery it just shuts down instead of hibernating. After connecting to power, I turn it back on and it restarts as though it had been off. Why is it not coming back out of hibernation with my apps and session state preserved?

    gb

  • Anonymous

    There has been a speedy growth in the styles and varieties of coach lights and further outdoor lighting that has been available over the last few years. This is chiefly for the reason because there has been increased demand for low carbon low power lighting.Outdoor coach lights come in numerous varieties. You will discover hanging coach lights, coach bags for cheap solar coach lights, lantern style lights, gas coach lights and lamp post design outdoor coach lights. These all come from numerous kinds of materials including gold, silver and bronze.They are too for sale in countless colors for example; coach bags cheap bronze, silver, coach bags gold, white and black are all common and common.Make sure you research extremely well before purchasing your lights as you are sure to be purchasing more than just one set. You will most likely be wanting matching sets and so multiples will be ordered. Always do your investigation on the internet before ordering.The most popular makes of coach lights comprise Heath Zenith lights, cheap coach bags Lights Of America and Gamasonic. These makes have been manufacturing lights for years and are very reputable with excellent customer service.Prior to making your purchasing verdict, make a selection as to what kind of outdoor light you’ll be needing. Do you need a coach light with 360 degree motion detection? If your light is being fixed to a wall then it is probable that a straightforward 180 degree will be sufficient.Are you after purchasing a solar powered light? With simply a minute additional initial expense, solar powered lights will save you cash for a long time.Make sure you purchase many extra sets of light bulbs. You never know when they will discontinue making your precise light and so you don’t want to risk the bulbs becoming obsolete. cheap coach bag In some countries high energy bulbs have become outlawed so that is another thing to keep in mind.

  • Anonymous

    Designer brand styles for guys has taken a progress in a great new direction. Top fashion brand name wholesale handbags make a strong, fashionable appeal with the
    capacity to bear the many essential supplies in this very frantic, technology-driven world. With key chains, money clips, mobile phones and digital assistants, a man
    can no longer simply go out of his house with only a notecase tucked into his jacket pocket and think he’ll have everything he will demand. With the help of the
    current styles in designer offerings, guys luckily possess numerous more options at their waving for carrying their most necessary things without being awkward about
    holding an apparently female carry-all bag. Current lading designers have addressed this concern by revealing new courses of masculine carry-alls. Wholesale handbags
    for men allow functional selections for those guys who want to stay well configured while showing a picture of macho charm and dignity.
    With iPhones, key chains, notebooks and billfolds are often tough for men who go to their jobs each day, such bags can be helpful for guys. Some styled wholesale
    handbags or bags can easily hold many items and usually have wide bands that are able to hang over the chest. These bags are starting to be very typical, and some of
    the known design shops are seeing this. Louis Vuitton has a fashionable new group of tote bags for men that will be approaching out in autumn of 2009. The set has
    carry-alls that are shaped for business and play. They are well designed and contain the famous Louis Vuitton pattern.
    http://classiccardyuggboots.onlyblog.net/2011/04/29/gucci-classic-handbags-on-line/
    http://uggbootsformen.kafespot.com/2011/04/29/gucci-classic-handbags-on-line/
    http://sotolog.net/uggleatherboots/2011/04/29/log95.html
    http://www.lsddesign.nl/cheapuggbootsforsale/2011/04/29/gucci-classic-handbags-on-line/
    http://facesinsync.com/knitteduggboots/2011/04/29/gucci-classic-handbags-on-line/
    http://classicugg.arigsor.mn/2011/04/29/gucci-classic-handbags-on-line/
    http://uggclassictallboots.9daybody.com/2011/04/29/gucci-classic-handbags-on-line/
    http://3wordjournal.com/uggbootsbaileybutton/2011/04/28/gucci-classic-handbags-on-line/
    http://uggclassictall5815.blog.com.mt/2011/04/29/gucci-classic-handbags-on-line/
    http://live-drive.ru/chestnutuggboots/2011/04/29/gucci-classic-handbags-on-line/

  • Anonymous

    Are you familiar with Pelham bit, a type of bit used when riding a horse? The Pelham bit can have a sold or jointed mouthpiece. There is a larger ring directly
    connected to the mouthpiece on to which the ‘snaffle reins’ attach, and shanks that extend down terminating in rings on which ‘curb reins’ attach. The pelham bit is
    often used for schooling and general riding, providing the rider is knowledgeable about using a curb bit and riding with double reins. An English Pelham bit somewhat
    mimics the action of the bridoon (small snaffle bit) and weymouth (curb) bit combination used on a ‘double bridle’. A Pelham may be used when a horse can not hold the
    two bits comfortably, or for convenience.You may wonder why I first introduce the Pelham bit which has nothing to do with fashion or designer handbags. You know the
    elements of fashion are originated from our everyday life. The main characteristic of the popular Gucci handbag I will introduce is the Pelham horsebit detail.This New
    Pelham Medium Top Handle Bag features brown pony hair leather with dark brown leather trim, which makes it a classic bag. Brass hardware adds a hint of vintage. The
    delicate horsebit detail and embossed Gucci script logo are the distinctive characteristics of Gucci handbags, revealing your unique taste and noble temperament.
    Measured at 43 x 15 x 24 cm , this bag provide enough space for your daily essentials and business documents no matter you carry it in working days or during business
    trip. And the considerate designs of inside zip, mobile phone and PDA pockets add the practicality to this handbag. Studs on the bottom provide extra protection to the
    bag. And the supple double handles enable it to be comfortably hand-held.The Pelham bit used in horses is ingeniously designed on the handbag, which presents us a
    distinctive creation. Therefore, the New Pelham Medium Top Handle Bag is worthy of the title of one of the most popular Gucci handbags.
    http://uggboots2010.a-lincoln-long-nine.com/2011/04/29/gucci-classic-handbags-on-line/
    http://discountuggboot.vannerforalltid.se/2011/04/29/gucci-classic-handbags-on-line/
    http://leavehermanalone.com/classiccardyuggboots/2011/04/28/gucci-classic-handbags-on-line/
    http://discounteduggboots.widblog.com/2011/04/29/gucci-classic-handbags-on-line/
    http://buyuggboots.5hundredkeele.com/2011/04/29/gucci-classic-handbags-on-line/
    http://boysuggboots.ionixe.com/2011/04/29/gucci-classic-handbags-on-line/
    http://getcashnoweasy.info/uggbootsale/2011/04/28/gucci-classic-handbags-on-line/
    http://adoodleaday.co.uk/uggbootsale/2011/04/29/gucci-classic-handbags-on-line/
    http://pinkuggs.smallkitchenreviews.com/gucci-classic-handbags-on-line/
    http://uggbootscheap.blogto.info/2011/04/29/gucci-classic-handbags-on-line/

  • http://www.58bits.com Anthony Bouch

    Excellent – thanks for the post. Works like a charm on 2011 MBP

  • Destroyerur

    may i know what i did wrong?
    after i enter source .bash_profile , it keep asking for password

  • Destroyerur

    may i know what i did wrong?
    after i enter source .bash_profile , it keep asking for password