Linux Bootloaders (LILO vs. GRUB)

30 November -0001
by: Justin
October 1, 2002

To begin with, lets answer the question of what exactly a bootloader is. A bootloader is a program with a set of instructions that resides in your master boot record (MBR). When your computer starts up, it must first 'boot' or 'boot strap' (taken from the adage to pull oneself up by ones' boot straps). This is basically the process the computer goes through when it wakes up. The computer must discover what equipment is available to it and load some initial instructions. These initial instructions are your BIOS (Basic Input/Output System). Your system's BIOS are actually stored on a small ROM (Read Only Memory) chip on your motherboard. A system's BIOS provides for initial hardware discover and diagnostics (called POST for Power on Self Test). The POST not only instructs your computer where to find and start the processor, but also tells your computer where to look on the hard drive for the MBR (which contains information about how to load the computer operating system). BIOS also provides a CMOS program, which is the GUI that allows you to change boot options. Usually you can hit F10 when a computer starts up to see your CMOS and change CMOS settings. CMOS stands for 'Complementary Metal Oxide Semiconductor' and is actually a small bit of NVRAM (or Non-Volatile Random Access Memory) which is used by the computer during boot. CMOS is powered by a small battery so it can hold memory for a very long time (usually years before the battery needs replacing) that your computer can use during the initial boot up. All of these are critical to you computers boot process since they give the initial instructions to computer for loading your operating system.

Once your BIOS points your system to your MBR, then your bootloader comes into play. Your bootloader will take over the boot process and allow you to point your computer to any number of places on your hard drive for loading the operating system. If you have a computer that boots more than one operating system, the initial instructions for loading the operating system will be stored in different areas on your hard drive. The bootloader will provide a menu of options that will allow you to choose which of these sectors on the hard drive (and thus operating system) you wish to use. If you are only using Linux you can use a bootloader to load different kernel versions or to utilize specialized Linux modes (such as single user mode for maintenance).

There are two industry standard bootloaders available for most Linux distributions: LILO and Grub. LILO stands for LInux LOader, and GRUB stands for GRand Unified Bootloader. While I have almost exclusively used LILO, from what I understand GRUB may be better because if you upgrade your kernel you don't have to reinstall GRUB (but if you use LILO you will have to reinstall it). If you don't plan on making and kernel upgrades you may want to just stick with LILO. The best defense I've found of GRUB is from Mayank Sarup <mayank@freeos.com> at FreeOS.com (http://www1.freeos.com/articles/3482/):

"GRUB, unlike LILO, is able to read filesystems and recognize kernel images too. While LILO requires the physical location of the kernel on your drive, GRUB does not. Even the latest filesystem ReiserFS is supported. This means that you don't have to re-install GRUB every time you make a change to the config file or install a new kernel. If your BIOS supports LBA then there is also no problem reading beyond 1024 cylinders. There's some good support for network booting of diskless clients. On the other hand, GRUB installation can be a bit of a problem. Maybe we're all too used to LILO or maybe GRUB still has some way to go? Little of both we think."

All Linux distributions I have worked with will allow you to choose which bootloader you wish to use. For most people the bootloader choice is an extraneous option since most people will never upgrade their kernels or change anything on their system that would be affected by the bootloader.

The bootloader's power is encapsulated in its ability to allow you to multi-boot operating systems. Thus, with a boot-loader you can run both Linux and Windows on your computer. Be warned, however, if you choose to load Linux and a Microsoft operating system, you should install the Microsoft OS first since some versions aggressively search the MBR and will wipe out any boot loaders that you have previously installed. Linux is perfectly happy loading on a computer with another operating system, and won't complain if you leave unpartitioned (or NTFS partitioned) space on your hard drive with other operating systems.

If you use LILO your bootloader will be controlled by the configuration file found at /etc/lilo.conf. You will find it useful to read the man (manual pages) for both lilo and lilo.conf if you are using LILO. Try 'man lilo' and 'man lilo.conf' at the command line to access these files. You can also find some extensive discussion of LILO at The Linux Documentation Project (tldp.org) site at http://www.tldp.org/HOWTO/mini/LILO-1.html.