Don’t sleep with a patched OS X

I am running a triple-boot (Windows 7, Ubuntu 10.10 and a patched Mac OS X 10.6.3) on a Dell Inspiron 1525 with Intel Core 2 Duo, 250 GB HDD and 3 GB Ram, and using Grub 2 as the bootloader.

A few days ago, Debsankha, one of my collegemates, installed for me the last of these operating systems and fixed the bootloader in exchange for a treat at KFC.

It was working fine until yesterday, when I was working on my desktop and the laptop was on in OS X but wasn’t plugged in. My laptop battery is near the end of its life so it discharges quickly. I couldn’t find a power source for the laptop so I decided to make it sleep to conserve charge till I needed it again. I pressed the power button and chose Sleep, then went back to my work.

Later when I tried to boot it I saw that I couldn’t even go beyond the first boot screen (which is one that asks for the HDD password), because my internal keyboard was disabled. This is a bug with patched OS X’s when it doesn’t have a clean shutdown.

I tried hunting for an external USB keyboard, but couldn’t get one. But I rebooted it a few times and then my keyboard was suddenly working again. Later I discovered that rebooting a few times often reactivates the keyboard.

However, when I chose Mac OS X 32-bit at the grub menu, I got just a blank screen. The light showed some initial hard drive activity, then it went off. The menu entry in grub is supposed to boot OS X via the verbose mode by default (similar to adding the –v flag in the Darwin bootloader), but not a single line of the verbose was being displayed. I looked up online and many threads discussed waking up problems with both original Macs and patched ones. Many of them said that when the screen remains blank, everything’s working fine, except the monitor is not waking. I tested this by waiting for sufficiently long, then typing in my password, pressing enter, or increasing the volume (which is supposed to make a sound), but it appeared that the waking problem was not just with my monitor, and that my system wasn’t really booting. I even tried an external display, to no avail. I changed BIOS settings, trying to get USB devices or the Wi-fi switch to wake the system, but it didn’t work.

Finally I called up Debsankha, who told me to chuck Grub 2 and chainload the Darwin bootloader, and boot with the –v flag. He sent me this link, in which it’s explained how to modify the settings to enable this. Note that the OS X section he talks about is in the /boot/grub/grub.cfg file, which I couldn’t figure out at first.  Make a backup of the file somewhere, in case you screw it up. In any case, you can always generate a working grub.cfg file just by typing update-grub in the Linux terminal, but if you screw up grub, you can’t log in, and then fixing the grub is a bit messy. With the backup, you can just boot with a Live CD or USB and copy back the .cfg. Saves some minutes. To test the .cfg code, you may preserve the existing menu entries, and create a new one, as I did.

IMPORTANT: change the partition numbers in those lines to suit your system. The 2’s there (eg hd0,2) refer to the partition number of the Mac Volume, and the 4’s to that of the / volume of Linux. Check what these numbers are for your system using the Disk Utility. Mine were 3 and 8, for example.

DON’T run update-grub after you change grub.cfg. The file will then be regenerated, and all your changes will be overwritten.

So I did this and rebooted. My menu entry showed up after some tries and I got the Darwin screen, at which I added –v and booted. There were only about 6 lines of text printed, when it tried to load the sleepimage, and said ‘Wake kernel!’

Debsankha looked in the Boothelp file of chameleon and told me to add the flag Wake=No. So I typed –v Wake=No and booted again. This time it worked. It had taken me all of a day.

I’ve preserved the Darwin chainloader entry in my grub. An added bonus is it doesn’t go into verbose by default, so no flags means a GUI boot. Although the ‘GUI’ here is just an inert silver apple in the middle of the screen, I saw that there were quite a few threads even to try and get that using Grub 2.

Debsankha said and I also saw on the web that there might be some kext which would take care of these sleep disorders. However, I have had enough. I’m not going to touch that sleep button again.

If there’s any little point here which you would like to be discussed in detail, you may add a comment. I’ll surely reply.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s