Friday, March 9, 2007

How To Disable Safe Sleep for faster sleep on lid close?

Newer portable Macs use safe sleep (hibernation) in combination with normal sleep (older computers can use this, too). What happens is that when you put your computer to sleep, the system writes the contents of RAM into the file /private var vm sleepimage, then goes into normal sleep mode. If your system loses power completely, it can recover the contents of RAM from this sleepimage file.

The problem with this is putting your computer to sleep can take a while (20 seconds to one minute or more), depending on how much data you currently have loaded in RAM. Also, this sleepimage file is the same size of your total RAM, wasting valuable hard drive space. I have 2GB of RAM, so my file is 2GB.

To disable safe sleep, run the two following commands in Terminal:
$ sudo pmset -a hibernatemode 0

To state the obvious, with safe sleep disabled, a total power loss will
wipe out whatever was open on your machine. To enable safe sleep mode
again, repeat the above commands, but change hibernatemode 0 on the first line to hibernatemode 3, and =false to =true
on the second line. You'll then need to reboot again. Personally, I
prefer the safe sleep mode, even with the slower sleep time and hard
drive consumption -- even if for no other reason than it's great when changing a battery on a flight.
$ sudo nvram "use-nvramrc?"=false
When done, restart your computer. Now go delete the file /private var vm sleepimage" to free up some hard drive space. When you put your computer to sleep it, should happen in under five seconds; my MacBook now goes to sleep in two seconds.

No comments:

Your Ad Here