GNU GRUB is the boot loader of the GNU project. It was the first boot loader to use the new BIOS features to boot beyond 1024 cylinders and it had a menu interface before LILO. Also it could detect more then 64MB of RAM when other systems could not yet do this.
In an ideal world all operating system kernels would conform to a certain standard so that any kernel could be loaded by any boot loader. The Multiboot standard is such a proposed standard, but very few operating systems conform to it (primarily the GNU HURD operating system). GRUB is designed to conform to the Multiboot standard. Besides Multiboot, it can boot Linux and BSD kernels and chainload anything else. For BSD kernels the latest features of the latest version are not supported, but Linux support is up to date.
GRUB is huge compared to both LILO and SYSLINUX. This is mainly because it can read most file system types by itself. Besides it serves as its own installer and it has many useful and less useful commands. You can recompile it with some file systems and other features configured out to save space.
Just for fun and to show how flexible GNU GRUB really is, we will install the Multiboot compliant GRUB Invaders game as well. Skip this if you don't like it. Unpack the tar archive and just use the invaders binary.
Download the latest version of GRUB (0.92), unpack it and type the following commands in the source directory:
./configure make
Create the file menu.lst with the following contents.
root (fd0) title Linux with RAM disk kernel /boot/zImage initrd /boot/root.img.gz title Linux without RAM disk kernel /boot/zImage root=/dev/fd0 title GRUB Invaders kernel /boot/invaders
Create a diskette and copy the usual stuff to it. The fact that we create a DOS diskette is arbitrary. We could have performed the same procedure with almost any other file system that Linux supports. The files stage1 and stage2 are components of grub that are traditionally installed in the directory /boot/grub on the boot device. The configuration file is menu.lst is also copied to this directory. As opposed to LILO, GRUB reads the configuration file at boot time.
fdformat /dev/fd0H1440 mkfs.msdos /dev/fd0 mount -t vfat /dev/fd0 /mnt mkdir /mnt/boot mkdir /mnt/boot/grub cp zImage /mnt/boot cp root.img.gz /mnt/boot cp invaders/invaders /mnt/boot cp grub-0.92/stage1/stage1 /mnt/boot/grub cp grub-0.92/stage2/stage2 /mnt/boot/grub cp menu.lst /mnt/boot/grub umount /dev/fd0
Now we only need to make this diskette bootable. There are three ways to do it:
Run the GRUB shell:
grub-0.92/grub/grub
In the GRUB shell type the following commands:
root (fd0) setup (fd0) quit
The setup command installs a boot sector program on the given device. Note that GRUB can install its own boot sector, but it cannot write, and hence cannot copy, the required files stage1 and stage2 to the target device. This must have been done before by an operating system.
After you have installed GRUB onto the diskette, you can copy other kernels to it and edit the menu.lst file as much as you like, without the need to reinstall. Only the file stage2 may not be moved.
When you boot the GRUB diskette, you get a menu with three entries. You can do any of the following:
cat (hd0,0)/etc/passwdWhile you type the command, pressing the TAB key shows you which files are available, just as in the bash shell.
kernel (hd0,2)/boot/vmlinuz root=/dev/hda3 read-only bootThis boots a kernel on /dev/hda3. This works, even if you hosed your LILO.