Frequently Asked Question

How does the kernel boot from power-on to a login prompt?

Firmware (BIOS or UEFI) runs first, picks a bootable device, and loads the bootloader (GRUB, systemd-boot, rEFInd). The bootloader loads two files into RAM: the kernel image (vmlinuz) and the initramfs, a small compressed filesystem containing enough modules and tools to find and mount the real root filesystem.

The kernel decompresses itself, initialises the CPU, sets up paging, discovers hardware, mounts the initramfs as a temporary root, and runs /init. That script loads disk and filesystem modules, mounts the real root, and uses switch_root to pivot. The kernel then execs the system's PID 1 (/sbin/init, almost always systemd today), which brings up everything else and eventually shows the login prompt or display manager.

Video

Further reading and video