Skybinary

View Categories

1.1.2 Linux Boot Process Explained (BIOS vs. UEFI, GRUB2, and Commands)

1 min read

1.1.2 Linux Boot Process Explained (BIOS vs. UEFI, GRUB2, and Commands) #

The Linux boot process is a structured sequence that loads the operating system into memory. Below is a detailed breakdown of the key components, including BIOS/UEFI, GRUB2, boot files, and essential commands.


1. Firmware Initialization: BIOS vs. UEFI #

1) Basic Input/Output System (BIOS)

  • Legacy firmware (older systems).
  • Process:
    1. POST (Power-On Self-Test) → Checks hardware.
    2. Loads MBR (Master Boot Record) → First 512 bytes of the boot disk.
    3. Starts the bootloader (e.g., GRUB2).
  • Limitations:
    • No secure boot.
    • Limited to MBR partitioning (max 2TB disks).

2) Unified Extensible Firmware Interface (UEFI)

  • Modern replacement for BIOS.
  • Process:
    1. Runs POST.
    2. Looks for an EFI System Partition (ESP) (/boot/efi).
    3. Loads bootloader (e.g., GRUB2) from ESP.
  • Advantages:
    • Supports Secure Boot (prevents malware).
    • GPT partitioning (>2TB disks).
    • Faster boot times.

2. Bootloader: GRUB2 (Grand Unified Bootloader 2) #

  • Default bootloader for most Linux distros.
  • Config File: /boot/grub2/grub.cfg (auto-generated).
  • Key Files:
    • vmlinuz → Compressed Linux kernel.
    • initrd.img or initramfs → Temporary root filesystem (loads drivers before real root is mounted).

GRUB2 Commands #

CommandPurpose
grub2-installInstalls GRUB2 to a disk (/dev/sda).
grub2-mkconfigGenerates a new grub.cfg file.
grub2-updateUpdates GRUB2 (some distros alias this to update-grub).
mkinitrdCreates an initrd (initial RAM disk).
dracutModern alternative to mkinitrd (used in RHEL/Fedora).

3. Kernel & Initramfs Loading #

  1. GRUB2 loads vmlinuz (Linux kernel).
  2. initrd.img or initramfs is loaded → Contains drivers/modules needed to mount the real root (/).
  3. Kernel initializes hardware and switches to the real root filesystem.

4. Boot Sources #

a) Preboot eXecution Environment (PXE) #

  • Network booting (used in servers/data centers).
  • Requires:
    • DHCP server (assigns IP).
    • TFTP server (serves boot files).

b) Booting from USB #

  • Requires a bootable USB (created with dd or tools like Rufus).
  • Example:bashCopyDownloaddd if=ubuntu.iso of=/dev/sdX bs=4M status=progress

c) Booting from ISO (Directly Mounted) #

  • Some UEFI systems allow booting directly from ISO files (without USB).

5. System Initialization (systemd / SysVinit) #

After the kernel loads:

  • systemd (modern init system, PID 1) takes over.
  • Targets (runlevels) determine what services start:
    • multi-user.target → CLI mode.
    • graphical.target → GUI mode.

Summary: Linux Boot Process Flow #

  1. Firmware (BIOS/UEFI) → POST → Finds boot device.
  2. Bootloader (GRUB2) → Loads vmlinuz + initramfs.
  3. Kernel → Initializes hardware, mounts root (/).
  4. Init system (systemd) → Starts services, reaches target.

Key Troubleshooting Commands #

  • Fix GRUB2:bashCopyDownloadgrub2-install /dev/sdX # Reinstall GRUB grub2-mkconfig -o /boot/grub2/grub.cfg # Regenerate config
  • Rebuild initramfs:bashCopyDownloaddracut -fv # For RHEL/Fedora mkinitrd # For Debian/Ubuntu (older)

Final Notes #

  • UEFI + GPT is the modern standard (faster, more secure).
  • GRUB2 is highly configurable (edit /etc/default/grub before running grub2-mkconfig).
  • initramfs is critical for loading drivers (e.g., encrypted LVM, RAID).

Powered by BetterDocs

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top