[HowTo] Boots into Linux in 5 Seconds


Introduction

Booting fast can significantly impact the user experiences. This HowTo briefly introduce Boot Gear, a method to make a Linux desktop boot into X window faster, and yet remain full functional.

The best result so-far is 5 seconds from boot loader into X:

To reduce the boot time, Boot Gear bypass lots of initial actions, improve the parallel process, and use a rewritten init/startx program instead of autologin and display manager.

Hardware detail of testing platform is Ubuntu 8.04 x86, with Linux Kernel 2.6.24:

Motherboard: Gigabyte C51-MCP51
CPU: AMD Athlon 64 Processor 3000+
Memory: Hyundai 1GB
Hard Disk: WDC WD1600JS-55N


Step 1: Get rid of initrd

By building the necessary funtions into kernel, you can directly boot without initial ramdisk.

For example, the kernel needs these modules to initialize my SATA2 hard drive:

sd_mod      (CONFIG_BLK_DEV_SD)
scsi_mod    (CONFIG_SCSI)
libata      (CONFIG_ATA)
sata_nv     (CONFIG_SATA_NV)
ata_generic (CONFIG_ATA_GENERIC)

Since I use Ext3 as filesystem, CONFIG_EXT3_FS is also needed. Change these settings in .config from =m to =y, build by make bzImage, and copy the file arch/x86/boot/bzImage to /vmlinuz-fast. This is our new kernel.

Step 2: Use a fast init

The init used to be InitNG, but soon I have moved to finit due to its extremely fast speed.

Check out the source code:

git clone http://helllabs.org/git/eeepc.git
Be sure to modify the default user account in Makefile, after make, copy the file finit-mdv to /sbin/finit-mdv.

Step 3: Start the X

The Xorg needs dbus, udev and hal daemon. Add a script called /usr/sbin/services.sh:

#!/bin/sh
/etc/init.d/dbus start 2&>1 > /var/log/service.log
/etc/init.d/udev start 2&>1 >> /var/log/service.log &
/etc/init.d/hal start 2&>1 >> /var/log/service.log &

This will be executed by finit after startx.

Step 4: Log everything while booting (Optinal)

To profile (and showing off) the result of boot time, you need a tool called bootchart.

Download bootchart-0.9.tar.bz2 from the website, extract it and install by ./install.sh.

Edit /sbin/bootchartd and change init variable:

init="/sbin/finit-mdv"

Add a new line into /usr/sbin/services.sh:

/sbin/bootchartd stop

Finally, modify the bootloader entry (GRUB for example):

title           Boot Gear fast booting
root            (hd0,6)
kernel          /vmlinuz-fast root=/dev/sda7 ro init=/sbin/bootchartd
Note that you can't use UUID format as root parameter.

After reboot, we have a fast booting Linux system now.


Where do we go from here

Let's take a more detail look at booting process:

You may have noticed that X start from the third second, and then services.sh was executed.

There still quite some hard works to do, including:

Fedora has discussed a worth reading feature named OneSecondX.

Boot Gear is a sub-project of PUD GNU/Linux, a Live CD aim to provide a light and quick Linux desktop, yet remain simple and easy to use.

Thanks, and feedback welcome!
Pin-Shiun Chen (penk) <penkia@gmail.com>