Do you usually close your MacBook and run? Disable Safe Sleep!

The subject is not new: I presented it to you for the first time in late 2007, and Fernando brought it up again at the beginning of this year. Reading the recently published tip by Recovery Force, we thought it best to raise the discussion here again.

The “Safe Sleep” feature is one of the most frequent causes of data loss on hard drives from MacBooks, MacBooks Pro and even from PowerBooks and iBooks G4. The cause of this is the delay in transferring the contents of the RAM to the hard disk, as I explained in the first article linked in this post. Depending on the amount of data, this whole process can take a few minutes and, in case the user doesn't notice, he can make too sudden movements with his machine until he even takes it off the table and quickly comes to store it in his backpack. And the danger arises.

PowerBook G4 returning from Safe SleepPowerBook G4 returning from Safe Sleep

The first precautionary measure, of course, is to get used to closing the lid of the laptop and being patient, that is, waiting until the light of the sleep go out. I always get something to do before I put it in my backpack. But if you don't even want to take that risk, it is ideal to disable Safe Sleep completely.

Before that, Apple explains what "Safe Sleep" and why it exists:

Some portable computers support “Safe Sleep”. During “Safe Sleep”, the current state of the computer saved on the hard disk, including applications and open documents. This prevents your information from being lost if the computer is turned off completely during sleep, which occurs if the battery runs out or is replaced.

If your computer needs to read the saved state when you wake up, a progress bar will be displayed until the computer is ready for use.

With that in mind, proceed by opening the Terminal and typing the following two commands, one at a time:

(code lang = ”cpp”) sudo pmset -a hibernatemode 0sudo nvram "use-nvramrc?" = false (/ code)

To free up the disk space occupied by the image sleep:

(code lang = ”cpp”) sudo rm / private / var / vm / sleepimage (/ code)

And don't worry, you can return everything to its original state:

(code lang = ”cpp”) sudo pmset -a hibernatemode 3sudo nvram "use-nvramrc?" = true (/ code)

Oh, don't forget to restart your machine after all this.

(youtube) http://www.youtube.com/watch?v=pHzwIkw4Y0w (/ youtube)

(This tip was originally published in March 2007 by macosxhints.com.)