Skip to content
Tutorials Center
My learning

Topics

Lesson 4 of 66 ยท Getting Started

How a Computer Boots

Follow the boot process step by step: power-on, firmware (BIOS or UEFI), POST, the bootloader, kernel start-up and the first user process. Includes a boot simulator.

When you press the power button, there is no operating system in memory. RAM is empty, and the OS lives on a disk or SSD. So how does the machine get from "nothing" to a login screen? The answer is a chain of small programs, each one loading a bigger one. This is called bootstrapping, or simply booting (from "pulling yourself up by your bootstraps").

In this lesson you will follow the chain from the power button to the first user process, learn the difference between BIOS and UEFI, and run a boot-sequence simulator that stops with a clear error if any link breaks.

The boot chain

Power on CPU starts at a fixed address.
Firmware BIOS or UEFI runs self-tests.
Bootloader Finds and loads the kernel.
Kernel Sets up memory, drivers, init.

Each stage is small and loads the next, larger stage.

1 / 2

Step 1: power on and the firmware

When power stabilizes, the CPU resets and begins executing at a hard-wired address. That address maps to a chip holding firmware: software stored in non-volatile flash memory on the motherboard.

Two firmware families exist:

  • BIOS (Basic Input/Output System): the classic design from the 1980s. It runs in a limited 16-bit mode, reads the first 512-byte sector of the boot disk (the MBR, Master Boot Record) and jumps to the code in it.
  • UEFI (Unified Extensible Firmware Interface): the modern replacement. It understands file systems, reads a boot program (an .efi file) from a special EFI System Partition, supports disks larger than 2 TB through GPT partition tables, and offers Secure Boot, which checks digital signatures so only trusted bootloaders run.

Step 2: POST

Before anything else, the firmware runs the POST (Power-On Self-Test). It checks the CPU, memory and basic devices. If something is wrong you hear beep codes or see an error. Only after POST does the firmware initialize hardware and look for a boot device in the configured order (disk, USB, network).

Step 3: the bootloader

The firmware cannot be expected to know every operating system. It only knows how to start a bootloader: a small program such as GRUB (Linux), the Windows Boot Manager or Apple's boot.efi. The bootloader's jobs are to:

  1. show a menu if several systems are installed (dual boot),
  2. find the kernel image on disk and load it into memory,
  3. load an initial RAM disk (initramfs) with the drivers needed to reach the real root file system,
  4. pass boot parameters (such as which partition is the root) to the kernel and jump to it.

Older BIOS systems used a two-stage trick: the 512-byte MBR code was too small to understand a file system, so it loaded a bigger second-stage loader from disk.

Step 4: the kernel takes over

The kernel decompresses itself, switches the CPU into the right mode, and initializes the core pieces: the memory manager (it builds the page tables), the scheduler, interrupt handlers and the drivers for detected hardware. It then mounts the root file system and starts the very first user-space process.

Step 5: the first process and services

On Linux the first process is init (usually systemd) and always has process ID 1. Every other process descends from it, forming the process tree you will meet in process creation. It starts services (network, logging, display manager) and finally presents a login prompt. On Windows the analogous steps launch smss.exe, wininit.exe and the login screen.

Simulating the boot chain

The simulator below models each stage as a function that returns the next one. You can break a stage by changing a flag in the machine dictionary and watch the boot stop with the same kind of message real machines give.

Python Boot sequence simulator

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Try setting root_fs_mountable to False or changing "firmware" to "BIOS" and run again.

Boot time process list

The tree below is what you would see a few seconds after boot on a typical Linux system (simplified). The kernel starts PID 1, and everything else is its descendant.

Python A process tree after boot

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Dual boot, recovery and secure boot

A dual-boot machine has a bootloader that offers a choice of operating systems on different partitions. A recovery mode boots a minimal system to repair the main one. Secure Boot checks each stage's signature against keys stored in the firmware, which blocks bootkits (malware that hides in the boot chain), though it can also block homemade kernels unless you add your own keys.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What is the correct order of the boot stages?

    Firmware runs first, then loads the bootloader, which loads the kernel, which starts the first user process (init).
  2. 2. What is a key difference between BIOS and UEFI?

    UEFI is the modern firmware with file system support, GPT and signature checks; BIOS reads a 512-byte MBR.
  3. 3. Why does the bootloader exist as a separate stage?

    The firmware only knows how to start a bootloader, and the bootloader knows how to load a particular kernel.
  4. 4. What process ID does the first user-space process (init/systemd) get on Linux?

    Init is always PID 1, and every other process descends from it.

Summary

  • Booting is a chain: firmware, POST, bootloader, kernel, first process, services, login.
  • BIOS reads the MBR; UEFI loads .efi programs from the EFI System Partition and supports GPT and Secure Boot.
  • The bootloader loads the kernel (and an initramfs) and passes boot parameters.
  • The kernel initializes memory, scheduling, interrupts and drivers, then starts PID 1.
  • A failure in any stage stops the chain, which is why error messages tell you which stage failed.

Next: OS Structure: Monolithic, Layered and Microkernel