Sunday, February 13, 2011

Hibernate Mode on Macbook Pro with OptiBay

Recently i bought an OptiBay Drive for my Macbook Pro. The OptiBay Drive allows you to replace your Superdrive with another hard disk or SSD.

I used the OptiBay to install an Intel X25 SSD on my Computer. I put the os on the SSD. After that, the system really works fast. This article has a video comparing an old macbook pro with hard disk to an old macbook pro with SSD. The article is in german, but you will understand the included video without knowledge of german.

But after the installation of the os on the SSD i had a problem: when i put the machine on standby it froze. I had to power of the machine and restart it. After some research if found out, that by default, mac os uses the "sleep and hibernate" mode for standby.

In sleep mode, the ram content is maintained. Of course this works only as long as there is power to maintain the ram contents. Waking up the machine from sleep mode is very fast.

In hibernate mode, the ram content is written to the hard disk. The content can be restored even if the battery fully died.

"Sleep and hibernate" mode means the machine goes to sleep mode but for safety reasons the disk content is also written to the hard disk.

For some reasons, entering hibernate mode only works if the ram content is written to the primary disk. But since i installed the os on the (secondary) SSD, the system tries to write the ram contents to the secondary disk. When doing this the system freezes.

First i tried to move the hibernate file to another disk. This is possible, the file is written when the system goes to standby. But when you try to wake up the system after a power loss, the system boots from scratch and does not restore the state which was written to the hibernate file. The reason for this is that the hibernate file must be on the root volume.

I solved the problem by changing the hibernate mode from "sleep and hybernate" to "sleep". This can be done with the pmset command:
sudo pmset hibernatemode 0
Now the system can be put in standby mode again!. The only drawback of this solution is that the current state can not be restored after a power loss (e.g. battery was empty).

As a last step you can recover some disk space on your ssd and remove the hibernate file. It is not used anymore.
sudo rm /var/vm/sleepimage