OS Booting Process Tutorial
Introduction
The booting process is how a computer starts up and loads its operating system. It involves several steps, from powering on the hardware to running the OS kernel. Understanding this process is fundamental for anyone interested in operating systems, firmware, or low-level programming.
1. Power-On and Firmware Initialization
- When you power on a computer, the CPU starts executing code from a fixed location in ROM (Read-Only Memory).
- This code is the firmware, which can be either BIOS (Basic Input/Output System) or UEFI (Unified Extensible Firmware Interface).
- The firmware performs a Power-On Self Test (POST) to check hardware integrity (RAM, CPU, storage, etc.).
2. BIOS vs UEFI
- BIOS is the legacy firmware interface, using 16-bit real mode and the Master Boot Record (MBR) partitioning scheme.
- UEFI is the modern replacement, supporting 32/64-bit mode, graphical interfaces, secure boot, and the GUID Partition Table (GPT).
- UEFI can boot from larger disks and supports more advanced features.
3. Bootloader and Disk Partitioning
- After POST, the firmware looks for a bootable device (HDD, SSD, USB, etc.).
- With BIOS/MBR, the first 512 bytes of the disk (the MBR) contain the bootloader code.
- With UEFI/GPT, the firmware loads a bootloader (like GRUB, Windows Boot Manager) from the EFI System Partition.
- The bootloader's job is to load the OS kernel into memory.
4. Loading the Kernel
- The bootloader locates the OS kernel (e.g.,
vmlinuzfor Linux,ntoskrnl.exefor Windows) and loads it into RAM. - It may also load an initial RAM disk (initrd/initramfs) for drivers and setup.
- Control is then transferred to the kernel.
5. Kernel Initialization
- The kernel initializes hardware, mounts the root filesystem, and starts system processes.
- For Linux, the first process is usually
initorsystemd. - The OS is now running and ready for user interaction.
6. Troubleshooting Boot Issues
- Common problems: missing bootloader, corrupted MBR/GPT, misconfigured BIOS/UEFI settings, hardware failures.
- Tools: BIOS/UEFI setup utility, boot repair disks, recovery environments.
References
Summary Table
| Step | BIOS/MBR | UEFI/GPT |
|---|---|---|
| Firmware | BIOS | UEFI |
| Partition Scheme | MBR | GPT |
| Bootloader Location | MBR (first 512 bytes) | EFI System Partition |
| Kernel Loading | Bootloader loads kernel | Bootloader loads kernel |
| Max Disk Size | ~2TB | >9ZB |
Diagram
[Power On] → [BIOS/UEFI] → [Bootloader] → [Kernel] → [Init/Systemd] → [User Space]
Further Reading
- Explore the source code of GRUB or Syslinux for bootloader internals.
- Try building a simple bootloader in assembly or C.
- Experiment with UEFI shell and Secure Boot settings.