Getting Lion to Sleep

My college friend, a zookeeper in St. Louis, confirmed my theory that nobody has really ever had trouble convincing a lion to sleep; it’s essentially all lions do.  In fact, in captivity, they sleep an average of 13.5 hours of the 24-hour day!


That said, as I mentioned in my post regarding my first impressions of OSx86 Lion, this little kitty’s sleep schedule was an issue right off-the-bat; it became an even bigger problem when we received our electric bill after a month of sleepless nights.

The Problem

Lion would sleep.  It would even wake from sleep– and even better than that, it would wake from sleep with a simple double-click of the (bluetooth) mouse, a commodity not afforded to me whilst running Snow Leopard on the ol’ hackintosh.  The problem arose when rebooting the machine anytime after I put it to sleep: CMOS would reset, indicating a checksum error.  My overclock settings would be lost (I’d have to load them from a saved BIOS configuration), necessitating a second reboot.  Kind of like when I crash hard at about 10:00 AM the day after taking Benadryl before I go to sleep.

The Solution

The dedicated folks at tackled the problem with gusto (as always!) and determined that the AppleRTC.kext was once again to blame (it’s an old foe, if you didn’t know…).  The thread dedicated to this issue is long, but the good news is that the problem can be fixed with a simple terminal command that patches the AppleRTC.kext in /System/Library/Extensions.  I recommend making a copy of the kext before applying the patch.

Note:  You need to have a working DSDT.aml in order for sleep to work at all (at least with Gigabyte motherboards).

Here is the code to run in Terminal:

sudo perl -pi -e 's|\x75\x30\x44\x89\xf8|\xeb\x30\x44\x89\xf8|;
s|\x75\x3d\x8b\x75\x08|\xeb\x3d\x8b\x75\x08|' /System/Library/Extensions/AppleRTC.kext/Contents/MacOS/AppleRTC

Follow it up with these commands that fix permissions on the newly-patched AppleRTC.kext (actually, on the entire /System/Library/Extensions directory):

sudo chown -R 0:0 /System/Library/Extensions
sudo chmod -R 755 /System/Library/Extensions

Voila!  Reboot (so OS X can load the new kernel extension) and put your hackintosh to sleep.  Wake ‘er up and reboot to test whether or not the patch worked.

As a side note, I had  kernel panic when I tried to sleep my machine for the first time.  It pointed to a couple of USB kernel extensions as the cause, so I turned on the Chameleon “USB Fix: option and rebooted.  I’ll do some more research on whether or not the USB drivers actually caused the panic or if it was random (perhaps my iPhone was syncing when I tried to put my box to sleep or something– I know it was connected).  The second try worked like a charm.

As always, thanks to the community for their hard work, specifically BlackOSX.  Job well done!