Skip to content

Boot Process in Linux

First PublishedByAtif Alam

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.

  1. 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).
  2. 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.
  3. 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.
  4. 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).
  5. Login — Getty processes (or a display manager for GUI) provide login prompts.

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.

The kernel can load modules at runtime (drivers, filesystems, etc.). Common commands:

CommandPurpose
modprobe <module>Load module and dependencies (recommended).
insmodLoad a single module (no dependency resolution).
rmmodUnload a module.
lsmodList loaded modules.
modinfo <module>Show module info (path, parms, description).

Example: modprobe vfat loads the VFAT filesystem module so you can mount FAT volumes.

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 application
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/myapp --config /etc/myapp/config.yaml
Restart=on-failure
User=myapp
[Install]
WantedBy=multi-user.target
  • ExecStart — Command to run. Use absolute paths.
  • Restarton-failure restarts the process when it exits with a non-zero status.
  • User — Run as this user (good for least privilege).

Then:

Terminal window
sudo systemctl daemon-reload
sudo systemctl enable myapp
sudo systemctl start myapp
sudo systemctl status myapp
  • daemon-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.