The start-up problem
The operating system is on the drive, and memory is empty
At power-on, memory is empty. Firmware, a small program in a chip on the board, runs first.
Press the power button. What runs? The processor can only run what is in memory. But memory was cleared when the power went off. It is empty. The operating system is on the drive, as files, and nothing is running that could read them. The way out is a small program kept in a chip on the motherboard: the firmware. It is always there, and the processor is built to start with it.
The start-up sequence
Four programs run in turn, and each loads the next
Firmware, then the bootloader, then the kernel, then services.
Between the power button and the sign-in screen, four programs run, one after another. Firmware runs first. On this laptop it takes four point two seconds to test the hardware and find a drive. The bootloader takes one point three seconds to find the kernel and load it. The kernel takes two point one seconds to take over the hardware. Services take the longest, six point nine seconds, and end at the sign-in screen.
Firmware
Firmware tests the hardware, then looks for a drive to start from
The self test checks the parts. The boot order decides which drive is tried first.
Firmware is the program stored on the motherboard itself. It is called UEFI, and on older machines BIOS. First it tests the hardware: processor, memory, graphics and drives. Then it walks its boot order. The first entry is a USB drive, and nothing is plugged in. The second is the SSD, which holds a bootloader, so firmware starts it and never reaches the third.
Firmware · Going deeper
BIOS and UEFI
UEFI uses GPT drives and supports Secure Boot. BIOS uses MBR and stops at 2.2 TB.
Bootloader and kernel
The bootloader finds the kernel and hands over
The bootloader sits in the EFI System Partition and loads the kernel into memory.
This is a five hundred and twelve gigabyte drive, drawn to scale. The hairline at the left is the EFI System Partition: a hundred megabytes, holding the bootloader. The firmware starts it from there. The bootloader reads its settings, and offers a menu if more than one system is installed. Then it copies the kernel into memory and gives it control.
Services
One process starts everything else
The kernel starts process 1. Process 1 starts every service, in dependency order.
The kernel does not start your programs. It starts exactly one process, and that process starts all the rest. First come the services everything depends on: file systems, device drivers and logging, started together. Then the ones that need those, such as the network. Last comes the sign-in screen, and the machine is ready.
Services · Going deeper
Sleep, hibernate, shut down and restart
Only Restart reloads everything. Windows Shut down keeps the kernel.
Trust at start-up
Whatever starts first controls everything after it
Each stage runs what the one before hands it, so a tampered early stage cannot be seen by later ones.
Why would anyone attack the start-up? Because it is a chain. Firmware starts the bootloader, the bootloader starts the kernel, and security software starts near the end. Now suppose malware replaces the bootloader. It loads the kernel it chooses. By the time security software starts, it is running on top of something it cannot see.
Trust at start-up · Going deeper
Secure Boot: each stage checks the next before running it
Every stage carries a signature. A stage that fails the check is never run.
Secure Boot protects the start-up sequence from tampering. The firmware holds a set of trusted keys, and checks the bootloader's signature before running it. The bootloader checks the kernel. The kernel checks its drivers. If anything has been altered, the signature no longer matches. The firmware refuses to run it, and nothing after it starts.
Start-up failures
How far it got tells you what failed
Read the symptom, name the stage, and the suspects follow.
A machine that will not start still tells you how far it got. Nothing at all: the fault is power. Fans but no picture, perhaps beeps: the self test failed, usually on memory. A message that no bootable device was found: firmware works, but found no drive. A bootloader error: the drive was found, and its boot files are damaged. A blue screen or kernel panic: the kernel started, then hit a bad driver. And a hang at the spinner means a service.
Start-up failures · Going deeper
The recovery tools
From Startup Repair to Reset this PC: least disruptive first.
Lesson complete
You finished “How a computer starts”
Nicely done.