Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.4: Enable safe sleep on some older Macs System 10.4
Tiger only hintAs soon as I heard about 'safe sleep' (which lets you replace a battery without a shut down, for instance) on the new PowerBooks, I wanted it. I have often been in the position where my 12" PowerBook G4 has run out of juice while hibernating (due to various reasons), and then I have lost all my open programs. Well it appears that safe sleep can be implemented on many Macs, as described in this excellent entry on Andrew Escobar's blog.

It works. I've tried it.

[robg adds: I tested this on my 12" PowerBook G4 (1.33GHz), and it worked -- on the second attempt. The first time I yanked the power and restored it, the machine just cold booted. But on the subsequent attempts, it worked as it should. Very cool! If you try this one yourself, please post your Mac model info and success/failure results in the comments.

It should be obvious, but I'll say it anyway: this is potentially quite dangerous! Andrew provides good recovery instructions, in case things go wrong. However, I would recommend having a current backup, just in case...

The above-linked article is very well done, with clear step-by-step directions and additional information. In the event that entry ever disappears, though, I thought I would at least provide the basic steps here; Read More to see them...

Please note, I do not recommend using the following information to implement safe sleep on your Mac -- use the above-linked directions instead, as they are much more thorough, and cover situations that I haven't documented! With that warning, here are the basic steps:
  1. Open Terminal, and type the following, pressing return after each line:
    sudo nvram nvramrc='" /" select-dev
    " msh" encode-string " has-safe-sleep" property
    unselect
    '
    
  2. Now type sudo nvram "use-nvramrc?"=true and press Return. You must now restart the Mac for the settings to take effect.

  3. After the restart, go back to the Terminal, and enable hibernation:
    sudo pmset -a hibernatemode 3
    If you use secure virtual memory, see the original instructions for different settings. This command should create a file named sleepimage in /var/vm.

  4. Verify that everything worked -- put the Mac to sleep as you usually do, wait a few seconds, then wake it up. Use Console to view the System log, and make sure you see an entry that contains System SafeSleep.

  5. Test Safe Sleep -- sleep the machine, wait a bit, then disconnect all power sources. Plug in the power sources again, and watch the new "wake from gray" sequence.
That should do it ... and this nifty trick will save a few minutes during battery changeovers on those long flights!
    •    
  • Currently 2.33 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (3 votes cast)
 
[52,835 views]  

10.4: Enable safe sleep on some older Macs | 42 comments | Create New Account
Click here to return to the '10.4: Enable safe sleep on some older Macs' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.4: Enable safe sleep on some older Macs
Authored by: hoffel on Nov 18, '05 07:37:44AM

This is nice. The only thing that bothers me is that I can't trigger safe sleep other than by removing the battery in my PB.

I used to have a Windows laptop for a while where this could be set in the preferences. It was even possible to choose different triggers for each (I had closing the lid for sleep and fn-power for hibernate). This was perfect in that I normaly just closed the lid, but when I knew I would be away for some time I could use hibernate in order to preserve battery power.

With the Powerbook (Alu 1,25) being so power hungry, I certainly would welcome such a function. Does anybody know if it is possible to trigger hibernate mode manually so that the computer shuts down completely but then restores to where I left it?

hoffel.



[ Reply to This | # ]
10.4: Enable safe sleep on some older Macs
Authored by: robg on Nov 18, '05 07:43:29AM

If you read the linked blog, it explains how to make safe sleep the default, I believe. I didn't test it, though.

-rob.



[ Reply to This | # ]
I tried it and it works fine
Authored by: amutti on Nov 18, '05 08:17:57AM

I am using this hibernate mode as my default and it works fine. It takes a while to start back up (30 seconds-ish) though. I'm using it on 1.5 17" PB G4. I've been using it for 2 days now.

Tony



[ Reply to This | # ]
10.4: Enable safe sleep on some older Macs
Authored by: hoffel on Nov 18, '05 09:37:13AM

Thanks, rob. I did read the blog, but what I was looking for is apparently not yet possible (as evidenced in the blog entry's comments, in which people are asking for the same thing...).

The perfect solution would be to have the option in the shutdown dialog... But I believe that's for Apple to implement (read: not likely, at least for the old Powerbooks).

Well, here's to hoping!

hoffel.



[ Reply to This | # ]
A proper hibernate mode would be nice ...
Authored by: rv8 on Nov 18, '05 09:46:30AM

If I hibernate my work Dell laptop, there is no battery consumption while the machine is hibernating. It can hibernate for a long period, and the battery is still fully charged when I bring it back to life. This is very useful, as I can work without having to find a power outlet immediately.

If I understand Safe Sleep properly, the machine is still sleeping, and battery power is used to keep the RAM alive. If the machine is left in that state long enough, the battery will be drained. Sure, you can restore everything as it was, once you find a power outlet. But, we really could use a "proper" hibernate function, ala PC laptops.

---
Kevin Horton



[ Reply to This | # ]
A proper hibernate mode would be nice ...
Authored by: mrmister on Nov 18, '05 10:11:11AM

You do not understand Safe Sleep properly--it works much like the one on your Dell.



[ Reply to This | # ]
A proper hibernate mode would be nice ...
Authored by: PeteVerdon on Dec 12, '05 01:57:44PM

Actually, I think he does. It's true that Safe Sleep doesn't use any power, but (as designed) the computer only enters Safe Sleep once it has exhausted its battery in normal Sleep. So, while you don't lose anything, you do need a source of power in order to use it.

Pete



[ Reply to This | # ]
Isn't this a very old feature of PBs?
Authored by: bolah1313 on Nov 18, '05 07:59:14AM

I may be mistaken but I could have sworn all of the PowerBooks, which all have backup batteries, will automatically sleep the computer when the main battery is depleted allowing you up to four minutes to change it. In fact when I got the original G4 PowerBook (Ti Book) I used to show off to all my PC friends that I can remove the battery and still retain all my windows. How is the safe sleep different.

---
Tino XIII



[ Reply to This | # ]
Isn't this a very old feature of PBs?
Authored by: bolah1313 on Nov 18, '05 08:03:39AM

Never mind I found the answer.

---
Tino XIII



[ Reply to This | # ]
Isn't this a very old feature of PBs?
Authored by: syko on Nov 18, '05 08:53:50AM

And what's the answer?



[ Reply to This | # ]
Isn't this a very old feature of PBs?
Authored by: unforeseen:X11 on Nov 18, '05 09:03:37AM

The answer is that in "safe sleep", the content of the RAM gets written to the harddrive. This way, you can remove any power source for years and the Mac will still wake up as you closed it. ;-)

---
this is not the sig you`re looking for.



[ Reply to This | # ]
Isn't this a very old feature of PBs?
Authored by: rawhead on Nov 18, '05 05:46:57PM

I think another answer to that is that only 15 and 17in PB had that feature. My 12in didn't.

---
All these moments will be lost in time
Like tears in rain.
Time to die.



[ Reply to This | # ]
Success: 15" PowerBook G4
Authored by: renderhead on Nov 18, '05 09:21:36AM

This hint (as laid out in the blog entry) worked perfectly for me.

Computer Specs:
15" Aluminum G4 Powerbook
CPU: 1 GHz
Memory: 1.5 GB
Boot ROM Version: 4.7.1f1

Aside from the memory upgrade, the computer is a factory-standard 15" PowerBook, purchased in the spring of 2004.



[ Reply to This | # ]
Success: 15" PowerBook G4
Authored by: beccles on Nov 19, '05 12:29:10AM

Ditto!

Computer Specs:
15" G4 Powerbook
CPU: 1.5 GHz
Memory: 1 GB
Boot ROM Version: 4.8.6f0

Purchased Jan [summer!] 2005.



[ Reply to This | # ]
sudo
Authored by: SOX on Nov 18, '05 09:31:07AM

I noticed that my sudo session was preserved across the sleep. I invoked the hybernation by using sudo, then when it woke sudo did not ask me to re-enter my password.



[ Reply to This | # ]
pressing return after each line does not work
Authored by: SOX on Nov 18, '05 09:33:38AM

I use tsch not bash. When I press return after each of those lines it tells me the quotation is not closed.



[ Reply to This | # ]
pressing return after each line does not work
Authored by: perturb on Nov 19, '05 04:46:45AM
In csh/tcsh, you need to terminate incomplete lines with a backslash:
sudo nvram nvramrc='" /" select-dev\
" msh" encode-string " has-safe-sleep" property\
unselect\
'


[ Reply to This | # ]
Did not work for me
Authored by: SOX on Nov 18, '05 09:42:51AM

I tried using the
sudo pmset -a hibernatemode 1
as detailed in the link to induce hiberantion without removing the battery. This failed. I did not get any "safe sleep" entry in the system log or the wake-up screen.

The only deviation I made from the directions was typing the command all on one line:
sudo nvram nvramrc='" /" select-dev " msh" encode-string " has-safe-sleep" property unselect'

since tsch would not let me break it into 3 lines.



[ Reply to This | # ]
oops works now! small warning.
Authored by: SOX on Nov 18, '05 10:14:32AM

I was an idiot and did not reboot.
Work of advice: Don't do this with an external monitor and the hibernate mode set to 1 instead of 3. if you do then you have to open up the powerbook to restart it every time and you cannot operate it with the lid closed!



[ Reply to This | # ]
Superhint
Authored by: zpjet on Nov 18, '05 10:30:18AM

YES! there should be a category Superhints here and this one is one of them. i tried to fill up my 2 gb of memory of my 15" january 2005 powerbook launching about 30 applications, and then it took some time yes, one minute to sleep, a bit more to wake up (since it takes a few seconds to make it to gray screen). but normally loaded, it took less than half a minute! i won't use it always i think, especially while on the road, but i absolutely love to have the option!

one more up, the sleepy light is not disturbing when i sleep near my computer!

a few notes: you won't see the advertised gray and blurry screen while booting when you password protected your computer (System Preferences > Security > Require password...)

i noticed a bit odd behavior when entering password after safe sleep, sometimes the keyboard response was delayed.



[ Reply to This | # ]
10.4: Enable safe sleep on some older Macs
Authored by: theocrates on Nov 18, '05 01:17:52PM
I posted a couple of comments at Andrew's web site (see them under my other alias, "Shocktrooper") regarding Safe Sleep and third-party batteries that I thought might be useful mentioned here, too.

In a nutshell, third-party batteries do not support Sleep mode, so they do not auto-sleep like Apple batteries when they run low; instead, they simply run down and cut out the computer, which means you lose all unsaved data and need to reboot to get up and running again. After activating the Safe Sleep hack, however, I discovered that when my battery ran down and cut out my computer, pressing the power button did not reboot but restored the Safe Sleep image instead. Huh?! I thought Safe Sleep only worked when your computer lost power while it was sleeping?

I have now replicted this result four times with no problems. Still, I can't quite explain this behavior, and the only thing Andrew says is that
[w]hen your Mac is set to sleep, it will now enter regular Sleep mode first (consuming minimal power). It will only enter Safe-Sleep if the battery is very low on power, or is unpluged [sic].
which seems to leave open the possibility that the computer only need be low on power, but not actually sleeping, to go into Safe Sleep mode. But this is not clear here and I have not seen any posts that specifically do talk about this issue.

In any event, I'm still happy that I can run down my battery without losing any unsaved data. But it would be cool if someone could clear up the issue for me. Anyone else out there with third-party batteries that can confirm my results or give a clearer explanation of what's happening here?

[ Reply to This | # ]
10.4: Enable safe sleep on some older Macs
Authored by: saint.duo on Nov 18, '05 02:36:43PM

Sleep - in and of itself, is just closing the lid or selecting sleep, and being able to wake the computer by opening the lid or pressing a key, and coming back to where you were. This is supported by all batteries, as the computer is just going into a low power mode.

Sleep Swap is where you can remove a battery, and put in a fresh one and then be able to actually wake the computer back up, not having to boot it. This only works on PowerBooks (not the 12"), due to a backup battery or capacitor in the computer (depending on the model)

Safe Sleep monitors the charge level of the battery, and if during sleep, it gets to a certain point, saves the contents of RAM to the hard drive and safely shuts the machine down. The difference here is that before safe sleep, the computer would just turn off, possibly corrupting data.

I can only imagine that some 3rd party batteries may cause sleep swapping not to work, but I wouldn't know how.

---
duo



[ Reply to This | # ]
forgot deep sleep...
Authored by: saint.duo on Nov 18, '05 02:39:05PM

Deep sleep is probably what some 3rd party batteries do not support. Before safe sleep, when the battery reaches a certain point, the computer enters a sleep mode that cannot be woken from without the power adapter, but is using a very minute amount of battery power to preserve the contents of RAM. If you leave it long enough like this, then the computer will just shut off from complete lack of power.

---
duo



[ Reply to This | # ]
Works on iBook G4 1.33MHz
Authored by: emendelson on Nov 18, '05 05:00:22PM

As the heading says. With a current-model iBook G4, I can close the lid, wait for the pulsing sleep light to come on, remove the battery (and AC adapter if connected) - and then put back the battery, press the power button, and watch the machine re-emerge from sleep. Very nice - and something that every x86 laptop has had for years.



[ Reply to This | # ]
Works on iBook G4 1.33MHz
Authored by: rawhead on Nov 18, '05 05:54:10PM

Uhh, you're talking about "Hibernate" right?

But has every Wintel laptop had the ability to be in regular "sleep" mode from which you can wake up in less than a second (actually, Wintel "sleep" is never that quick to wake up), then go into "hibernate" when the battery is running low or is suddenly removed?

I didn't think so.

I agree that not being able to selectively "force" a hybernate-like mode barring removing the battery after sleep is kinda sucky, but in terms of implementation, I love SafeSleep much better than what I can get on my Wintel machines right now (that is, each time I have to choose between sleep and hibernate)


---
All these moments will be lost in time
Like tears in rain.
Time to die.



[ Reply to This | # ]
10.4: Enable safe sleep on some older Macs
Authored by: xavierbdm on Nov 19, '05 07:36:26AM

Safe sleep does not what you say it does.
Setting up safe sleep on a machine, means that EACH time your laptop goes to sleep it will save the RAM to disk, EVERY time.
It is meant as a safeguard.
That is why you can pull out the battery and the power cord of a laptop that has the feature activated (but was put in sleep the "normal" way), and get it to wake up afterwards.
The laptop never wakes up to save RAM to disk when battery is low.
(that would be relying on battery having enough back-up juice left to actually do that. It is the Windows implementation. Clumsy, unefficient and dangerous too -imagine if the laptop is being bounced in a bag while waking up to enter hibernation-)

---
iMac G4 17 800/512/80 + powerbook firewire G3 500/512/30



[ Reply to This | # ]
Does not work on 867 MHz
Authored by: feyd on Nov 18, '05 06:39:57PM

I didn't *think* it would work...but I hoped it would for battery swaps.

The display turns off and it looks like it is going to sleep but it never does. The HDD stays spinning and the machine becomes unresponsive.

:(

~me



[ Reply to This | # ]
10.4: Enable safe sleep on some older Macs
Authored by: sjonke on Nov 18, '05 09:28:47PM

Has anyone tried this on a non-Powerbook? Does it work on PowerMacs? I have a PowerMac G4 Dual-533 in particular. I would like to try it in part because I'm hoping it might resolve the crash-at-sleep problems with USB 2 PCI cards. If it's writing the state of ram to memory and then powering off, perhaps it would do the trick?

---
--- What?



[ Reply to This | # ]
10.4: Enable safe sleep on some older Macs
Authored by: TrumpetPower! on Nov 19, '05 11:38:21AM

Works perfectly on my 12" 1 GHz PowerBook G4 (PowerBook6,2) w/ 1.25 Gbytes RAM.

I've got an external display attached, and it often takes the PowerBook a few extra seconds to detect the display on wake, even if it was attached when it was put to sleep (and not disconnected while sleeping). The time it took to wake from Safe Sleep really didn't feel any longer than usual.

My PowerBook is old enough that the two batteries I got with the computer just don't hold the same charge they used to. On more than one occasion I've been quite inconvenienced by having to find a power outlet, shut down, or whatever just to deal with a battery swap. I'm simply delighted that this is now solved!

My parents have a relatively new eMac. Their power is also somewhat unreliable, tending to spikes and drops and many more outages than I have here. They just got an immortal power supply with voltage regulation to clean the power. I'll be trying this out on their computer the next time I'm there; it could mean that they'll never notice a power problem again, unless they actually try to use the computer when it's out.

Cheers,

b&

P.S. I'm doing a cut-and-paste of these comments between Andrew's original blog entry and Mac OS X Hints. No, it's not a case of deja-vu, sorry. b&



[ Reply to This | # ]
10.4: Enable safe sleep on some older Macs
Authored by: KenaiTheMacFan on Nov 21, '05 10:56:06AM

immortal power supply? :D
do you mean uninterruptible power supply?;)

---
Ian



[ Reply to This | # ]
bluetooth always ON
Authored by: vexingv on Nov 19, '05 12:16:44PM

i was able to enable safe sleep on my 12" 1.33 powerbook running 10.4.3. it took a few extra seconds to enter sleep, but waking up (with powersource) was just as fast, but of course waking up after having been removed from a powersource was longer as it read from the hard drive.

but i noticed that after waking up from hard drive, bluetooth is set to discoverable and there's no way to turn it off from either prefs or the menubar. anyone else experience this behavior as well? only after disabling safe sleep and restarting does bluetooth go back to normal. i think safe sleep would be a useful feature, but not if it leaves bluetooth persistent (i never use BT).



[ Reply to This | # ]
bluetooth always ON
Authored by: TrumpetPower! on Nov 19, '05 03:49:30PM

Strange. I had Bluetooth off before enabling Safe Sleep, and it's still off now.

You sure your problem is with Safe Sleep?

Cheers,

b&



[ Reply to This | # ]
bluetooth always ON
Authored by: vexingv on Nov 19, '05 08:42:06PM

yeah bluetooth was definitely off before i had enabled safe sleep. upon wake after removing the battery, the menubar icon changed and then the option to turn off was greyed.



[ Reply to This | # ]
Use it anytime with SuspendNow
Authored by: BOlle on Nov 20, '05 12:13:04PM

With SuspendNow!, you can use safe sleep whenever you want. Mind you: i'm just reciting the claim, I'm on a Ti myself. No testing here.

http://www.jackoverfull.altervista.org/applicazioni/



[ Reply to This | # ]
Safe Sleep on the mini
Authored by: gabester on Nov 21, '05 07:17:35AM

I've tried this on my 1.25Ghz mini, 512 MB RAM with an upgraded, non-Apple OEM 60 gig hd and it works so far without a flaw.

If you read Andrew Escobar's log, there is a way to set Safe Sleep as your default mode of sleep, perfect for me with the mini because I'm always letting it fall asleep through inactivity then forgetting it's still powered and unplugging it or the power strip it's plugged into.

Since I don't have a laptop this works on, I don't know if by setting the default sleep mode to Safe Sleep, your laptop will continue to use standard sleep while power is available, or if it will just go straight into Safe Sleep every time. On my Mac mini, it goes straight into Safe Sleep.

Now if only I could find a combination battery pack/power supply for the mini, I could use it as a truly portable computer.
g=



[ Reply to This | # ]
WARNING: Really can be very dangerous!
Authored by: sjonke on Nov 22, '05 07:08:39AM
I think perhaps Apple has good reason to not have this feature enabled on older machines. This morning my Powerbook ended up in a state that was very difficult to recover from. I could not even get into open firmware!

I had been using the Safe Sleep feature set to always Safe Sleep (hibernatemode set to 1) without problems for a couple days. Then I decided to try seeing if Safe Sleep would retain my VPN connection. We use Cisco's VPN client. So I connected to the VPN, then put my PB to sleep. When I then powered it back up it did the usual Safe Sleep progress bar and then I ended up with a lit, but black screen with only the mouse cursor on it. Obviously this is the screen saver lock, except that it never presented a password entry screen and nothing I tried could make it do it. At this point I tried various things including putting it back to "safe sleep" by closing the lid, then re-opening and powering up. Forcing the power off (holding down the power key until it powered off) and rebooting. Of course it then just safe sleep recovered back to the same blank screen! I tried holding down SHIFT while booting. Also I tried disconnecting my external display and then reconnecting. Through some combination of these events, I ended up with only the external display powered - the internal, even with the lid open, would not turn on! I tried to boot into open firmware with command-option-o-f and while it probably worked, I couldn't see anything because the internal screen stayed off!!

The best I could get was the external display powered but with nothing on it and the internal display still off. I guess I could have tried to type into the open-firmware screen blind, but that seemed awfully dangerous. Fortunately I do have a firewire drive with a clone backup. So I tried holding down Option at boot and while this again probably worked, I couldn't see anything because the screen was still off, of course. Fortunately I knew that other hint for booting from an external drive: hold down command-option-shift-delete. That forces your Mac to ignore the internal drive. This worked. Then I was able to go to the terminal and disable the Safe Sleep feature by entering: sudo nvram "use-nframrc?"=false. If you've had it enabled and you decide to disable it, you can save yourself quite a bit of disk space by deleting the safe sleep image that will remain and use up disk space if you don't manually delete it. So after disabling this hint, enter: sudo rm /var/vm/sleepimage

I wonder if there aren't hardware differences in the new Powerbooks that allow this Safe Sleep feature to work safely that are not in older machines

---
--- What?

[ Reply to This | # ]

10.4: Hibernation as a command-line utility or widget
Authored by: Cochonou on Nov 22, '05 02:03:31PM
I have written a small program allowing to turn on hibernation (or deep sleep) from the command line or from a widget :
If you are interested, get it from dashboardwidgets or get it from my site.

[ Reply to This | # ]
10.4: Enable safe sleep on some older Macs
Authored by: 93 Escort Wagon on Nov 26, '05 12:53:06PM

Worked for me on a 1.25GHz 15" Al Powerbook. Funny thing is, I didn't initially see the part about 'secure virtual memory' (which I do use), so I didn't use the altered settings - but I've gotten it to hibernate and then wake up several times without any issues. So perhaps this actually works correctly after all, despite the report to the contrary?



[ Reply to This | # ]
10.4: Enable safe sleep on some older Macs
Authored by: inik on Nov 26, '05 03:55:46PM

No problems on a Powerbook G4 1ghz AiBook.



[ Reply to This | # ]
How to DISable it?
Authored by: wackazong on Mar 01, '06 07:43:46AM

Hi!

I tried out wether it worked on my Powerbook, it does. Soon I realized that this permanently decreases my harddisk size by 1GB (the amount of RAM I have). So I tried to disable safe sleep (as shown on the mentioned blog), but every time I reboot, the /var/vm/sleepimage is recreated.....

Anybody know how to completely disable safe sleep???

Thanks!



[ Reply to This | # ]
10.4: Enable safe sleep on some older Macs
Authored by: ccsccs7 on Apr 20, '06 09:15:09PM
I enabled this a while ago, but it came in real handy recently when my PowerBook 12" exerienced one of its "dying-in-sleep" episodes where it fails to wake from sleep and can only be restarted by forcing a "shutdown." (Yeah, I don't understand how it "thinks" it's on, but has no change in state until after the shutdown and power on procedure.) I was way excited to see that the good ol' hibernation kicked in at startup to restore my setup to how it was before the last sleep instance. :)

[ Reply to This | # ]
Works Great - PB G4 12 1.5GHz
Authored by: alexmathew on Oct 19, '06 07:57:57AM

Thanks!!
AM



[ Reply to This | # ]