Operating systems / How booting works (BIOS, UEFI)

How booting works (BIOS, UEFI)

From the press of the power button to the login screen: how a computer with blank memory finds, loads and starts its own operating system, one small program at a time.

Beginner7 steps~7 min
Firmware — BIOS or UEFI, in a chip on the board
Bootloader — small program that loads the kernel
Kernel — the core of the operating system
CPU — runs one of them at a time
// THE SHORT VERSION

In 30 seconds

A computer starts with empty memory, so it boots in stages, each one loading the next.

First comes firmware stored in a chip on the motherboard (BIOS on older machines, UEFI today). It tests the hardware, then looks through its boot order for a bootloader.

The bootloader loads the kernel, the core of the operating system, which starts everything else.

UEFI can also verify digital signatures at each handover. That is Secure Boot: code that has been tampered with is refused.

How booting works (BIOS, UEFI), step by step

STEPS01 / 07

Simplified: real systems add stages (an early RAM disk, a signed “shim” on many Linux installs), and the details differ on phones and Macs. The outline is the same.

STEP 01 / 07 Power on: firmware first
THE MATH
power on CPU starts at a fixed address that address is in firmware
  1. Step 1: Power on: firmware first. When power arrives, RAM is blank and the operating system is still just files on a disk. So the processor is built to begin at one fixed address, the reset vector, which leads into a chip on the motherboard that keeps its contents without power. The program stored there is the firmware: BIOS or UEFI.
  2. Step 2: Self-test (POST). The firmware first checks that the machine is fit to start: it sets up the processor, finds and tests the memory, and wakes the graphics, keyboard and storage. This is the power-on self-test. If something vital fails, the boot stops here, often with a pattern of beeps or a blinking light.
  3. Step 3: Find a boot device. The firmware cannot start an operating system itself. It keeps a boot order, a list of places to look for a small starter program called the bootloader, and tries them in turn. Here no USB stick is plugged in, so it moves on to the internal disk and finds one.
  4. Step 4: Run the bootloader. The firmware copies the bootloader into RAM and jumps to it, so the processor is now running code that came from the disk. GRUB on Linux and Windows Boot Manager are bootloaders. A bootloader knows how to read the disk’s file system and may show a menu of systems to start.
  5. Step 5: Load the kernel. The bootloader finds the kernel, the core of the operating system, copies it into RAM and jumps to it. The kernel takes over the hardware through its drivers, opens the main file system and starts the first process. That process starts everything else, ending at the login screen.
  6. Step 6: BIOS vs UEFI. The two kinds of firmware find the bootloader differently. BIOS, from the 1981 IBM PC, blindly runs the first 512-byte sector of the disk. UEFI, its replacement on modern PCs, understands partitions and files: it loads a bootloader file from a small dedicated partition, handles far larger disks and can check signatures.
  7. Step 7: Secure Boot. With Secure Boot switched on, UEFI firmware holds a list of trusted public keys. Before running a bootloader it checks the file’s digital signature against them, and the bootloader checks the kernel in the same way. Code that has been altered, say by malware that wants to start before the system, fails the check and is not run.
VALUES SO FAR
stage 1firmwarechip
POST····test
boot dev····found
stage 2····from disk
stage 3····from disk
PID 1····started
BIOS····legacy
UEFI····modern
Secure····check
// BEFORE

Learn this first

Nothing. This concept starts from scratch.

Spotted a mistake on this page?