Boot Process
Linux boot sequence from firmware through initramfs to systemd targets, including rescue and emergency modes.
Boot Sequence
1. Firmware BIOS or UEFI initializes hardware, runs POST 2. Bootloader GRUB2 loads from MBR (BIOS) or ESP (UEFI) 3. Kernel vmlinuz loaded into memory, decompressed, hardware init 4. initramfs Temporary root filesystem — loads storage drivers, finds real root 5. systemd PID 1 — mounts filesystems, starts services per target 6. Target multi-user.target (CLI) or graphical.target (GUI)
Systemd Targets
Targets replaced SysV runlevels. A target is a group of units that define a system state.
systemctl get-default
sudo systemctl set-default multi-user.target
sudo systemctl set-default graphical.target
sudo systemctl isolate multi-user.target
poweroff.target runlevel 0 Halt/shutdown rescue.target runlevel 1 Single-user, root shell, minimal services multi-user.target runlevel 3 Full multi-user, network, CLI only graphical.target runlevel 5 Multi-user + display manager reboot.target runlevel 6 Reboot emergency.target (none) Minimal — root on / read-only, no services
systemctl list-units --type=target
Rescue Mode
Rescue mode starts a minimal system with root shell. Filesystem is mounted read-write. Network and most services are off.
sudo systemctl isolate rescue.target
systemd.unit=rescue.target
Or the legacy equivalent: append 1 or single to the kernel command line.
Emergency Mode
Emergency mode is more minimal than rescue. Root filesystem is mounted read-only. No services, no network. Use when rescue mode won’t boot.
systemd.unit=emergency.target
mount -o remount,rw /
systemctl reboot
Reset Root Password — RHCSA Critical Skill
This is tested on the RHCSA exam. Memorize this procedure.
linux line and append rd.break at the endlinux ($root)/vmlinuz-... root=/dev/mapper/rhel-root ... rd.break
mount -o remount,rw /sysroot
chroot /sysroot
passwd root
touch /.autorelabel
exit
exit
The /.autorelabel file tells SELinux to relabel the entire filesystem on next boot. Without it, the new password file has the wrong SELinux context and authentication fails.
Kernel Parameters
cat /proc/cmdline
quiet Suppress most boot messages rhgb Red Hat graphical boot rd.break Break into initramfs shell (password reset) init=/bin/bash Skip systemd entirely, drop to bash (emergency) selinux=0 Disable SELinux (diagnostic only, never in production) systemd.unit=X Boot into target X single / 1 Rescue/single-user mode crashkernel=auto Reserve memory for kdump
initramfs
The initial RAM filesystem contains drivers and scripts needed to mount the real root. If you add a new storage driver (e.g., for iSCSI or new RAID), you need to rebuild it.
sudo dracut --force
sudo dracut --force /boot/initramfs-$(uname -r).img $(uname -r)
sudo mkinitcpio -P
lsinitrd /boot/initramfs-$(uname -r).img | head -40
Boot Diagnostics
systemd-analyze
Startup finished in 3.456s (firmware) + 1.234s (loader) + 2.345s (kernel) + 5.678s (userspace) = 12.713s graphical.target reached after 5.432s in userspace
systemd-analyze blame | head -15
systemd-analyze critical-chain
systemctl --failed
dmesg | head -50
journalctl -k -b