Skip to main content

Understanding Boot Process

1. Understanding BIOS vs UEFI Boot Sequence

Aspect BIOS UEFI
Boot Mode Legacy BIOS mode Unified Extensible Firmware Interface
Firmware Interface Basic Input/Output System Modern firmware interface with graphical UI
Boot Process Starts from 512-byte MBR (Master Boot Record) Starts from GPT (GUID Partition Table) or MBR
Bootloader Location MBR or VBR (Volume Boot Record) EFI System Partition (ESP) with .efi files
Boot Speed Slower due to limited capabilities Faster boot times with optimized processes
Security Features Basic security features (e.g., password protection) NEW Secure Boot, Platform Key (PK), and Signature Verification
Partition Table Uses MBR, supports up to 4 primary partitions Uses GPT, supports more than 128 partitions
Memory Access Limited to 1MB addressable memory Supports more than 4GB of memory access
File System Support Supports only FAT12/FAT16 Supports multiple file systems including NTFS, exFAT, HFS+, etc.
User Interface Text-based interface Graphical user interface (GUI)

Example: UEFI Boot Process Overview


# UEFI Boot Process Steps:
1. Power-on self-test (POST)
2. Load EFI firmware from flash memory
3. Initialize hardware components
4. Load UEFI applications (e.g., boot managers)
5. Execute EFI application to load OS
Note: UEFI provides enhanced security features like Secure Boot, which prevents unauthorized code from running during the boot process.

2. Understanding GRUB Bootloader

Component Description Notes
GRUB Grand Unified Bootloader Primary bootloader for Linux systems
Configuration File /etc/default/grub Global GRUB settings
Generated File /boot/grub/grub.cfg Processed configuration used at boot
Boot Menu Timeout GRUB_TIMEOUT=5 Seconds to wait before default OS boot
Default OS GRUB_DEFAULT=saved Boot entry to select by default
Console Output GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" Kernel parameters for boot

Example: GRUB Configuration

# /etc/default/grub
GRUB_DEFAULT=0
GRUB_TIMEOUT=10
GRUB_TIMEOUT_STYLE=menu
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_DISABLE_SUBMENU=true

Example: Update GRUB Configuration

# Regenerate grub.cfg from /etc/default/grub
sudo update-grub
Note: Changes to /etc/default/grub require running update-grub to regenerate the actual boot configuration file.

GRUB Bootloader Overview

  • Loads the kernel and initial ramdisk (initrd)
  • Supports multiple operating systems
  • Can be configured via /etc/default/grub
  • Configuration is processed into /boot/grub/grub.cfg

3. Configuring GRUB Settings

Setting Description Default Value Notes
GRUB_TIMEOUT Timeout in seconds before booting the default entry 5 Set to 0 for immediate boot
GRUB_DEFAULT Default boot entry (0-based index) 0 Use saved to use last selected entry
GRUB_CMDLINE_LINUX Kernel command-line parameters Append options like quiet splash
GRUB_DISABLE_OS_PROBER Disable OS detection during update false Set to true to skip other OS detection
GRUB_TIMEOUT_STYLE Style of timeout display menu Can be hidden or menu

Example: Modifying GRUB_TIMEOUT

# Edit /etc/default/grub
sudo nano /etc/default/grub

# Change the line:
GRUB_TIMEOUT=10

# Update GRUB configuration
sudo update-grub
Note: Changes to /etc/default/grub require running update-grub to apply them.
Warning: Incorrect GRUB_DEFAULT values can cause boot failures. Ensure the index matches an existing entry.

4. Accessing GRUB Menu

GRUB (Grand Unified Bootloader) is the bootloader responsible for loading the operating system. Accessing the GRUB menu allows users to select different kernels, boot options, or recovery modes.

Method Description Notes
Press and Hold Shift During boot, hold the Shift key to access the GRUB menu. Works for UEFI systems. On some systems, Esc or Space may be used instead.
Press and Hold Esc Some systems (especially older BIOS-based) require pressing Esc. Not supported on all systems. May be overridden by UEFI firmware.
Boot Delay Configuration Modify /etc/default/grub to set a longer boot delay. Add or modify GRUB_TIMEOUT=10 to delay boot by 10 seconds.

Example: Modifying GRUB Timeout

# Edit the GRUB configuration file
sudo nano /etc/default/grub

# Modify or add the line:
GRUB_TIMEOUT=10

# Update GRUB after changes
sudo update-grub
Note: The update-grub command regenerates the GRUB configuration file based on the contents of /etc/default/grub and available boot entries.
Warning: Incorrectly modifying the GRUB configuration can prevent your system from booting. Always backup /etc/default/grub before making changes.

5. Booting into Single-User Mode

Mode Description Use Case
single-user mode Bootstraps the system with minimal services and no network access System recovery, password reset, or troubleshooting

Example: Booting into Single-User Mode

# From GRUB menu, select "Advanced options"
# Choose the recovery mode entry
# Or edit kernel parameters to add: init=/bin/bash
Note: In single-user mode, root privileges are granted without requiring a password. Ensure physical access is controlled.

6. Understanding systemd Boot Targets

Target Description Default Services
poweroff.target Halts the system and powers it off Shutdown services
reboot.target Reboots the system Shutdown and reboot services
rescue.target Enters rescue mode for system recovery Rescue shell, filesystem checks
emergency.target Enters emergency mode for troubleshooting Emergency shell, minimal services
multi-user.target Multi-user text mode (default for servers) Network, logging, cron services
graphical.target Graphical desktop environment (GUI) Display manager, desktop services

Example: Check current boot target

systemctl get-default

Example: Change boot target to graphical

sudo systemctl set-default graphical.target
Note: The graphical.target requires a display manager like GDM or LightDM to be installed and running.

7. Setting Default Boot Target

Target Description Command
multi-user.target Multi-user text mode, no graphical interface sudo systemctl default-target multi-user.target
graphical.target Graphical desktop environment (GUI) sudo systemctl default-target graphical.target

Example: Change default boot target to graphical mode

sudo systemctl default-target graphical.target
Note: The graphical.target usually implies the use of a display manager like GDM, SDDM, or LightDM.

8. Viewing Boot Messages

Command Description Notes
dmesg Display kernel ring buffer messages Shows hardware and driver initialization messages
journalctl Query the systemd journal Can filter by boot, service, or time range
journalctl -b View logs from current boot Useful for debugging boot issues
journalctl -b -1 View logs from previous boot Helpful for comparing boot states
tail /var/log/boot.log View boot log file May not exist on all systems; depends on init system

Example: View boot messages with dmesg

dmesg | grep -i error
dmesg | tail -20

Example: Use journalctl to view boot logs

journalctl -b --no-pager
journalctl -b -u nginx.service

9. Repairing GRUB

Example: Boot into Live USB and Repair GRUB

# Mount the root filesystem of the installed OS
sudo mount /dev/sda1 /mnt

# Bind mount necessary filesystems
sudo mount --bind /dev /mnt/dev
sudo mount --bind /proc /mnt/proc
sudo mount --bind /sys /mnt/sys

# Chroot into the installed system
sudo chroot /mnt

# Reinstall GRUB
grub-install /dev/sda
grub-mkconfig -o /boot/grub/grub.cfg

# Exit chroot and reboot
exit
sudo reboot
Command Description Notes
grub-install Installs GRUB bootloader to a specified device Use with caution, can overwrite existing bootloaders
grub-mkconfig Generates GRUB configuration file from available kernels and modules Typically run after kernel updates or hardware changes
grub-reboot Reboots into a specific GRUB entry on next boot Useful for troubleshooting or testing different kernels
Note: Ensure the correct device path is used when running grub-install. Incorrect paths can lead to unbootable systems.
Warning: Running grub-install on a device that already has a bootloader can overwrite it, potentially causing system boot issues.

10. Using Emergency Mode

Emergency mode in Linux provides a minimal environment for troubleshooting system issues. It is useful when the normal boot process fails or when system files are corrupted.

Mode Description Use Case
emergency Single-user mode with minimal services and no network System recovery, password reset, file system repair
rescue Single-user mode with full root filesystem mounted Advanced troubleshooting, system recovery

Example: Booting into Emergency Mode

sudo systemctl rescue

Example: Using GRUB to Enter Emergency Mode

grub> linux /vmlinuz-$(uname -r) single
grub> boot
Note: Emergency mode is not a full system recovery environment but rather a minimal shell for diagnostics and repairs.

Was this article helpful?