Monday, February 05, 2007

Booting linux in 5 seconds

I envy one thing on mac users. Fast boot times! That's the one thing linux never nailed. My gentoo, from power button to working desktop takes a nudge less than a couple of minutes to boot. I finally solved it, using Suspend2. It works right out of the box.

The full howto is here. The short version, if you are lucky, goes like this:

emerge -av sys-kernel/suspend2-sources

Compile your kernel, setting these options:

Power Management -> Suspend2
Power Management -> Suspend2 -> Swap writer
Power Management -> Suspend2 -> Default device: swap:/dev/hda?
Cryptographic options -> Cryptographic API
Cryptographic options -> LZW
Where ? is your swap partition. Compile and boot into the new kernel. You can now execute the command "hibernate" for the laptop to hibernate.

For the lid to work as a suspend command, on a thinkpad, create the file /etc/acpi/events/button_lid with these contents:

event=button/lid LID 00000080
action=/usr/sbin/hibernate 

For other laptops, close the lid then look on /var/log/acpid for the correct event code.

Finally, to get the behavior of Macs, which suspend to disk and ram, set PowerDownMethod to suspend-to-ram in /etc/hibernate/suspend2.conf. The laptop will suspend to disk first, then to ram. If ram holds up during the power cycle, you'll boot in a couple of seconds. If battery dies, you'll still be safe, as the laptop will boot from the saved image on disk, taking a few more seconds to boot the kernel and read the stored image from disk.

Posted by K at 23:24:10 | Permanent Link | Comments (0) |