hasseg.org

Disabling Safe Sleep in OS X

Filed under Mac, Scripts

I’ve had problems with my MacBook hanging with an empty black screen after waking up from sleep. This usually happens when I make it go to sleep by closing the lid and later wake it up by opening it (approximately 20% of the time). Closing the lid, waiting until the sleep light starts slowly blinking again (signaling that the OS has finished initializing sleep mode) and then opening it again has always solved the problem, but it is still really annoying.

Update: Ok, it's now been almost a month and my laptop has not hung once when waking up from sleep, so I guess I can pretty much say that disabling safe sleep did the trick.

Update (Dec 1, 07): This problem has been fixed in Leopard. You can still use this method for disabling safe sleep, though. The pmset command seems to suffice.

When searching for possible solutions or workarounds for this, I stumbled upon this post on Mac OS X Hints. It focuses on disabling “safe sleep”, which is a feature in OS X that saves the RAM contents to disk when going to sleep. One of the comments on that page has a simple but useful shell script that runs the two required commands for you, given that you run it from the command line and type in your password (as it needs to run the commands with sudo). I copied it for myself, being a convenient way to save the commands needed and to be able to easily invoke this functionality later.

Disabling safe sleep has the following consequences:

  1. If your laptop loses power while sleeping, the RAM contents will be lost
  2. Your laptop will go to sleep waaay faster than before
  3. Your data will be more secure (I don't think the file where the RAM contents are saved is encrypted)
Point number one doesn't really matter to me; I never leave anything unsaved and open when I put my laptop to sleep. Number three, while positive, is similarly insignificant; it's really a longshot that someone would steal my laptop while it's in sleep mode, hack their way past the authentication screen, parse the contents of the sleep file and then somehow use them in some unspecified nefarious way. Number two, on the other hand, is really cool. It used to take my laptop almost half a minute to go to sleep (OK, I may be exaggerating, but it was a long time), but now it takes two (2) seconds (!) for it to go ZZZZZZ.

The speed benefit aside, whether or not disabling safe sleep has also solved the “blank screen after wakeup” problem remains to be seen.

Categories