Boot Process in Linux
From power-on to a login prompt, the system goes through firmware, bootloader, kernel, and userland init. On most modern systems the init process is typically systemd (or init on older systems). This page summarizes the sequence, how the kernel is loaded, kernel modules, and how to run a process as a systemd service.
Boot sequence
Section titled “Boot sequence”- Power on / BIOS or UEFI — POST (Power-On Self Test), hardware initialization, and selection of boot device. The firmware loads the first stage of the bootloader from the disk (e.g. MBR or EFI partition).
- Bootloader (e.g. GRUB) — Loads the kernel and initramfs (initrd) into memory, passes kernel parameters (e.g.
root=for the root filesystem), and transfers control to the kernel. See Loading the kernel below. - Kernel — Uncompresses, initializes hardware, mounts the root filesystem (often with help from the initrd), and starts the first userspace process (init). The kernel image and initrd are often stored under
/boot— see File System for the hierarchy. - systemd / init — Runs as PID 1: brings up services from unit files, mounts filesystems listed in
/etc/fstab, and reaches the target (e.g. multi-user or graphical). - Login — Getty processes (or a display manager for GUI) provide login prompts.
Loading the kernel
Section titled “Loading the kernel”GRUB — Configuration is typically in /etc/default/grub and scripts under /etc/grub.d/. The important parts for loading the kernel are the linux and initrd lines (and optionally boot); root= tells the kernel which device holds the root filesystem. After loading, GRUB jumps to the kernel entry point.
kexec — Loads a new kernel (and optionally initrd) into memory and executes it without a full hardware reboot. Used for fast reboots or crash recovery. Example: kexec -l /boot/vmlinuz --initrd=/boot/initrd.img --reuse-cmdline then kexec -e to switch.
Kernel modules
Section titled “Kernel modules”The kernel can load modules at runtime (drivers, filesystems, etc.). Common commands:
| Command | Purpose |
|---|---|
modprobe <module> | Load module and dependencies (recommended). |
insmod | Load a single module (no dependency resolution). |
rmmod | Unload a module. |
lsmod | List loaded modules. |
modinfo <module> | Show module info (path, parms, description). |
Example: modprobe vfat loads the VFAT filesystem module so you can mount FAT volumes.
Running a process as a service
Section titled “Running a process as a service”With systemd, you run a process as a service by creating a unit file (e.g. /etc/systemd/system/myapp.service) and enabling/starting it.
Example unit file:
[Unit]Description=My applicationAfter=network.target
[Service]Type=simpleExecStart=/usr/local/bin/myapp --config /etc/myapp/config.yamlRestart=on-failureUser=myapp
[Install]WantedBy=multi-user.target- ExecStart — Command to run. Use absolute paths.
- Restart —
on-failurerestarts the process when it exits with a non-zero status. - User — Run as this user (good for least privilege).
Then:
sudo systemctl daemon-reloadsudo systemctl enable myappsudo systemctl start myappsudo systemctl status myappdaemon-reload— Reload unit files after editing.enable— Start at boot (creates symlink in the target).start/status— Run now and show status.
For mount points and fstab, see File System.