Before Red Hat Linux can run, it must be loaded into memory by a special program called a boot loader. A boot loader usually exists on the system's primary hard drive (or other media device) and has the sole responsibility of loading the Linux kernel with its required files or (in some cases) other operating systems into memory.
LILO comes as standard on all distributions of Linux. To work with LILO an administrator edits the file /etc/lilo.conf to set a default partition to boot, the time-out value, where choices should appear in a menu, kernel parameters, which partition is mount as the root partition, whether or not to initially load a RAM disk, where LILO should be installed, and other information. The administrator must then update the loader by running the LILO command.
MBR Vs. Root Partition
The configuration file, by default is read by LILO.
The configuration file tells LILO, where to place its boot loader.
In general, you can either specify the master boot record (MBR) on the first physical disk (/dev/hda) or the root partition of your Linux installation (/dev/hda1 or /dev/hda2).
The first stage of loading LILO is completed when LILO brings up in order of the each of the letters— L I L O.
When you see the LILO prompt, you are in the second stage.
If you are starting with LILO, you can begin editing the configuration file.
For existing Linux users migrating to LILO, you should get the latest version of LILO.
Before you try LILO, you should have an emergency Linux boot disk a CD-ROM, or another storage device in case if there is problem with booting the system from the hard disk. After you install LILO on your system, you can make it take over your MBR.
As a root user, type:
# /sbin/lilo –v –v
LILO Configuration File
Given below is a sample /etc/lilo.conf file.You can have many kernel images on the same /boot system. For other parameters, refer to the manual pages (man lilo.conf).
timeout=50 compact default=Linux
image=/boot/vmlinuz-2.6.23-13 label=Linux read-only root=/dev/hdb3
image=/boot/vmlinuz-2.4.18-14 label=ker2.4.18 read-only root=/dev/hdb3
other = /dev/hda label = WindowsXP
The boot = option tells LILO to install the boot loader to the MBR of the first hard disk. The map = and install = options point to the files that LILO uses internally during bootup. Do not change these files.
While booting, the boot loader will wait five seconds for you to press Shift. If you don’t press any key (esc or shift), then default kernel, will be booted.
If you do, the boot loader will ask you which image to boot. If you forgot the choices, press TAB it will display a menu.
Now you have the choice of booting Linux kernel 2.6.18 or Windows XP. After loading, Linux prompts you to enter a password for the image. You can add the fallback=<command_line> option to any image.
This option specifies that is stored as the default command line if the current image is booted. If using the fallback option, the next reboot will load a different kernel.
GNU GRUB is a boot loader (can also be spelled boot loader) capable of loading a variety of free and proprietary operating systems.
GRUB will work well with Linux, DOS, Windows, or BSD. GRUB stands for GRand Unified Boot loader.
GRUB is dynamically configurable. This means that the user can make changes during the boot time, which include altering existing boot entries, adding new, custom entries, selecting different kernels, or modifying init rd.
GRUB also supports Logical Block Address mode. This means that if your computer has a fairly modern BIOS that can access more than 8GB (first 1024 cylinders) of hard disk space, GRUB will automatically be able to access all of it.
GRUB can be run from any device (floppy disk, hard disk, CD-ROM, USB drive, network drive) and can load operating systems. It can also decompress operating system images before booting them.
Features of GRUB
GRUB contains several features that make it preferable to other boot loaders available for x86 architecture. Below is a partial list of some of the most important features:
GRUB provides a true command-based, pre-OS environment on x86 machines.
This feature affords the user maximum flexibility in loading operating systems with specified options or gathering information about the system.
GRUB supports Logical Block Addressing(LBA)mode.LBA places the addressing conversion used to find files in the hard drive’s firmware, and is used on many IDE and all SCSI hard devices.
Before LBA, boot loader encounter 1024-cylinder BIOS limitation, where BIOS can‘t find a file after 1024 cylinder head of the disk.
LBA support allows GRUB to boot operating systems from partitions beyond the 1024-cylinder limit, so long as the system BIOS supports LBA mode. Most modern BIOS revisions support LBA mode.
GRUB can read ext2 partitions. This functionality allows GRUB to access its configuration file, /boot/grub/grub.conf, every time the system boots, eliminating the need for the user to write a new version of the first stage boot loader to the MBR when configuration changes are made.
The only time a user needs to reinstall GRUB on MBR is, if the physical location of the /boot/partition is moved on the disk.
LILO VS GRUB
GRUB is a better choice, for several reasons:
LILO supports only upto 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 doesnot have an interactive command interface.
LILO present RHEL 4 and GRUB from RHEL 5 onwards
How does GRUB work?
When system boot, the BIOS will transfers to the first boot device, which can be a hard disk, a floppy disk, a CD-ROM, or any other BIOS-recognized device.
The first sector of a hard disk is called the Master Boot Record (MBR).
This sector is of 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. 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 the needed data.
Stage 2 points to its configuration file, which contains the entire 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.
Most of the time, you will not touch GRUB.When operating system is installed, especially in the right sequence (inconsiderate OS first - like Windows, flexible OS later - Linux and family), the GRUB will be installed automatically and relevant entries appended.