Dec 14

OK. Not exactly related to virtualization but I thought I’d share this anyways. I am always on the move and I’m usually bringing my Mac with me. One of my favorite things about the Mac is that I can really just close the lid and walk to a meeting and open the lid and it’s ready to work instantly. That’s just incredible to me. Sure, a PC can sleep and even hibernate but neither makes the thing come alive quickly. The one painful thing for me has been waiting for my Mac to sleep. I run a lot of stuff all the time. Right now I have 21 different apps open plus a VM running in VMware Fusion. That means that when my Mac goes to sleep I have to wait for it to write most of the 4 GB of RAM to disk. A fellow engineer just showed me a faster way to make the Mac sleep – adjust the hibernatemode variable.

The innovation in Apple’s “Safe Sleep” is that it goes ahead and writes out the disk image, but then suspends to RAM. If you just resume, everything’s already in RAM and you can avoid the delay from resuming the image. If you lose power (or change battery), then it resumes from the disk image. By comparison, Windows offers both suspend-to-RAM and suspend-to-disk, but not at the same time.

You can change the Mac’s hibernate behavior using pmset; here’s the reference for it:

http://developer.apple.com/documentation/Darwin/Reference/ManPages/man1/pmset.1.html

“sudo pmset -a hibernatemode 0″ = suspend to RAM only (default on desktops)
“sudo pmset -a hibernatemode 1″ = suspend to disk only
“sudo pmset -a hibernatemode 3″ = suspend to disk + RAM (default on laptops)

To see your current hibernatemode: “pmset -g | grep hibernatemode”. Right now I have mine set to hibernatemode 0 and man do I love it. Instant sleep and instant recovery. This even works with 4 different VMs running in VMware Fusion with no hiccups. Can life get any sweeter?

I hope this helps some of you Mac lovers out there.

VN:F [1.9.3_1094]
Rating: 5.0/5 (22 votes cast)
VN:F [1.9.3_1094]
Rating: +1 (from 3 votes)
Wake Up Your Mac Faster, 5.0 out of 5 based on 22 ratings

View Comments to “Wake Up Your Mac Faster”

  1. Anonymous Says:

    Vista has a similar feature called “Hybrid Sleep”. Interestingly, it appears that the default behavior is the opposite of the Apple, using the logic that for a desktop without a battery backup like a laptop has, it is safer to suspend to disk + RAM.

    http://windowshelp.microsoft.com/Windows/en-us/...

  2. latoga Says:

    The one thing to note to your readers Mike is that if you change the settings to the hibernatemode 0, this means that you WILL lose work if you close the lid and then try changing the laptop battery.

    When I first got my Mac, I did this on a cross country flight without even thinking about it and then was amazed when the Mac restarted with all my apps (and data) still where I left them. Like most things, it's a trade off…but something that needs to be kept in mind.

  3. Mike DiPetrillo Says:

    Absolutely be aware that you will loose your data if it's just in RAM. Like you I loved the fact that I could change out my battery in the middle of a long flight (I take lots of them). However, I found that I preferred the quick up and down times of changing the setting and then just knowing that I'll have to shut all the way down to swap batteries on those long flights. I might change my mind again now that Delta is starting to offer WIFI on the planes. We'll have to see how the old battery does then. If only they put power in all of the seats. One reason I still love trains.

  4. Bob Klaas Says:

    Thanks for the sweet tip!

  5. sfoskett Says:

    Note that you CAN change your batteries with the Mac plugged in and sleeping without losing anything in mode 0. But if you can plug in, why are you running on batteries, I suppose?

    Anyone know of a way to tell the Mac to hibernate to disk just this once from the command line?

  6. A Weblog…Again » Blog Archive » Macbook Sleep/Hibernation Tip Says:

    [...] useful tip on how to speed up the already super-fast sleep/hibernation of the [...]

  7. Andrew Miller Says:

    You've got to use SmartSleep (no relation to the developer, etc.).

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

    It makes what you're listing above much easier as well as can change the settings when your battery is low (which makes perfect sense).

  8. Mike DiPetrillo Says:

    I love smart readers with useful comments. Thanks for the link to that awesome little app!

  9. Ted Wood Says:

    Awesome! Thanks for the tip. This always frustrated me, too, since they changed it. Glad we can get the RAM-only mode back.

  10. Das MacBook schneller in den Schlaf legen Says:

    [...] http://www.mikedipetrillo.com/mikedvirtualization/2008/12/wake-up-your-mac-faster.html [...]

  11. Chris Bulow Says:

    I don't recall changing any settings and mine is set to 0 already…

  12. Mr. Darcy Says:

    I recommend SmartSleep, too. It gives you best of both “worlds” and seems to work pretty much as advertised.

  13. James Says:

    I always always save my work before putting my mac to sleep. It's just general best practice to do that, IMO.

  14. alec Says:

    A few times my macbook pro failed to actually suspend after I closed the lid. It almost started a fire one time when I closed the lid and put it into the padded laptop bag. When I took it out 2 hours later it was so hot it burnt my fingers.
    So from that point I always confirm the machine is suspended before packing it down. You just shorted my wait with 30-40 seconds, I thank you for that! :)

  15. Mike DiPetrillo Says:

    Funny you mention that. The same thing happened to me a couple of times. They do get REALLY hot in those bags. :)

  16. links for 2008-12-18 « memor.ia blog Says:

    [...] Wake Up Your Mac Faster (tags: macbookpro mac apple) [...]

  17. Oliver Says:

    If you use encrypted virtual memory, there are some extra settings as well. I tend to use 5 for disk only. http://blog.stephanbuys.com/2008/02/protecting-...

    Also, there is a nice article on tuning the settings if you don't want to suspend to disk normally, but still want the protection of doing it when the battery gets low. http://www.radiotope.com/content/os-x-105-leopa...

  18. Stream o’ consciousness… | Mike Orren Says:

    [...] Wake Up Your Mac Faster [...]

  19. Lucas Says:

    That`s nice if you have a lot of the RAM occupied but otherwise it will be only couple of seconds for the mac to write RAM on disk. Still, really nice tipe.

    Just wondering if it makes any time differences when you open the lid, because on both options (0 and 3) the content is in the RAM and the Mac shoudn`t read the HD anyway. So, it`s instant recover on option 3 too, isn`t it?

  20. Mike DiPetrillo Says:

    It's definitely instant recovery both ways. You just don't have to wait for it to shut down. For me that's big. I have 4 GB of RAM in my MB Pro. I use most of it all the time since I'm always running tons of programs and at least 1 VM. It's made a huge difference in my life already not having to wait for it to suspend.

  21. Rob Uttley Says:

    Wow. I've had 2 batteries for over a year for my 1st gen MBP and I never realised I could swap batteries like that. When the power gets very low, I've always saved/closed all my documents, shut the whole machine down properly, swapped the batteries, and then restarted, reloading my apps and reopening my documents etc.

    Knowing that I can put the machine to sleep and swap batteries is brilliant – thanks for making me aware of that!

  22. Internets of Interest: 19th Dec | My Etherealmind Says:

    [...] Wake Up Your Mac Faster – I write on the train, but hibernating my MAC takes a few minutes – annoying. Turns out that OS X is hibernating to Disk and RAM and 4GB memory takes time to write the hibernate file. This tip shows you how to disable the Disk, but let the RAM hibernate. I can now shut the lid, and pop my computer into my bag.Life changing. [...]

  23. Andy Lee Says:

    Shouldn't the title of this post be “Put Your Mac to Sleep Faster”?

    Nitpick aside, this tip made my day. Like you, I wait for the pulsing light before I put my laptop in my bag. Having to wait 45 seconds really detracted from the feeling of having an on-the-go machine.

  24. carbonsink Says:

    Awesome, works perfect, thanks!

  25. Notes From Andy » Blog Archive » Put your Mac to sleep faster Says:

    [...] just found out how to drastically shorten the delay between closing my laptop and seeing the pulsing “sleep” light: [W]hen my Mac goes to [...]

  26. blah Says:

    whoa… Fantastic! Thank you!

  27. paul walk’s weblog » Blog Archive » Macs and fast hibernation Says:

    [...] to be diluted in recent versions of MacOSX. Happily, he points to Mike DePetrillo who has supplied an excellent guide to configuring this feature and restoring the original speed – essentially by hibernating to RAM rather than disk. I recommend [...]

  28. Martin Says:

    Hi,

    I run a little script via cron every ten minutes. I think that's basically the way that SmartSleep works. I post it below, not shure how it will look since I cannot preview the post. And a disclaimer: I did not invent the script but found it somewhere online.

    #!/bin/sh
    MODE=`/usr/bin/pmset -g | awk '/hibernatemode/ { print $2 }'`
    LEFT=`/usr/bin/pmset -g batt | grep Internal | awk '{ print $2 }' | awk -F % '{ print $1 }'`

    if [ $LEFT -lt 25 ] && [ $MODE != 3 ] ; then
    {
    /usr/bin/logger -t “hibernatemode” “Battery level less than 25%; setting hibernatemode to 3″
    /usr/bin/pmset -a hibernatemode 3
    }
    elif [ $LEFT -gt 50 ] && [ $MODE != 0 ]; then
    {
    /usr/bin/logger -t “hibernatemode” “Battery level greater than 50%; setting hibernatemode to 0″
    /usr/bin/pmset -a hibernatemode 0
    rm /var/vm/sleepimage
    }
    fi

  29. Mark Says:

    I've been using the (free) dashboard widget Deep Sleep. http://deepsleep.free.fr/

    In addition to allowing to configure “smart vs fast sleep” from the widget (without going through the console), it also allows you to enter “deep sleep” (aka “hybernate then turn off”) from the widget.

    So on those rare occasions when I want to swap batteries without rebooting, I can manually trigger “deep sleep” and wait for the machine to shut off. But otherwise, fast sleep is my mode of choice.

  30. links for 2008-12-22 : Ching* Says:

    [...] Wake Up Your Mac Faster (tags: howto mac tips apple osx hibernate macosx tweaks laptop) [...]

  31. Type Faster on Your Mac Says:

    [...] my last tip on putting your Mac to sleep faster was such a huge hit as you can see below that I thought I’d post another Mac tip up here. [...]

  32. Lucas Says:

    Is it possible to make the Mac sleep in hibernatemode = 1 and having it on without needing the battery or the it still consumes energy while sleeping and having all stuff at the HD?

  33. fdllxjpu Says:

    fdllxjpu…

    fdllxjpu…

  34. Suspeder Más Rápido-Memorias de un Amnesico 3.0 Says:

    [...] Fuente: Mike D’s Virtualization Blog [...]

  35. Buckie Says:

    Great tip! Just be careful that your battery doesn't run out while your Mac is asleep or you'll lose your current state (file changes, etc.), I haven't been ballsy enough to try this with my VM yet to see if it gets hosed.

  36. Louis Vuitton handbags Says:

    mine set to hibernatemode 0 and man do I love it. Instant sleep and instant recovery. This even works with 4 different VMs running in VMware Fusion with no hiccups. Can life get any sweeter?

  37. nokiaphones Says:

    Nokia has become very much familiar in every part of the world and every where. Once you need to get a cell phone then you must see your choice from Nokia collection to get an ideal cell phone.

Leave a Reply

blog comments powered by Disqus