Ict-innovation/LPI/102.2

= 102.2 Install a boot manager = Candidates should be able to select, install and configure a boot manager.

Key Knowledge Areas


 * 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.

Introduction
A boot loader is installed in the MBR. 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.

As explained under the boot processes above, there are two stages to a boot loader. The first stage and second stage. The first stage is the boot sector application that is responsible for loading stage2.

Grub Boot Loader
Grub understands Linux filesystems and instead of using raw sectors to locate the Linux kernel GRUB can load from an ext2 or ext3 filesystems. GRUB is also capable of directly loading several non Linux operating systems. The GRUB boot loader has a three stages. Stage 1 has the usual job of a primary boot loader but it loads stage 1.5 which is a boot loader which understand a particular file system such as ext2/3, reiserfs etc and once loaded it loads the 2nd boot loader. The 1.5 stage boot loader is located on the first 30 kilobytes of hard disk immediately after the MBR.

Grub can be installed, either by editing the grub configuration file located at /boot/grub/grub.conf or /boot/grub/menu.lst and running grub-install or by invoking the grub shell. When referring to hard disks and partition grub uses the convention (hdx) for hard disks, irrespective of whether they are PATA or SATA disks, and (fdx) for floppy disks, where x refers to the disk number as seen by the BIOS. When a reference to a partition is need the conventions (hdx,n) or (fdx,n) is used, where n is the partition numbered from 0.

A sample of a grub configuration file is given below:

default=0 timeout=10 splashimage=(hd0,0)/grub/splash.xpm.gz title Linux (2.4.18-14) root (hd0,0) kernel /vmlinuz-2.4.18-14 ro root=/dev/hda5 initrd /initrd-2.4.18-14.img

The main sections of the grub.conf/menu.lst file are:

default
 * image that will boot by default (the first entry is 0)

timeout
 * prompt timeout in seconds

title
 * name of the image

root
 * where the 2nd stage bootloader and kernel are e.g (hd0,0) is /dev/hda1

kernel
 * path for the kernel starting from the previous root e.g /vmlinuz

ro
 * read-only

root
 * the filesystem root

initrd
 * path to the initial root disk

To install the first stage MBR loader on /dev/hda with grub-install you would run the command grub-install (hd0). Alternatively grub can be installed through the grub shell but still requires the grub.conf/menu.lst file. The grub shell can be entered by typing 'grub. 'To install the boot loader you need to run the following commands in the shell:

root (hd0,0)

setup (hd0)

The first line tells grub that the /boot partition, where the configuration file is located,is on the first hard disk on partition 1, and the 2nd command tells grub to install the 1st boot loader to the MBR of the first hard disk. An advanatge of Grub is that each time the grub configuration file is updated with an new image for example, grub does not have to be reinstalled as with LILO.

GRUB 2

GRUB 2 is the next generation, a rewrite of what was formerly known as GRUB (i.e. Ver 0.9x), which has, in turn, become GRUB Legacy. GRUB Legacy is no longer being developed. GRUB 2 shares many characteristics with GRUB Legacy, but it also introduces many new changes, this includes better portability, memory management and modularity, supports non-ASCII characters, dynamic loading of modules, and more. There is three locations

The main configuration file has a new name, /boot/grub/grub.cfg, unlike menu.lst, this file can not be edited directly, typically the file is automatically generated by grub-mkconfig command or via update-grub command, which both read scripts located in the /etc/grub.d/ to build grub.cfg file.

Here the numbering in the script names defines precedence in the order of execution by the command grub-update or grub-mkconfig.

Let's review the scripts:


 * 00_header – is the script that loads GRUB settings from /etc/default/grub, including timeout and default boot entry.
 * 05_debian_theme – defines the background, colors and themes.
 * 10_linux – loads the menu entries for installed operating systems.
 * 20_memtest86+ loads the memtest utility.
 * 30_os-prober – is the script that will probe hard disks for other operating systems and add them to the boot menu.
 * 40_custom is a template that you can use to create additional entries to be added to the boot menu.

/etc/default/grub contains menu settings customization, such as default menu entry and boot default timeout.

New changes and features can be summarised as follows.


 * grub.cfg is the main configuration
 * scripts files located in /etc/grub.d/ are used to generete grub.cfg
 * partition numbers in GRUB device names now start at 1, not 0.
 * can read files directly from LVM and RAID devices.
 * Many facilities are dynamically loaded as modules allowing flexible built of core image.
 * Boot stages are no more, image files have been reorganised.
 * Supports more file systems, including ext4, NTFS and HFS+.
 * After adding or editing of script(s), update-grub command must be run to rebuild grub.cfg with updates.

Used files, terms and utilities:


 * /boot/grub/menu.lst, grub.cfg and other variations.
 * grub-install
 * MBR
 * superblock

Previous Chapter | Next Chapter