Some time back I disabled hibernation mode on my macbook pro to save space on the drive. This is because hibernation required creation of a sleepimage file which was 2 Gb in size. Recently I stumbled across an article which again listed how to turn this off.
sudo pmset hibernatemode 0
sudo rm /var/vm/sleepimage
I decided to turn hibernation back on after this trip down memory lane, and so, issued the following command: sudo pmset hibernatemode 1
Clearly if 0 (false) turned the setting off then 1 (true) would turn it back on. Yes. But not quite. At least, not how I wanted it. Not how it was before. It actually resulted in my computer going into hibernate mode when it was supposed to sleep. Sleep is a low power state for the computer where the hard drives, monitors, network card and other things almost, but not quite, turn off. Or at least it should be. Hibernate is a state of no power. The computer saves it state information (to either memory or the hard drive) and shuts down. After awaking from hibernate the computer reads this information and restores its former state. As you can imagine this is far slower than awaking from sleep. Hibernate should only happen when the battery is low and the computer about to lose power. After my pmsetting the computer would hibernate whenever it should have been sleeping. Quite annoying.
I finally went to the pmset manual today which bestowed upon me this little gem
SAFE SLEEP ARGUMENTS
hibernatemode takes a bitfield argument defining SafeSleep behavior. Passing
0 disables SafeSleep altogether, forcing the computer into a regular sleep.0001 (bit 0) 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 0 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 system 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.
It seems I had unknowingly only set bit 0 which, causes OS X to write memory state and immediately hibernate at sleep time.
Confused? Me too at first. In computer science numbering starts at zero because. bit 0
then refers to the first bit in a series (of which we have 4). If we have a series 4321, 1 is bit 0
, 2 is bit 1
, 3 is bit 2
and so on. By setting hibernatemode to 1 then I only set the first part of what I wanted - 0001. I also needed to set the second bit giving 0011. As the last line informs us 0011 is binary for 3, so that was the proper setting.
See what happens when we assume? Always read the docs kiddies.
illogic-al.Org