LFCS Admin Exam preparation guide – Install, configure and troubleshoot bootloaders

LFCS Admin Exam preparation guide – Install, configure and troubleshoot bootloaders

LFCS Admin Exam preparation guide series, main page can be found here.

This post is part of the Operation of Running Systems from the domain competency list for the exam. The full list can be found in the link above paragraph or the Linux Foundation page here.

Let us start what is bootloader – is a small program that helps to bridge the gap between firmware and the Linux operating system, there few bootloaders to choose from, but most popular are GRUB Legacy and GRUB2.

GRUB Legacy configuration

The GRUB Legacy storing the configuration in a standard text file, called menu.lst, and is stored inside /boot/grub folder. CentOS and Fedora using grub.conf file instead. The configuration file contains two sections – Global definition and OS boot definition.

Global definition contains commands that control the overall operation of the GRUB boot menu. There are only few settings we can control as in the table below:

colorThe foreground and background color to use in the boot menu
defaultDefault menu option to select
fallbackSecondary menu if the default fails
hiddenmenuThe menu which is hidden from selection
splashimageThe image file pointer to use for background
timeoutSpecifies the time to wait before the menu selections go to the default
GRUB Legacy global commands

After the global definition we place the definition for OS we want to boot into. We can specify more than one OS installed on our machine. There is a lot of definition we can specify for bootloader to find which OS we want to use, the most important are listed in table below.

titleThe title of the OS we want to list in boot menu
rootDefines the disk/partition where GRUB /boot folder is located (hddrive, partition)
kernelDefines the kernel image store in /boot folder to load
intrdInitial RAm disk file with drivers necessary for kernel
rootnoverifynon-Linux boot partition, example Windows
OS Boot definition example

After we write the GRUB configuration file we need to install it to MBR, the command for that is grub-install, this command accept only single parameter which partition where to install GRUB. We can write disk information the Linux or GRUB format:

Linux – grub-install /dev/sda

GRUB Legacy – grub-install ‘(hd0)’

To install another OS we want to show in our GRUB menu we have to run the same command and specify partition instead of MBR

Linux – grub-install /dev/sd1

GRUB Legacy – install-grub ‘hd(0,0)’

After we modify the configuration we will see our new menu with the options we defined. The default boot option will be process after the time-out pass. We can as well modify GRUB menu on the fly during the boot, we can select the option we want to modify and press “e” key. Press “b” key to boot with the new values.

GRUB Legacy example


GRUB2 was introduce as improvement to GRUB Legacy therefor many features are the same, with small changes. GRUB2 stores configuration in grub.cfg file inside /boot/grub folder, that’s mean we can have both installed

on our Linux box.

The structure of the file looks different :

menuentry “CentOS Linux” {
set root=(hd1,1)
linux /boot/vmlinuz
initrd /initrd
menuentry“Windows” {
set root=(hd0,1)

GRUB2 changes how we present the partition information, we still use 0 to represent the first hard drive but the first partition is set to 1 set root=hd(0,1). The configuration file contains in /boot/grub/grub.cfg should not be modified, instead, we should use separate file store in /etc/grub.d folder. We can create different files for each boot option installed on our system, for example, one for Linux and one for Windows. Global commands should be saved in the /etc/default/grub configuration file.

We don’t need to install GRUB2, and we can just simply use the grub-mkconfig program to modify our configuration. This program reads the files stored in the /etc/grub.d folder and combine them into one grub.cfg configuration file.

GRUB menu example.

On of the biggest issues with booting to our machine can happen if we upgrade the Linux kernel. Before we decide to upgrade is good idea to create additional entry in GRUB menu to point to new kernel. By doing this we can select which kernel we want to boot, if new kernel fails we can select the old one. Linux create this entries automatically when adding new kernel.

When we need to perform any maintenance on our machine we can do this directly form our GRUB menu by selecting our boot option pressing “E” and adding runlevel 1. That will allow as to boot into single user mode and we can modify the appropriate modules, init scripts to fix our Linux and boot correctly.

Thank you for reading. Keep learning!