202.2. System Recovery

202.2 System Recovery

Weight: 4

Description: Candidates should be able to properly manipulate a Linux system during both the boot process and during recovery mode. This objective includes using both the init utility and init-related kernel options. Candidates should be able to determine the cause of errors in loading and usage of bootloaders. GRUB version 2 and GRUB Legacy are the bootloaders of interest. Both BIOS and UEFI systems are covered.

Key Knowledge Areas:

  • BIOS and UEFI

  • NVMe booting

  • GRUB version 2 and Legacy

  • grub shell

  • boot loader start and hand off to kernel

  • kernel loading

  • hardware initialisation and setup

  • daemon/service initialisation and setup

  • Know the different boot loader install locations on a hard disk or removable device.

  • Overwrite standard boot loader options and using boot loader shells.

  • Use systemd rescue and emergency modes.

Terms and Utilities:

  • mount

  • fsck

  • inittab, telinit and init with SysV init

  • The contents of /boot/, /boot/grub/ and /boot/efi/

  • EFI System Partition (ESP)

  • GRUB

  • grub-install

  • efibootmgr

  • UEFI shell

  • initrd, initramfs

  • Master boot record

  • systemctl

Boot process overview

lets take a look at boot process and stick what ever we have learned till now:

if any problems occur on any of these steps, boot process fails. It might be motherboard problems, Disk problems or boot loader problem.lets start from very beginig.

BIOS basic Input Output System vs UEFI(EFI) Unified Extensible Firmware Interface

When we start computer there should be away to wake up the kernel from sleep. But even our pour bootloader sleeps on the hard disk and has to access disk when no kernel driver is available. So there should be a hardware solution to access hard disk and starts boot loader and then bootloader wake up the kernel.

BIOS and UEFI are both interfaces for accessing disk.They sit between hardware/firmware and operating system and help computers to start. BIOS has become pretty old and UEFI has developed to retire it. UEFI has many advantages and has become default interface in modern PCs. UEFI is able to boot from large disks when we use GPT.

MBR(Master Boot Record)

on BIOS system Master boot record is read from disk. MBR is not part of any file system and considered as metadata of your hard disk.How is it working ?Master boot record holds two things, some of or all of boot loader program and the partition table. At first stage just 446 kb of disk is read, (primary boot loader/IPL) and its job is to load second stage .as 512 bytes is so small to keep whole needed files to load the kernel, In second stage a MB of disk is read, which is meta data area of disk and every thing which is needed to load kernel should be exsited here. Boot loader(grub2) located in first 30 KB of hard disk immediately after MBR. grub load kernel and inintrd from /etc/boot/grub/grub.conf and loads other modules as needed. Grub loads GUI from /grub/splash.xpm.gz and starts the system.

GPT ( GUID Partition Table)

in UEFI system, GPT partition table is used. GPT partition table contains an EFI System Partition (ESP).Inside that there is always /efi directory. /efi directory might contains one or many boot loaders. Each boot loader has its own identifier and corresponding directory. So if you are using boot linux and microsoft windows, its usual to have both /efi/grub and /efi/microsoft directories.Boot loaders in this partition has .efi extension. So as you can see UEFI/EFIgive more flexibility and you can support more than one operating system by just having an ESP partition on a hard disk. no more pain :).

GPT is backward compatible and it has MBR .It is not used. it is MBR which is GPT compatible.

MBR vs GPT

Lets compare these two:

item

mbr

gpt

Number of Supported partitions

4

128 (modifiable )

Stored in

mbr (out side of file system)

GPT partition

Partition Types

Primary, Logical, Extended

No more(Primary, logical, Extended)

Maximum Partition Size

2^64 * 512=2 T

2^64 * 512 =>hit file system limitations

Backup

no, nothing, easily damaged :(

store a backup at the end of disk

Work With

BIOS

UEFI and BIOS (Backward compatible)

Boot Loader Recovery General Notes

Recovering boot loader needs to specify three major required elements. We have already got familiar with all 3:

  1. root partion

  2. kernel and boot partition as its argument (usually same as root)

  3. initrd/initramfs

how ever some commands are different in grub version 1 and version 2.

  • Recovering Grub Legacy

grub version1 dosn't have "ls" command.Do not forget it starts counting hard disk partitions from "Zero".

after rebooting system install grub again:

  • Recovering Grub2

Grub2 is more enhanced than legacy grab and if boot problems occur, grub might left system in different states.

grub command prompt

Description

grub>

prompt

GRUB 2 loaded modules but was unable to find the grub.cfg file. = has already found root partition

grub rescue>

prompt

GRUB 2 failed to find its grub folder, or failed to load the normal module. = has not found root partition

grub>:

The grub prompt on a blank screen

GRUB 2 has found the boot information but has been either unable to locate or unable to use an existing GRUB 2 configuration file (usually grub.cfg)

grub rescue>:

the rescue mode

GRUB 2 is unable to find the grub folder or its contents are missing/corrupted. The grub folder contains the GRUB 2 menu, modules and stored environmental data.

GRUB-

a single word, with no prompt and no curser

GRUB has failed to find even the most basic information, usually contained in the MBR or boot sector.

Busybox or Initramfs

GRUB 2 began the boot process but there was a problem passing control to the operating system. Possible causes include an incorrect UUID or root= designation in the 'linux' line or a corrupted kernel.

Frozen splash screen

blinking cursor with no grub> or grub rescue prompt. Possible video issues with the kernel. While these failures are not of GRUB 2's making, it may still be able to help. GRUB 2 allows pre-boot editing of its menu and the user may restore functionality by adding and/or removing kernel options in a menuentry before booting.

each failer might need different remedies here lets take a look at the first one. Grub2 supports "ls" , "cat" command and support tab tab completion. it starts counting partitions from "One" . Strange world huuh ?

and finally do some post configuration :

and install grub:

Last updated