Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

tenderidol

macrumors regular
Original poster
Sep 5, 2009
149
0
Apparently Mac OS X has three hibernation modes (as outlined below from an official Apple document): a. Always save the RAM content to HD and hibernate (this is the default), b. Dont save RAM content to HD (I think this is the "regular sleep" and risks losing data if power is interrupted), and c. Save RAM content to HD and hibernate when the battery power is at a critical level.

I am planning to change the default scenario (point (a) above) to the (c) to avoid writing RAM content to HD every time the lid is closed. Has anyone changed the hibernation modes before? If so, has there been any problems with battery life, data loss, etc etc?

Thanks in advance!

SAFE SLEEP ARGUMENTS
hibernatemode takes a bitfield argument defining SafeSleep behavior. Passing disables SafeSleep alto-gether, altogether,
gether, forcing the computer into a regular sleep.

0001 (bit ) enables hibernation; causes OS X to write memory state to hibernation image at sleep time.
On wake (without bit 1 set) OS X will resume from the hibernation image. Bit set (without bit 1 set)
causes OS X to write memory state and immediately hibernate at sleep time.

0010 (bit 1), in conjunction with bit 0, causes OS X to maintain system state in memory and leave sys-tem system
tem power on until battery level drops below a near empty threshold (This enables quicker wakeup from
memory while battery power is available). Upon nearly emptying the battery, OS X shuts off all system
power and hibernates; on wake the system will resume from hibernation image, not from memory.

hibernatemode is set to 3 (binary 0011) by default on supported portables.

hibernatemode is set to (binary 0000) by default on supported desktops.

Please note that hibernatefile may only point to a file located on the root volume.
 
I have a widget on my dashboard called "Deep Sleep", it forces it to hibernate. Because "sleeping" drains the battery too quickly..
 
having being used to quick sleeping G4 powerbooks and never having an issue, I disabled safe sleep as soon as I got my MBP (that was in 2006)
 
having being used to quick sleeping G4 powerbooks and never having an issue, I disabled safe sleep as soon as I got my MBP (that was in 2006)

That's what I'd like to do as well. I rarely put my MBP to sleep by closing the lid or letting it run unattended for a while. However, for the few times that it goes into sleep, I dont want it to write the RAM content to my SSD which will create unnecessary wear.

Is that how you disabled it?

note: this will disable saving RAM contents to your SSD, so you may have the risk of losing work if you lose power while your computer is asleep.

Go to a terminal and execute this:
sudo pmset -a hibernatemode 0

Then remove the sleepimage:
sudo rm /private/var/vm/sleepimage

Did you ever try mode "2" (the one where the machine hibernates if the battery level is too low)?

Thanks in advance!
 
Yes:
sudo pmset -a hibernatemode 0
Was what I used. It has even stayed set like that since 2006 without me even having to reapply it. I expected when I did it that I would have to keep bodging it after system updates etc. but it has been permanent.
 
thank

I actually went to the dashboard site on apple.com and search for deep sleep, sleep, hibernate and it didn't bring up anything.
 
On the safe sleep arguments, I think one of the reasons it came about was that on the G4 powerbooks they had a second battery backup. You used to be able to shut the lid on a dying computer, rip the battery out, slot in a new one and open the lid without loosing anything. When the MBPs came out they dropped the second battery so safe sleep was a way of getting around this backstep. The rapid sleep/wake to me has always been a huge selling point over the XP laptops and something that makes windows users jealous, safe sleep to me is a step towards windows hibernate.
 
I use this:

http://www.jinx.de/SmartSleep.html

1) smart sleep: sleep if battery charge is above the sleep & hibernate level.
2) sleep & hibernate when below the sleep & hibernate level. hibernates only when battery charge is below 5% or less than 5 minutes.
3)sleep: machine will go to sleep only (saves state in RAM only, battery keeps RAM contents)
4)sleep & hibernate: machine sleeps and hibernates. (default)
5)hibernate only machine will go to hibernate only. (saves state on disk, battery will not be used)

Point 2 is a special combination of two standard modes.
 
Thanks for all the replies. Very informative....

I am still trying to understand what the "default" sleep behavior is when I close the lid of MBP or dont touch it for 15 minutes. Does it put everything into RAM and waits there until it is awaken without writing anything to the HD? If yes, I assume writing the RAM image to HD takes place if you are on a battery power and it goes below a certain threshold. If this is the default, then I dont need to change it because I rarely use my MBP on battery power and even then it doesn't go down to a critical point in a sleep state.

If the default sleep state involves writing anything to the SSD (in my case), I would like to change it to something else.

Thanks again!
 
I use this:

http://www.jinx.de/SmartSleep.html

1) smart sleep: sleep if battery charge is above the sleep & hibernate level.
2) sleep & hibernate when below the sleep & hibernate level. hibernates only when battery charge is below 5% or less than 5 minutes.
3)sleep: machine will go to sleep only (saves state in RAM only, battery keeps RAM contents)
4)sleep & hibernate: machine sleeps and hibernates. (default)
5)hibernate only machine will go to hibernate only. (saves state on disk, battery will not be used)

Point 2 is a special combination of two standard modes.

Whoa. This is pretty sweet. Thanks!

I guess there's one flaw to the second option, though, and that's if you put your laptop to sleep at a high battery level and leave it unattended for a long time. Since it goes to sleep at a high charge it will only save state to RAM but after a long period of time the battery power will diminish and eventually the state saved in RAM will be lost. Not that big of a problem though considering it would probably take a few days for that to happen.
 
I don't hibernate/put my MBP to sleep. It runs on AC power 5 days a week, then gets taken to work on Fridays, operates on battery for an hour or so, and then wanders over to my girlfriend's house where it gets plugged in. On Sunday nigts it migrates back to my house where it gets plugged back in. Even when I owned Windows laptops they never slept/hibernated.

Tom
 
I don't hibernate/put my MBP to sleep. It runs on AC power 5 days a week, then gets taken to work on Fridays, operates on battery for an hour or so, and then wanders over to my girlfriend's house where it gets plugged in. On Sunday nigts it migrates back to my house where it gets plugged back in. Even when I owned Windows laptops they never slept/hibernated.

Tom

But surely you don't transport it turned on? You either sleep or shut it down, don't you?
 
Thanks for all the replies. Very informative....

I am still trying to understand what the "default" sleep behavior is when I close the lid of MBP or dont touch it for 15 minutes. Does it put everything into RAM and waits there until it is awaken without writing anything to the HD? If yes, I assume writing the RAM image to HD takes place if you are on a battery power and it goes below a certain threshold. If this is the default, then I dont need to change it because I rarely use my MBP on battery power and even then it doesn't go down to a critical point in a sleep state.

If the default sleep state involves writing anything to the SSD (in my case), I would like to change it to something else.

Thanks again!

Default behaviour is the following: when the mac goes to sleep the content of the RAM is copied to the Hard drive (or SSD) and the RAM is kept powered on. That way when you wake your mac it's immediately ready thanks to the RAM content. The copy on the Hard drive (or SSD) will only be used if the power is cut, for example if the battery charge is depleted during sleep, so that you won't lose anything.

In case of an SSD, if you want to reduce the write you should try to disable writing to disk, at least when the battery charge is still high. A good way to do it is to use the control panel I posted above and select "Smart sleep" as a mode. So basically unless the battery charge is below a specified threshold the content of the RAM will not be written to disk when you put it to sleep. Only when the battery is low and you put the mac to sleep the content will be written to reduce the chances of losing your current session.

As terriyaki said, the only issue is that the mac has to be on for the control panel to change the sleep mode (to write to disk again) when the battery gets too low.
 
Default behaviour is the following: when the mac goes to sleep the content of the RAM is copied to the Hard drive (or SSD) and the RAM is kept powered on. That way when you wake your mac it's immediately ready thanks to the RAM content. The copy on the Hard drive (or SSD) will only be used if the power is cut, for example if the battery charge is depleted during sleep, so that you won't lose anything.

In case of an SSD, if you want to reduce the write you should try to disable writing to disk, at least when the battery charge is still high. A good way to do it is to use the control panel I posted above and select "Smart sleep" as a mode. So basically unless the battery charge is below a specified threshold the content of the RAM will not be written to disk when you put it to sleep. Only when the battery is low and you put the mac to sleep the content will be written to reduce the chances of losing your current session.

As terriyaki said, the only issue is that the mac has to be on for the control panel to change the sleep mode (to write to disk again) when the battery gets too low.

Thanks again for your reply. Now I know what the default is... I'll try Smart Sleep then.
 
Yes:
sudo pmset -a hibernatemode 0
Was what I used. It has even stayed set like that since 2006 without me even having to reapply it. I expected when I did it that I would have to keep bodging it after system updates etc. but it has been permanent.

the nice thing about it too is that you can delete the hibernation file and save x gigs on the hd (x=the number of gigs of ram you have). Also, your computer goes to sleep in about 2 seconds instead of 10 or so. As long as you don't plan on hot-swapping batteries, it essentially works the same as the other mode.
 
the nice thing about it too is that you can delete the hibernation file and save x gigs on the hd (x=the number of gigs of ram you have). Also, your computer goes to sleep in about 2 seconds instead of 10 or so. As long as you don't plan on hot-swapping batteries, it essentially works the same as the other mode.

So, basically, mode 0 just puts everything to RAM, doesn't write anything to disk and keeps the content of the RAM powered as long as there is enough battery.

This looks like a good option for me because my computer is connected to a power outlet at 95% of the time. Even when I am using it on battery, I rarely close the lid and put it to sleep. Besides, even if it goes to sleep, as long as I wake her up and shut it down before the battery depletes completely, everything will work fine, right?

The only drawback is that if in a rare event I forget this and the computer shuts itself off, there could be some corruption?

Lastly, what's the command to restore it to default in case necessary?
sudo pmset -a hibernatemode 3?

Thanks!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.