From Power Button to Login Screen
CPU's first instruction address:
; First instruction at reset vector (x86)
jmp BIOS_ENTRY_POINT
; BIOS/UEFI code stored in ROM/Flash on motherboard
Legacy firmware (1970s)
Modern firmware (2005+)
Diagnostic testing sequence to verify hardware is functioning correctly.
Beep codes or displayed codes indicate status or errors:
| Beeps | Meaning (AMI BIOS) |
|---|---|
| 1 short beep | POST successful |
| 2 short beeps | POST error (see screen for details) |
| 1 long, 2 short | Video error (GPU problem) |
| 1 long, 3 short | Video error (no GPU detected) |
| Continuous beeps | Memory error (RAM not detected/failed) |
Modern systems: Show POST code on small LED display or in UEFI interface
BIOS/UEFI checks devices in configured order:
BIOS Mode (MBR):
0x55AA in last two bytesMBR Structure (512 bytes):
+--------------------------------------------------+
| Bootstrap code (446 bytes) | <- Bootloader code
+--------------------------------------------------+
| Partition Table (64 bytes) | <- 4 partition entries
| - Partition 1: bootable, type, start, size |
| - Partition 2: ... |
| - Partition 3: ... |
| - Partition 4: ... |
+--------------------------------------------------+
| Boot Signature: 0x55 0xAA (2 bytes) | <- Valid boot sector
+--------------------------------------------------+
UEFI Mode (GPT):
/EFI/BOOT/BOOTX64.EFI.efi filesGPT Disk Structure:
+--------------------------------------------------+
| Protective MBR (for backward compatibility) |
+--------------------------------------------------+
| Primary GPT Header |
| - Disk GUID |
| - Partition table location |
| - CRC32 checksums |
+--------------------------------------------------+
| Partition Table (up to 128 entries) |
| Entry 1: EFI System Partition (ESP) | <- FAT32, bootloaders
| Entry 2: Linux root partition |
| Entry 3: Linux swap |
| ... |
+--------------------------------------------------+
| Partitions (actual data) |
+--------------------------------------------------+
| Backup Partition Table |
+--------------------------------------------------+
| Backup GPT Header |
+--------------------------------------------------+
/EFI/
+-- BOOT/
| +-- BOOTX64.EFI # Default bootloader (fallback)
+-- ubuntu/
| +-- grubx64.efi # Ubuntu GRUB bootloader
+-- Microsoft/
| +-- Boot/
| +-- bootmgfw.efi # Windows Boot Manager
+-- refind/
+-- refind_x64.efi # rEFInd boot manager
A small program that loads the operating system kernel into memory. Bridge between firmware (BIOS/UEFI) and OS kernel.
| Bootloader | Used By | Notes |
|---|---|---|
| GRUB 2 | Linux (Ubuntu, Fedora, etc.) | Most common, powerful, scriptable |
| systemd-boot | Linux (Arch, some UEFI systems) | Simple, UEFI-only |
| Windows Boot Manager | Windows | bootmgfw.efi (UEFI) or bootmgr (BIOS) |
| rEFInd | Multi-boot systems | Graphical, auto-detects OSes |
/boot/grub.efi file on ESP: /EFI/ubuntu/grubx64.efi/boot/grub/grub.cfgmenuentry 'Ubuntu' {
set root='hd0,gpt2' # Partition with /boot
linux /vmlinuz-5.15.0-generic \ # Kernel image
root=UUID=abc-123 ro quiet # Kernel parameters
initrd /initrd.img-5.15.0-generic # Initial RAM disk
}
menuentry 'Ubuntu (recovery mode)' {
set root='hd0,gpt2'
linux /vmlinuz-5.15.0-generic \
root=UUID=abc-123 ro single # Single-user mode
initrd /initrd.img-5.15.0-generic
}
menuentry 'Windows Boot Manager' {
chainloader /EFI/Microsoft/Boot/bootmgfw.efi
}
Key kernel parameters:
root=UUID=... - Root filesystem to mountro - Mount root as read-only initiallyquiet - Suppress verbose boot messagessplash - Show graphical boot splashsingle - Boot to single-user mode (recovery)init=/bin/bash - Override init system (emergency)/boot/vmlinuz-* into memory/boot/initrd.img-* into memoryKernel image (vmlinuz) is compressed:
Main kernel initialization function: start_kernel() in init/main.c
[ 0.000000] Linux version 5.15.0-generic (gcc version 11.2.0)
[ 0.000000] Command line: root=UUID=abc-123 ro quiet splash
[ 0.000000] KERNEL supported cpus: Intel GenuineIntel
[ 0.000000] x86/fpu: x87 FPU will use FXSAVE
[ 0.001234] Memory: 16384MB RAM
[ 0.005678] Zone ranges: DMA [0-16MB], Normal [16MB-16GB]
[ 0.012345] ACPI: Core revision 20210730
[ 0.023456] PCI: Using configuration type 1 for base access
[ 0.034567] clocksource: tsc: mask: 0xffffffff max_cycles: 0x3b...
[ 0.045678] Console: colour VGA+ 80x25
[ 0.056789] Calibrating delay loop... 4788.00 BogoMIPS
initramfs (Initial RAM Filesystem): Temporary root filesystem in memory
Why is initramfs needed?
mount, modprobe, lvm, cryptsetup/init (runs in initramfs)Kernel runs /init script from initramfs:
/devroot= kernel parameter/root within initramfsswitch_root - Change root to real filesystem/sbin/init on real root filesystem# Simplified /init script (in initramfs)
#!/bin/sh
# Mount pseudo-filesystems
mount -t proc proc /proc
mount -t sysfs sysfs /sys
mount -t devtmpfs devtmpfs /dev
# Load modules
modprobe ext4
modprobe nvme
# Setup LVM if present
lvm vgscan
lvm vgchange -ay
# Mount real root filesystem
mount -o ro /dev/nvme0n1p2 /root
# Switch to real root and run /sbin/init
exec switch_root /root /sbin/init
First user-space process started by kernel. Parent of all other processes.
| Init System | Used By | Characteristics |
|---|---|---|
| systemd | Modern Linux (Ubuntu 15.04+, Fedora, Arch, Debian) | Parallel startup, dependencies, targets |
| SysV init | Legacy Linux, BSD | Sequential scripts, runlevels |
| Upstart | Ubuntu 6.10-14.10 (deprecated) | Event-based |
| OpenRC | Gentoo, Alpine Linux | Dependency-based, lightweight |
# Kernel executes (PID 1):
/sbin/init → symlink to /lib/systemd/systemd
systemd uses targets instead of runlevels:
| Target | SysV Runlevel | Description |
|---|---|---|
poweroff.target |
0 | Shutdown |
rescue.target |
1, s | Single-user mode (maintenance) |
multi-user.target |
2, 3, 4 | Multi-user, text mode |
graphical.target |
5 | Multi-user, GUI |
reboot.target |
6 | Reboot |
Default target: /etc/systemd/system/default.target (symlink)
$ ls -l /etc/systemd/system/default.target
lrwxrwxrwx 1 root root 36 Oct 15 10:23 \
/etc/systemd/system/default.target -> /lib/systemd/system/graphical.target
systemd reads unit files and starts services based on dependencies:
.service - Service (daemon).target - Group of units (like runlevels).mount - Mount point.socket - Socket activation.timer - Cron-like scheduling.device - Hardware devicegraphical.target
+-- multi-user.target
| +-- basic.target
| | +-- sysinit.target
| | | +-- local-fs.target (mount filesystems)
| | | +-- swap.target (enable swap)
| | | +-- cryptsetup.target (decrypt volumes)
| | +-- sockets.target
| | +-- timers.target
| +-- sshd.service
| +-- networking.service
| +-- cron.service
+-- display-manager.service (GDM, LightDM, SDDM)
systemd starts services in parallel when dependencies allow:
# Traditional sequential (SysV):
Start networking... [done]
Start database... [done]
Start web server... [done]
Total: 15 seconds
# systemd parallel:
Start networking, database, logging simultaneously
Wait only for actual dependencies
Total: 6 seconds
After= - Start after these units (but doesn't wait for them to finish)Before= - Start before these unitsRequires= - Hard dependency (fail if dependency fails)Wants= - Soft dependency (continue even if dependency fails)Final step: Start login interface
Text mode (multi-user.target):
getty@tty1.service - Login prompt on TTY1-6GUI mode (graphical.target):
gdm.service - GNOME Display Managerlightdm.service - LightDMsddm.service - SDDM (KDE)Time | Component | Action
--------|------------------|------------------------------------------
0.0s | PSU | Power Good signal sent
0.1s | Motherboard | Clock started, CPU reset released
0.2s | CPU | Fetch first instruction from 0xFFFFFFF0
0.2s | UEFI | POST begins
0.5s | UEFI POST | CPU check OK
1.0s | UEFI POST | Memory: 16GB detected, quick test OK
2.0s | UEFI POST | PCIe devices enumerated
3.0s | UEFI POST | NVMe SSD detected
4.0s | UEFI | Read ESP, find GRUB
5.0s | GRUB | Display boot menu
10.0s | GRUB | Timeout, load default kernel
10.5s | GRUB | Load vmlinuz into memory
11.0s | GRUB | Load initrd into memory
11.5s | GRUB | Jump to kernel entry point
11.6s | Kernel | Decompress kernel
12.0s | Kernel | start_kernel() - CPU init
12.5s | Kernel | Memory management init
13.0s | Kernel | Scheduler init
13.5s | Kernel | Device drivers init
14.0s | Kernel | Mount initramfs, execute /init
14.5s | initramfs | Load ext4, nvme modules
15.0s | initramfs | Mount /dev/nvme0n1p2 as root
15.5s | initramfs | switch_root, exec /sbin/init
16.0s | systemd (PID 1) | Start, determine target: graphical.target
16.5s | systemd | Mount /home, /var, /tmp
17.0s | systemd | Start networking, logging (parallel)
18.0s | systemd | Start database, web server (parallel)
20.0s | systemd | Start GDM (display manager)
22.0s | GDM | Login screen displayed
--------|------------------|------------------------------------------
Total: 22 seconds (modern UEFI system with NVMe SSD)
Causes:
Fix:
grub-install /dev/sdagrub-mkconfig -o /boot/grub/grub.cfgCauses:
Fix:
mkinitramfs -o /boot/initrd.img-$(uname -r)/boot/grub/grub.cfg root UUIDManual boot from GRUB:
grub> ls # List partitions
(hd0) (hd0,gpt1) (hd0,gpt2)
grub> set root=(hd0,gpt2) # Set root partition
grub> linux /vmlinuz root=/dev/sda2 ro # Load kernel
grub> initrd /initrd.img # Load initramfs
grub> boot # Boot
Boot to rescue mode:
systemd.unit=rescue.target to kernel linesingle or 1 for single-user modeinit=/bin/bash for root shell (emergency)