Pick of the Week - Nov 10 [Show all picks]
Path Finder 5 - A feature-laden Finder replacement
Submit Hint Search The Forums LinksStatsPollsFAQHeadlinesRSS
12,000 hints and counting!

10.4: Disable Safe Sleep for faster sleep on lid close Laptop Macs
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
$ 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.

[robg adds: 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 batteries on a flight.]
    •    
  • Currently 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)
 
[127,146 views]  

10.4: Disable Safe Sleep for faster sleep on lid close | 24 comments | Create New Account
Click here to return to the '10.4: Disable Safe Sleep for faster sleep on lid close' hint
The following comments are owned by whomever posted them. This site is not responsible for what they say.
What about this tip from Apple?
Authored by: Dirk! on Tue, Mar 6 2007 at 8:01AM PST
Hello,

Apple has a tip about putting your computer into sleep mode very fast:

http://www.apple.com/pro/tips/quicksleep.html

"Just press Command-Option and then hold the Eject button for about 2 seconds and Zzzzzzzzzzzzzz. It doesn't get much faster than that."

Does that mean, this key combination puts you MacBook into sleep instead of deep sleep?

[ Reply to This | # ]
What about this tip from Apple?
Authored by: diamondsw on Tue, Mar 6 2007 at 8:23AM PST
Afraid not - still puts it in deep sleep. Good tip, though!

[ Reply to This | # ]
What about this tip from Apple?
Authored by: zebrum on Tue, Mar 6 2007 at 8:37AM PST
that key combo is obvioulsy not designed for laptops since it just wakes up immediately after sleeping since the lid is open.

[ Reply to This | # ]
What about this tip from Apple?
Authored by: Dirk! on Tue, Mar 6 2007 at 9:07AM PST
Not mine. It stays asleep.

[ Reply to This | # ]
What about this tip from Apple?
Authored by: rgray on Tue, Mar 6 2007 at 11:47AM PST
ditto!

[ Reply to This | # ]
What about this tip from Apple?
Authored by: tojo1 on Tue, Mar 6 2007 at 12:23PM PST
That is also the case with my TiPB 867. The computer immediately wakes up again after the sceen goes dark. Pity, because it is a neat tip and it would be one that I think I would adopt.

Using 10.4.7 if that makes any difference.

[ Reply to This | # ]
What about this tip from Apple?
Authored by: voiceofra on Tue, Mar 6 2007 at 11:56AM PST
If you have an Apple remote, holding down the Play/Pause button for about 5 seconds will also put it to sleep.

[ Reply to This | # ]
What I really want is :
Authored by: donaciano on Tue, Mar 6 2007 at 9:39AM PST
To have safe-sleep turned off by default, so that it doesn't waste part of my battery everytime I close the lid, and also be able to enable it once for the next sleep when I need it. Perhaps a command run from the terminal, or holding down option when pressing Sleep on the Shut Down prompt.

Or even a setting in system prefs to only use safe-sleep when the battery has less than a certain % left. Extra cautious folks could crank the number up to 100%, and I'd leave it around 10%.

Either of these would be fine. :)

[ Reply to This | # ]
10.4: Disable Safe Sleep for faster sleep on lid close
Authored by: barefootguru on Tue, Mar 6 2007 at 10:33AM PST
What the reasoning for the nvram command? I disabled my safe sleep purely with the first pmset line.

I disabled mine because safe sleep writes the entire contents of RAM to disk *unencrypted* -- even if you use FileVault and/or encrypted swap. There's been reports around the web of people finding their password in the safe sleep file.

[ Reply to This | # ]
10.4: Disable Safe Sleep for faster sleep on lid close
Authored by: blueatria on Tue, Mar 6 2007 at 4:25PM PST
Just do the following

sudo strings /var/vm/sleepimage | grep LOGIN

This is not great.... obviously you would need root access or have sudo access as the file is only accessible by root. Still, it is not great to have your password unencrypted on disk even if it is only accessible via root.

[ Reply to This | # ]
10.4: Disable Safe Sleep for faster sleep on lid close
Authored by: barefootguru on Wed, Mar 7 2007 at 10:02AM PST
Actually all you need is to boot it into target disk mode. And of course root password can be reset with Disk Utility. (I couldn't run strings on mine, it complained about lack of memory.)

[ Reply to This | # ]
10.4: Disable Safe Sleep for faster sleep on lid close
Authored by: etresoft on Tue, Mar 6 2007 at 11:42AM PST
I tend to forget these little tricks when I need them. I can see the rationale for having and not having the hibernate mode. I think we should be able to choose when appropriate. Here is a virtually untested script:
#!/bin/sh

SETTING=$1

if [ "$SETTING" == "off" ]; then
  echo "Turning off safe sleep"
  sudo pmset -a hibernatemode 0
  sudo nvram "use-nvramrc?"=false
  echo "Don't forget to reboot!"
  echo You are now free to remove your sleepimage file at /private/var/vm/sleepimage
elif [ "$SETTING" == "on" ]; then
  echo "Turning on safe sleep"
  sudo pmset -a hibernatemode 3
  sudo nvram "use-nvramrc?"=true
  echo "Don't forget to reboot!"
else
  echo "Usage: safesleep on | off"
fi


[ Reply to This | # ]
If you care about your privacy, don't use Safe Sleep
Authored by: lincd0 on Tue, Mar 6 2007 at 5:30PM PST
Disabling Safe Sleep should be the first thing you do on any new Mac. It writes your passwords and everything else in memory out to disk in the clear, where they're trivial to recover. It's appalling that Apple enables this by default and doesn't give naive users any warning of the risk, even when they turn on FileVault. Safe Sleep completely negates the effect of FileVault and most other forms of encryption.

[ Reply to This | # ]
10.4: Disable Safe Sleep for faster sleep on lid close
Authored by: 93 Escort Wagon on Tue, Mar 6 2007 at 11:15PM PST
Hmm... I disabled safe sleep about a month after I bought my Macbook Pro. However I did not run the second command (nvram ...), just the first one (pmset ...). My laptop is obviously not going into safe sleep - what does that second line do, exactly?


[ Reply to This | # ]
10.4: Disable Safe Sleep for faster sleep on lid close
Authored by: dadaDaveed on Wed, Mar 7 2007 at 9:25AM PST
This tip doesn't work on my MacBook for some reason. After entering both strings successfully and rebooting, it still takes 20-30 seconds to sleep. Any idea what would cause these commands to not work? (I'm running a Black MacBook with 2Gb RAM)

[ Reply to This | # ]
10.4: Disable Safe Sleep for faster sleep on lid close
Authored by: barefootguru on Wed, Mar 7 2007 at 10:08AM PST
Try removing the sleepimage file and seeing if it reappears on the next sleep. This will tell you if the delay is from safe sleep or something else.

[ Reply to This | # ]
10.4: Disable Safe Sleep for faster sleep on lid close
Authored by: moxieboy on Wed, Mar 7 2007 at 1:47PM PST
If you want to temporarily kill Safe Sleep, try:

sudo rm /var/vm/sleepimage

As others have pointed out, this is the image file. Deleting it won't cause any problems, and has the immediate effect of disabling Safe Sleep until reboot.

I find myself doing this occasionally to free up hard drive space. A temporary solution, I know, but it gives me an instant extra 2GB free.



[ Reply to This | # ]
10.4: Disable Safe Sleep for faster sleep on lid close
Authored by: FJModrego on Fri, Mar 9 2007 at 4:56AM PST
May be I am wrong (I have not tried it as yet) but I think that you can do all of this with the widget Deep Sleep which was the pick of the week on Oct 16, last year http://www.macosxhints.com/article.php?story=20061018014009924

[ Reply to This | # ]
10.4: Disable Safe Sleep for faster sleep on lid close
Authored by: smactron on Sun, Apr 1 2007 at 11:19PM PDT
How do I delete "/private var vm sleepimage"?

[ Reply to This | # ]
10.4: Disable Safe Sleep for faster sleep on lid close
Authored by: outer on Sat, Jun 30 2007 at 4:19PM PDT
Try this. Even after disabling "SafeSleep" usiing the other hints in this thread, and then actually doing "sudo rm /var/vm/sleepimage" or even "sudo tcsh; cat > /var/vm/sleeepimage ^D" everytime it seems that /var/vm/sleepimage comes back after a restart or shutdown! So....

sudo rm /var/vm/sleepimage
sudo ln -s /dev/null /var/vm/sleepimage

Works so far (2007-06-30 19:17 EST)

outer


[ Reply to This | # ]
10.4: Disable Safe Sleep for faster sleep on lid close
Authored by: NavyWings on Sat, Jul 7 2007 at 11:30AM PDT
in terminal, navigate to the /private/var/vm directory

Issue the following command:
sudo rm sleepimage

You'll be prompted for your password and it'll be deleted. If you get asked if you want to override the permission settings, just type "y" and hit return.

Good luck

[ Reply to This | # ]
10.5: Disable Safe Sleep for faster sleep on lid close
Authored by: spamathon on Wed, Jan 2 2008 at 2:29PM PST
This also works on 10.5 but with a caveat (that may well have been in place in 10.4, I just didn't figure it out until now).

Be aware that *any* changes you make with pmset change your active profile to 'Custom'. That means if you follow the above tip by setting hibernatemode to 0 your active profile switches to 'Custom'. Then if you switch back to one of the default Energy Saver profiles (Better Energy Savings, Normal, or Better Performance) hibernatemode is set to its value for that profile, which is 3 and will always be 3, apparently. The defaults cannot be changed.

So to take advantage of this tip permanently, your Energy Saver profile must always be set to 'Custom'.

Bit of a PITA really...

[ Reply to This | # ]
10.5.7 update
Authored by: mike666 on Thu, Jun 11 2009 at 4:58AM PDT
As far as I can determine, in 10.5.7, neither the OS, the Finder, Safari, Mail, Remote Desktop, Directory Utility, Terminal, nor Keychain Access store any passwords in RAM in a way that shows up as plain text in the sleepimage file. I did extensive testing and a sudo grep -a password /var/vm/sleepimage (the strings command won't run on a 4GB file) yielded nothing, even after changing my user password, logging out, logging in, restarting and updating the sleepimage file after every secure access in each app. (Note that if you want to try all this yourself, once you're done you'll need to exit your Terminal session, start a new one, and then edit out the entries in your .bash_history file which contain your password.)

The only time I was able to see a password show up in the sleepimage file was after running VMWare and logging into my Vista vm. That virtual machine's password showed up twice in plain text, so if you use VMWare, that may be a cause for concern although it didn't show up alongside any other strings which would identify it as a password so without knowing what it was already I doubt if anyone but an experienced hacker could fish it out. I didn't test every single app I have installed so it's possible there may be others that aren't safe to use but in general, it appears that Apple's software is not an issue. Ideally, of course, an option to encrypt the sleepimage file along with the swapfiles would be a great addition.

BTW, my Late '08 MBP (w/7200rpm HD) updates the sleepimage file in just a few seconds when I close the lid so the time and battery issues described above shouldn't be much of an issue to users of the newer models - it's pretty seamless.

[ Reply to This | # ]

SmartSleep prefPane
Authored by: gmachen on Sat, Aug 15 2009 at 9:26AM PDT
The best of all possible worlds:
http://www.jinx.de/SmartSleep.html

[ Reply to This | # ]