Speed up your Boot Process

From the writings of IKerekes

This is a short guide on how you may be able to speed up your booting time a little. It is not meant to be an exhaustive explanation of how the booting process works, but provides (I hope) just enough information to allow you to understand why this may help.

Booting Process

Most computer systems can only execute code found in memory (ROM or RAM), but modern operating systems are mostly stored on hard disks (or occasionally LiveCDs, USB flash drives, etc.). When a computer is turned on, it doesn't have an operating system in memory. The computer's hardware alone cannot perform the complex actions of which an operating system is capable, such as loading a program from disk, so a seemingly irresolvable paradox is created: how to load the operating system into memory. The solution involves using a special small program, called a bootstrap loader or boot loader. This program doesn't have the full functionality of an operating system, but is tailor-made to load enough other software to start the operating system. Often, multiple-stage boot loaders are used, in which several small programs summon each other, until the last of them loads the operating system.

In modern computers the bootstrapping process begins with the CPU executing software contained at a predefined address in ROM (for example, the BIOS). The CPU is designed to execute this software after reset without outside help. This software contains rudimentary functionality to search for devices eligible to participate in booting, and load a small program from a special section (most commonly the boot sector or Master Boot Record) of the most promising device. The boot process is controlled by the Bootloader, which is placed in the MBR of the first booting device.

The Initrd and Booting

In this document, I am referring to Grub (Grand unified bootloader) or Lilo (Linux loader) bootloaders, and am assuming that the booting device is an IDE hard disk drive with an installation of PCLinuxOS already present.

The bootloader, as many of you will know, loads the kernel and the initrd (Initial Ram Disk) of the installation. These then take care of the operating system boot up processes. The initrd.img file is usually a link to an .img file that is specific to the kernel being used. The specific file is generated when the kernel is installed and is named something like "initrd-<kernel_version>.img". To see what initrd files you have on your computer type the following into a terminal:

ls -l /boot/init*

This should give you an output somewhat similar to this

[root@localhost boot]# ls -l /boot/init*

root root 124605 Jul 19 07:09 /boot/initrd-2.6.16.27.dev2.img

root root 25 Aug 7 07:43 /boot/initrd.img ->initrd-2.6.16.27.dev2.img

Note the second entry is the link we spoke of earlier.

The specific initrd contains an initial root filesystem with enough code to boot the OS with that kernel. When this file is generated the information in the installkernel file (/etc/sysconfig/installkernel) is used - particularly for extra drivers that might be needed for the hardware present. When the original installation took place the LiveCD loaded all the available drivers to ensure that all hardware possible could be used. Most machines will never need the majority of these drivers so they are redundant and can be removed. Removing these should therefore speed up the boot process.

Creating a Custom Initrd

To speed up the boot process by creating a custom initrd file you can either:

  • Install a new kernel
  • or

  • Re-install an existing kernel

The small difference in the method used is due to the fact that if an initrd-<kernel_version>.img file specific to a kernel is present, then a new one will not be generated when that kernel is re-installed. To cause the new initrd.img file to be generated it is necessary to rename or delete the existing initrd-<kernel_version>.img file for that kernel.

So in summary, the information contained in the installkernel file, (more specifically on the "INITRDOPTS=" line), is used when generating an initrd-<kernel_version>.img file for the kernel being installed or re-installed. Remember there is also a file called initrd.img which is simply a link to the last initrd-<kernel_version>.img file created.

If an initrd-<kernel_version>.img file exists for the kernel you are installing, rename it.

Open the /etc/sysconfig/installkernel file as root and edit the "INITRDOPTS=" line to suit your needs. The reason I recommend renaming the initrd-<kernel_version>.img file is that if an error occurs the old file is always there to use again. It can be deleted when you are sure all is OK.

Great care must be taken here to ensure you do not delete any driver that your installation is using.

Having edited the installkernel file to your satisfaction it is now ready to be used by the kernel installation, to generate an initrd-<kernel_version>.img file for that kernel. Simply installing or re-installing a kernel will cause this to happen automatically.

So-

  • Decide on the kernel.
  • Rename the specific initrd-<kernel-version>.img file for that kernel, if it exists.
  • Edit the "INITRDOPTS=" line in /etc/sysconfig/installkernel (example below)
  • Install or re-install the kernel you have chosen.
  • Re-boot the computer.

That's it. You are now booting without the extra drivers you didn't need.

The following is just an example and is not to be used as an indication of what may be suitable for your computer.

Contents of old Installkernel file InitrdOpts line

INITRDOPTS=" --with libata --with sd_mod --with ata_piix --with scsi_mod --with sr_mod --with sg --with aic7xxx --with BusLogic --with ahci --with sata_qstor --with sata_sis --with sata_sx4 --with sata_uli --with sx8 --with sata_sis --with sata_nv --with sata_promise --with sata_sil --with sata_svw --with sata_via --with sata_vsc --with scsi_transport_spi "

The above contains all the sata and scsi disk device drivers. You need only the drivers specific to your hardware. For example if you need the 'sata_sil' driver, the line would look like:

INITRDOPTS=" --with sata_sil"

If you don't have sata or scsi drives only IDE, the contents of the new Installkernel file InitrdOpts line might look like this:

INITRDOPTS=""

If you don't know which driver you require for your Hard Disk go to "PCLinux Control Center -> Hardware -> Manage your system hardware" and select your drive, then read the information from the right panel. More detailed information on booting, and initrd can be found here:-

http://en.wikipedia.org/wiki/Bootloader

http://en.wikipedia.org/wiki/Initrd

The usual caveats apply - you make changes to your operating system, entirely at your own risk.

Top