🧠 How Computers Boot Up
Click on any component to learn how it works in the boot process
Complete Boot Flow (Click steps for details):
-
🔌 Power On → CPU starts
CPU jumps to hardwired ROM address
-
⚙️ CPU runs BIOS/UEFI (from ROM)
Executes directly from firmware chip
-
🔍 POST: Tests hardware
Detects RAM, tests CPU, finds video
-
⚡ Initializes RAM
Configures timings, creates memory map
-
💾 Finds bootloader
Checks disks for boot signature
-
📥 Loads to RAM
First 512 bytes → address 0x7C00
-
👑 Bootloader loads kernel
Stage 2 loads OS kernel
-
🚀 Kernel runs OS
Takes over all hardware
×
What physically happens:
1. Power stabilizes on motherboard
2. CPU comes out of reset state
3. CPU loads CS:IP = F000:FFF0 (address 0xFFFFFFF0)
4. This address is hardwired to ROM chip
5. First instruction: JMP FAR F000:E05B
Reset Vector: Fixed address CPU always starts at
Real mode: CPU starts in 16-bit mode (1MB address space)
No RAM access: CPU executes from ROM before RAM is ready
Key insight: The CPU's first instruction comes from the ROM chip, not from RAM.
×
Location: Executes directly from flash memory chip on motherboard
Not in RAM: Runs before RAM is initialized
Size: Typically 8-32 MB of firmware code
First tasks: Set up minimal chipset, start Power-On Self Test
BIOS vs UEFI:
• BIOS: 16-bit, limited to 1MB, MBR disks
• UEFI: 32/64-bit, modern features, GPT disks
• Both: Execute from firmware, initialize hardware
Common misconception: BIOS does NOT copy itself to RAM to run (except optional shadowing).
×
What POST actually tests:
1. CPU: Tests registers, math unit
2. RAM Detection: Reads SPD chip on RAM sticks (size, speed, timings)
3. RAM Test: Simple pattern test (0x55, 0xAA, walking 1's)
4. Video: Finds graphics card, initializes 80x25 text mode
5. Storage: Detects disks, checks controllers
6. Other: Keyboard, mouse, beeper
Beep codes: Different patterns indicate different errors
Example: 1 long + 2 short = video card error
Modern: Most errors show on screen instead of beeps
Critical function: POST determines what hardware exists and if it works.
×
What "initialize RAM" really means:
1. Detect: Read SPD: "DDR4, 8GB, 3200MHz, CL16-18-18-36"
2. Configure: Set memory controller with correct timings
3. Train: Test signal timing (modern DDR)
4. Map: Create memory map - what addresses are RAM?
5. Reserve: Mark video RAM (0xA0000), BIOS area (0xF0000)
NOT "copy to RAM": BIOS stays in ROM, configures RAM for others
Memory map: Table showing usable vs reserved areas
Passed to OS: Map given to bootloader → kernel
Key point: BIOS prepares RAM for the OS to use, but doesn't run from it.
×
Boot device search:
1. Check boot order (USB → HDD1 → HDD2 → Network → CD/DVD)
2. For each device:
a. Read first sector (512 bytes)
b. Check bytes 510-511 = 0x55 0xAA?
c. If yes → bootable! If no → next device
3. If none found: "No bootable device" error
MBR: Master Boot Record - first sector of disk
Boot signature: 0x55 0xAA in last 2 bytes
UEFI: Looks for \EFI\BOOT\BOOTX64.EFI in FAT32 partition
Finding process: BIOS systematically checks each possible boot device.
×
BIOS loads bootloader:
1. Use BIOS interrupt INT 0x13 (disk services)
2. Read sector 0 into memory at address 0x7C00
3. Load exactly 512 bytes (MBR size)
4. Verify checks
5. Jump to 0x7C00: "Bootloader, take control!"
Address 0x7C00: Traditional location, leaves room below for data
First RAM user: Bootloader is first program that runs FROM RAM
Still 16-bit: Bootloader starts in real mode (can call BIOS)
Code example:
; BIOS loads bootloader like this:
mov ah, 0x02 ; Read sectors function
mov al, 1 ; Read 1 sector
mov ch, 0 ; Cylinder 0
mov cl, 1 ; Sector 1
mov dh, 0 ; Head 0
mov bx, 0x7C00 ; Load to address 0x7C00
int 0x13 ; Call BIOS disk service
×
Bootloader's multi-stage job:
1. Stage 1 (512B): Load stage 2 from disk
2. Stage 2: Show menu, parse filesystem
3. Find kernel: /boot/vmlinuz or similar
4. Load kernel: Read from disk into RAM
5. Set up: Switch to protected mode, set stack
6. Jump to kernel: Hand over control
Filesystem aware: Stage 2 can read FAT, NTFS, EXT4
Menu: Can show OS selection (multi-boot)
Disappears: Kernel overwrites bootloader memory
Common bootloaders: GRUB (Linux), Windows Boot Manager, systemd-boot.
×
Kernel takes over:
1. Initialize: Set up memory manager, interrupt table
2. Detect hardware: Find all devices (ACPI/device tree)
3. Load drivers: Storage, network, graphics
4. Start services: Network, login, GUI
5. Launch init: First user process (PID 1)
6. Show desktop: Login screen or desktop environment
Memory management: Kernel takes over all RAM from BIOS map
Drivers: Replaces BIOS services with native drivers
Secure: Kicks BIOS out of memory (no more BIOS calls)
Complete handoff: Kernel becomes the permanent system manager.
⚙️
BIOS/UEFI
System Firmware
~8-32 MB (typical)
🧠
ROM/Flash
Firmware Storage
Permanent
🔑
Bootloader
The Tiny Key Program
512B - 10MB
💽
Disk Storage
Hard Drive / SSD
256GB - 2TB
👑
Kernel
Core of Operating System
50-500 MB
⚡
RAM
Random Access Memory
8-32 GB
📊 Size Comparison
Bootloader Stage 1 = One tweet
BIOS/UEFI = One book
Kernel = Library shelf
⚡ Speed Order
1. Power on
2. BIOS/UEFI runs (ms)
3. Bootloader loads (ms)
4. Kernel starts (seconds)
🔧 Tech Level
BIOS/UEFI: C + Assembly
Bootloader: Assembly + C
Kernel: Mostly C + Assembly
×
Location: Flash chip on motherboard (modern)
Size: ~8-32 MB (typical), can be larger
Job: First program that runs when power is on
Written in: Mostly C, some Assembly
Key task: Initialize hardware, find bootloader
🔄 BIOS vs UEFI:
• BIOS (old): 16-bit, MBR disks, text interface
• UEFI (new): 32/64-bit, GPT disks, graphical, secure boot
• Both serve same purpose: initialize system and boot OS
Execution: Runs from flash memory, uses RAM only after initializing it.
Key term: POST - Hardware self-test that BIOS/UEFI runs.
×
Type: Traditionally read-only; today it's usually flash (rewritable)
Physical form: Small chip soldered to motherboard
Permanence: Contents stay even when power is off
Contains: BIOS/UEFI firmware
Why ROM?: Must be available immediately at power-on
💡 ROM vs RAM:
• ROM/Flash: Permanent, non-volatile, slower, contains firmware
• RAM: Temporary, volatile, fast, holds running programs
• Disk: Permanent, non-volatile, slow, holds OS and files
Modern storage: Uses NAND flash memory (same as SSDs, USB drives) that can be updated.
Fun fact: Early computers had mask ROM chips that couldn't be changed at all!
×
Location: MBR (legacy BIOS) OR EFI System Partition (UEFI)
Stage 1 size: 512 BYTES total (446 bytes of code!)
Full bootloader: Usually 1KB - 10MB with multiple stages
Written in: Assembly + C (modern bootloaders)
Job: Find and load the operating system kernel
Fate: Hands control to kernel, then unused
🔧 Stages of Bootloading:
• Stage 1 (MBR): 512 bytes, finds Stage 2
• Stage 1.5: Filesystem drivers (optional)
• Stage 2: Full bootloader with menus, kernel loading
• Kernel loader: Final stage that loads OS
Modern bootloaders: GRUB (Linux), Windows Boot Manager, systemd-boot.
UEFI difference: Bootloaders are .efi files in the EFI System Partition.
×
Types: HDD (spinning disks), SSD (flash memory), NVMe (super fast)
Speed order: NVMe > SSD > HDD (slowest)
Persistence: Keeps data when power is off
Boot location: Legacy BIOS: sector 0 (MBR). UEFI: bootloader file in EFI System Partition.
Contains: Everything! OS, apps, your files
📁 Disk Layout for Boot:
1. Sector 0 (MBR): Bootloader (512 bytes) - legacy BIOS
2. EFI System Partition: Bootloader files (.efi) - UEFI
3. Partitions: Divided sections (C:, D: on Windows)
4. Filesystem: Where OS and files live (NTFS, EXT4, etc.)
Key term: MBR (Master Boot Record) vs GPT (GUID Partition Table) - old vs new disk partitioning.
Why OS isn't in ROM? Too big (GB vs MB), needs updates, different for each computer.
×
What it is: The "boss" program that controls everything
Written in: Mostly C, some Assembly
Size: 50-500 MB (huge compared to bootloader!)
Location: Somewhere on disk (not fixed location)
Job: Manage hardware, memory, processes, security
👑 Kernel's Responsibilities:
• Memory management: Allocates RAM to programs
• Process management: Runs multiple programs at once
• Device drivers: Talks to hardware (keyboard, screen, etc.)
• File system: Reads/writes files to disk
• Security: Protects system from bad programs
Popular kernels: Linux Kernel, Windows NT Kernel, macOS XNU Kernel.
Bootloader handoff: Bootloader loads kernel into RAM, sets up CPU, then jumps to kernel code and disappears.
×
What it is: Temporary, super-fast workspace
Speed: 100x faster than SSD, 1000x faster than HDD
Volatility: Forgets everything when power is off
Physical form: Memory sticks (DIMMs) on motherboard
Purpose: Everything runs here when executing
📊 Boot Process in RAM:
1. BIOS/UEFI runs from ROM/flash, initializes RAM
2. Bootloader loaded from disk to RAM
3. Kernel loaded from disk to RAM
4. Kernel takes over, manages all RAM
5. Applications run in RAM (everything executes here)
Key term: Volatile memory - loses data when power off (RAM). Non-volatile - keeps data (ROM, Disk).
Why not just use disk? Disk is 100-1000x slower! CPU would wait forever for data.
×
BIOS/UEFI routine that checks hardware components are working:
• Tests CPU, RAM, graphics card
• Checks for keyboard, mouse
• Verifies disk drives are present
• If error: beep codes or display error
• Success: single beep (if speaker present)
×
Old disk format (used since 1983!):
• First sector of disk (512 bytes)
• Contains: Boot code (446 bytes) + Partition table (64 bytes) + Signature (2 bytes)
• Limited to 4 primary partitions
• Max disk size: 2TB
• Still used on many systems
MBR Layout:
[446 bytes boot code][64 bytes partitions][2 bytes 0x55AA]
×
Modern disk format (UEFI standard):
• Replaces MBR (but includes protective MBR for compatibility)
• Unlimited partitions (practically)
• Supports disks larger than 2TB
• Has backup partition table at end of disk
• Required for UEFI boot
GPT vs MBR:
• GPT: Modern, >2TB, many partitions, UEFI only
• MBR: Old, ≤2TB, 4 partitions, BIOS/UEFI
×
Memory that loses data when power is removed:
• RAM (Random Access Memory) - Main system memory
• CPU Cache - Ultra-fast memory inside CPU
• Registers - Tiny memory inside CPU (fastest)
• Used for: Running programs, temporary data
• Speed hierarchy: Registers > Cache > RAM > Disk
Why volatile?
Volatile memory uses capacitors that need constant power.
Non-volatile uses different technology (flash, magnetic).
×
Memory that keeps data without power:
• ROM/Flash - BIOS/UEFI firmware
• SSD/NAND Flash - Solid state drives
• HDD - Magnetic hard drives
• USB drives, SD cards - Portable storage
• Used for: Long-term storage, firmware
Persistence trade-off:
Non-volatile = keeps data, but slower to write
Volatile = fast, but loses data when power off