Boot Sequences

The boot sequences at Grub level is slightly different depending on its boot executables (UEFI vs. Legacy) and the grub configurations (multiboot or chain-loading). We will go through the process flow from hardware to operating system as we scroll down.

Hardware BIOS/Firmware Initialization

BIOS stands for Basic Input/Output System. It initializes the devices on a computer system at hardware levels, preparing for usage. BIOS is always vendor specific, especially towards the CPU model. Hence, you can't (or in case, you don't need) to customize BIOS codes unless you're tinkering into the hardware component of the CPU, which is highly restricted to the CPU vendor.

Some CPU like ARM does not have BIOS. In those cases, they are initialized using different mechanism (on-board chips) or local firmware. Similar to BIOS, you might not be able to tinker the firmware for a compute module design, all at the mercy of the vendor. If the vendor open-source the firmware, then you got a chance to modify yours accordingly.

To keep thing simple, BIOS is a kind of firmware for computer. To avoid confusion between CPU architectures, we will call both firmware as hardware initialization module (HIM) moving forward.


Power Up

At this stage, the hardware initializes its hardware components from power-up or restart. At this point, user can adjust the HIM configurations in its configuration menu (e.g. BIOS menu / firmware menu) and then restart initialization again. There are some critical settings related to boot:

  1. Boot Mode (UEFI or Legacy or Both) - instructs HIM to initialize for specific types of boot mode. Some BIOS can perform both UEFI and legacy modes with Boot Mode Priority.
  2. Boot Mode Priority (UEFI first or Legacy first) - only available for HIM that is capable to seek UEFI and Legacy modes simultaneously. This option is for speeding up the device scanning and boot sequences.
  3. Fast Boot - available for skipping initialization components in exchange for faster boot speed.
  4. Secure Boot - available for secured hardware to software booting protection. All layers (hardware, bootloader, and OS) must be able to support this options in order to make thing works. Secure Boot is specific to machine for obvious security reason.
  5. Boot Order - instructing HIM to seek 1st bootable device based on the given list.


Release

Upon completion, it seeks the first bootable device either from its listed boot order OR prompted user input (some HIM offers hot-key to user to boot into specific devices on the fly).

If HIM fails to find any bootable device, it leaves an on screen message stating user to shutdown or insert a bootable device.

First Boot-loader

This is where GRUB comes in. Upon detected grub in the 1st bootable device, it seeks GRUB executable at a standard path depending the boot mode.


Grub Path

Currently, the known paths are, depending on boot mode:

  • Legacy - /boot/grub/
  • UEFI - /EFI/<vendor>/


Grub Configurations

There should always be a grub.cfg in the grub path, regardless of boot mode. This file holds the instructions for grub to perform loading. Currently, Grub supports multi-boot, chain-boot, and loopback-boot modes defined in the grub configurations. We will go through them individually in the sub-sections.