LPI Linux Certification/Install A Boot Manager

Detailed Objective
(LPIC-1 Version 5.0)

Weight: 2

Description: Candidates should be able to select, install and configure a boot manager.

Key knowledge area(s):
 * Providing alternative boot locations and backup boot options.
 * Install and configure a boot loader such as GRUB Legacy.
 * Perform basic configuration changes for GRUB 2.
 * Interact with the boot loader.

The following is a partial list of the used files, terms and utilities:
 * ,  and
 * MBR
 * MBR
 * MBR

Boot managers
A boot loader is installed in the MBR (Master Boot Record). When a system starts, it loads what is in the MBR to RAM. Under Linux there are two main boot loaders:
 * Lilo: LInux LOader.
 * Grub: GRand Unified Boot Loader.

A boot loader allows you to select the image that you would like to boot from. A system can contain multiple images (operating systems).

A boot loader allows you to interactively run commands and pass parameters to the image that you will boot. The initrd is the driver that will be used to build a filesystem on RAM to mount other filesystems and execute programs.

GRUB is today's default boot loader for many distributions. When installing Windows with Linux, install Windows first and Linux second, because Windows overwrites the MBR without asking.

LILO vs. GRUB
Both are used to load an image from a disk to RAM. GRUB has the following advantages to LILO:
 * More pre-OS commands.
 * Supports images stored beyond the 1024 BIOS cylinder limitation.
 * Can access its configuration file through the filesystem.

When using LILO, each time you add a new image or change an image a new LILO needs to be installed in the MBR.
 * LILO keeps its boot information in the MBR
 * GRUB keeps its boot information in the filesystem (menu.lst).
 * LILO also has a configuration file /etc/lilo.conf.

To install GRUB on the MBR, use grub-install. The command setup will override the MBR.

To install LILO on the MBR, use lilo. The lilo will use the /etc/lilo.conf file to know what to write into the MBR.

Example of /etc/lilo.conf:

boot = /dev/hda # LILO installation target: MBR vga = normal # (normal, extended, or ask) read-only # Mount the root file systems read-only image=/boot/vmlinuz # Image to load label=linux  # Label to display root=/dev/hda1 # Root partition for the kernel initrd=/boot/initrd # Ramdisk other=/dev/hda3 label=windows image=/boot/memtest.bin label=memtest86
 * 1) LILO global section
 * 1) LILO Linux section
 * 1) LILO DOS/Windows section
 * 1) LILO memtest section

Example of menu.lst (GRUB configuration file):

timeout 10 # Boot the default kernel after 10 seconds default 0 # Default kernel title GNU/Linux # Title root (hd0,1) # /dev/hda2 root filesystem kernel /boot/vmlinuz root=/dev/hda2 read-only initrd /boot/initrd boot title Winblows root (hd0,2) # /dev/hda3 makeactive chainloader+1
 * 1) GRUB default values
 * 1) Grub for Linux section 0
 * 1) Kernel and parameters to pass to the kernel
 * 1) Grub for DOS/Windows section

GRUB Resources
* GRUB Manual * GRUB homepage * Grub wiki * Linux+Win+Grub HowTo * Linux Recovery and Boot Disk Creation with Grub. * Win32 Grub * Booting with GRUB * WinGRUB * GRUB Installer for Windows * GRUB for DOS - Bridging DOS/Windows to Unix/Linux

Exercises

 * Exercises results

1) Install Grub on a floppy disk and try to boot your image manually:

mkfs -t ext2 /dev/fd0 mount /dev/fd0 /mnt mkdir -p /mnt/boot/grub cp /boot/grub/stage* /mnt/boot/grub/ cp /boot/grub/e2fs-stage1_5 /mnt/boot/grub/ touch /mnt/boot/grub umount /mnt grub root (fd0) setup (fd0) quit

Now reboot with the floppy and from the prompt select the kernel on the hard disk.

root (hd0,1) kernel /boot/vmlinuz root=/dev/hda2 read-only initrd /boot/initrd boot

2) Create /boot/grub/menu.lst file and install Grub on your hard drive with the grub utility.

3) Install back lilo. Change the linux label of the default kernel image to SuSE in /etc/lilo.conf and re-install the lilo program in the MBR.