Difference Between GRUB & LILO

Difference Between GRUB & LILO
You may have heard about another Linux bootloader called LILO (stands for Linux Loader). Briefly, a boot loader is the first software program that runs when a computer starts. It is responsible for loading and transferring control to the operating system kernel software (such as the Hurd or Linux). The kernel, in turn, initializes the rest of the operating system (e.g. GNU).
While a sensible option for many Linux users, I believe that GRUB is a better choice, for several reasons:

LILO supports only up to 16 different boot selections; GRUB supports an unlimited number of boot entries.
LILO cannot boot from network; GRUB can.
LILO must be written again every time you change the configuration file; GRUB does not.
LILO does not have an interactive command interface.
All in all, it seems that GRUB is the winner. So let’s see what this baby can do.

How does GRUB work?

When a computer boots, the BIOS transfers control to the first boot device, which can be a hard disk, a floppy disk, a CD-ROM, or any other BIOS-recognized device. We’ll concentrate on hard disks, for the sake of simplicity.

The first sector on a hard is called the Master Boot Record (MBR). This sector is only 512 bytes long and contains a small piece of code (446 bytes) called the primary boot loader and the partition table (64 bytes) describing the primary and extended partitions.

By default, MBR code looks for the partition marked as active and once such a partition is found, it loads its boot sector into memory and passes control to it.

GRUB replaces the default MBR with its own code.
GNU GRUB is a Multiboot boot loader. It was derived from GRUB (GRand Unified Bootloader), which was originally designed and implemented by Erich Stefan Boleyn.

Furthermore, GRUB works in stages.

Stage 1 is located in the MBR and mainly points to Stage 2, since the MBR is too small to contain all of the needed data.

Stage 2 points to its configuration file, which contains all of the complex user interface and options we are normally familiar with when talking about GRUB. Stage 2 can be located anywhere on the disk. If Stage 2 cannot find its configuration table, GRUB will cease the boot sequence and present the user with a command line for manual configuration.

Stage 1.5 also exists and might be used if the boot information is small enough to fit in the area immediately after MBR.

The Stage architecture allows GRUB to be large (~20-30K) and therefore fairly complex and highly configurable, compared to most bootloaders, which are sparse and simple to fit within the limitations of the Partition Table.

GRUB notation

This section is intended to help you get familiar with GRUB, without touching anything. The next section deals with actual files and manual configuration.

GRUB has its own notation, which is very similar yet somewhat different from the general notation a typical Linux user might be used to.

Now, here’s an example of a typical GRUB entry:

(hd0,1)
The brackets are a must; all devices listed in GRUB menu must be enclosed in brackets.
hd stands for hard disk; alternatively, fd stands for floppy disk, cd stands for CD-ROM etc.
The first number (integer for geeks) refers to the physical hard drive number; in this case, the first drive, as they are counted from zero up. For example, hd2 refers to the third physical hard drive.
The second number refers to the partition number of the selected hard drive; again, partitions are counted from zero up. In this case, 1 stands for the second partition.
From here, it is evident that GRUB (menu) does not discriminate between IDE or SCSI drives or primary or logical partitions. The task of deciding which hard drive or partition may boot is left to BIOS and Stage 1.

As you see, the notation is very simple.

Primary partitions are marked from 0 to 3 (hd?,0), (hd?,1), (hd?,2), (hd?,3). Logical partitions in the extended partition are counted from 4 up, regardless of the actual number of primary partitions on the hard disk, e.g. (hd1,7).

The entries alone are not enough to boot an operating system though.

GRUB also needs to know what operating system images to load. These are assigned as parameters to each of the called devices, including special flags (switches). For example, Windows Safe Mode is a special flag.

Leave a Reply

Your email address will not be published. Required fields are marked *