Last Updated on 08/12/2010 by dboth
GRUB stands for “GRand Unified Bootloader” and it is now the primary bootloader for most current Linux distributions. GRUB is the program which makes the computer just smart enough to find the operating system kernel and load it into memory.
GRUB has been designed to be compatible with the multiboot specification which allows GRUB to boot many versions of Linux and other free operating systems; it can also chain load the boot record of proprietary operating systems.
GRUB can also allow the user to choose to boot from among several different kernels for any given Linux distribution. This affords the ability to boot to a previous kernel version if an updated one fails somehow or is incompatible with an important piece of software. With proprietary operating systems this is not possible as it is an all or nothing scenario to upgrade.
Three Stages of GRUB
GRUB has three stages. Each stage is designed to work within the limitations of its environment during each stage of the boot.
Stage 1 of GRUB is actually the Master Boot Record (MBR) on the bootable hard drive or other bootable device.
GRUB Stage 1 is loaded into memory by the BIOS. Because the MBR is located on the first sector of the first cylinder of the hard drive and shares that 512 bytes with the partition table, it is very small. It is just smart enough to find and load stage 1.5 of the boot loader into RAM and then turn over execution to GRUB stage 1.5.
Stage 1.5 of the GRUB bootloader is located in the /boot/grub directory. Actually there are several files for stage 1.5 of GRUB located there, one for each type of filesystem that can be made bootable by Linux. Stage 1.5 of GRUB is specific to the filesystem type, such as ISO9660, XFS, Reiser, EXT2/3, and others.
The purpose of stage 1.5 is to locate and read into memory GRUB stage 2. It does this and then turns control of the computer over to GRUB stage 2.
Stage 2 of GRUB is also located in the /boot/grub directory. Its function is to load the kernel into memory and turn over execution to the kernel.