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.


December 15th, 2008 at 11:24 am
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/...
December 15th, 2008 at 4:11 pm
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.
December 15th, 2008 at 4:21 pm
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.
December 16th, 2008 at 8:33 am
Thanks for the sweet tip!
December 16th, 2008 at 10:08 am
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?
December 16th, 2008 at 1:43 pm
[...] useful tip on how to speed up the already super-fast sleep/hibernation of the [...]
December 17th, 2008 at 7:47 am
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).
December 17th, 2008 at 1:33 pm
I love smart readers with useful comments. Thanks for the link to that awesome little app!
December 18th, 2008 at 1:47 am
Awesome! Thanks for the tip. This always frustrated me, too, since they changed it. Glad we can get the RAM-only mode back.
December 18th, 2008 at 7:23 am
[...] http://www.mikedipetrillo.com/mikedvirtualization/2008/12/wake-up-your-mac-faster.html [...]
December 18th, 2008 at 11:29 am
I don't recall changing any settings and mine is set to 0 already…
December 18th, 2008 at 11:39 am
I recommend SmartSleep, too. It gives you best of both “worlds” and seems to work pretty much as advertised.
December 18th, 2008 at 1:13 pm
I always always save my work before putting my mac to sleep. It's just general best practice to do that, IMO.
December 18th, 2008 at 1:28 pm
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!
December 18th, 2008 at 4:07 pm
Funny you mention that. The same thing happened to me a couple of times. They do get REALLY hot in those bags.
December 18th, 2008 at 11:00 pm
[...] Wake Up Your Mac Faster (tags: macbookpro mac apple) [...]
December 19th, 2008 at 12:34 am
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...
December 19th, 2008 at 1:05 am
[...] Wake Up Your Mac Faster [...]
December 19th, 2008 at 2:52 am
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?
December 19th, 2008 at 7:00 am
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.
December 19th, 2008 at 8:27 am
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!
December 19th, 2008 at 10:49 am
[...] 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. [...]
December 19th, 2008 at 11:07 am
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.
December 19th, 2008 at 11:59 am
Awesome, works perfect, thanks!
December 19th, 2008 at 12:10 pm
[...] 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 [...]
December 19th, 2008 at 4:55 pm
whoa… Fantastic! Thank you!
December 20th, 2008 at 4:37 am
[...] 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 [...]
December 21st, 2008 at 5:21 pm
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
December 22nd, 2008 at 2:22 pm
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.
December 22nd, 2008 at 7:34 pm
[...] Wake Up Your Mac Faster (tags: howto mac tips apple osx hibernate macosx tweaks laptop) [...]
December 22nd, 2008 at 11:48 pm
[...] 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. [...]
December 23rd, 2008 at 8:44 am
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?
December 26th, 2008 at 7:03 am
fdllxjpu…
fdllxjpu…
January 7th, 2009 at 4:34 pm
[...] Fuente: Mike D’s Virtualization Blog [...]
February 1st, 2009 at 2:22 pm
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.
December 19th, 2009 at 1:09 am
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?
February 3rd, 2010 at 10:13 am
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.