The Linux system boot process and runlevels define the sequence in which the system starts up, initializes hardware and software components, and defines the operating state of the system.
Understanding the boot process and runlevels is essential for system administrators to troubleshoot startup issues, configure system states, and control how services and processes launch.
Modern Linux systems predominantly use systemd replacing the older SysV init and runlevels with targets and units.
Linux Boot Process
The Linux boot process involves several sequential stages:
1. BIOS/UEFI Initialization: After the system is powered on, the BIOS or UEFI firmware performs the Power-On Self-Test (POST) to verify that essential hardware components are working correctly. It then locates and loads the bootloader from the disk or EFI system partition to begin the boot process.
2. Bootloader Execution (e.g., GRUB2): The bootloader loads the selected Linux kernel into memory along with the optional initramfs (initial RAM disk) image, which contains drivers and tools needed during early boot. It also presents a menu that allows users to choose between different kernels or operating systems.
3. Kernel Initialization: The Linux kernel decompresses itself and initializes core system components such as device drivers, memory management, and process scheduling. It mounts the root filesystem and starts essential kernel threads required for system operation.
4. systemd Initialization: Once the kernel setup is complete, it starts systemd as the first user-space process with process ID 1 (PID 1). systemd reads its unit configuration files and begins launching and managing all services, devices, mount points, and system targets.
5. Target Execution: systemd activates a specific target that defines the system’s operational mode, such as multi-user.target for a command-line multiuser environment or graphical.target for a full graphical interface. When the target is reached, the system is fully initialized and ready for use.
Runlevels and Systemd Targets
The following are the core operating states used by Linux systems. They show how runlevels evolved into systemd targets for better service management.
1. Traditional Linux uses runlevels (0-6) to define system states:
0: Halt
1: Single-user mode (maintenance)
2-5: Multi-user modes with varying configurations
6: Reboot
2. systemd replaces runlevels with targets:
poweroff.target: system shutdown
rescue.target: single-user mode
multi-user.target: multi-user, non-graphical
graphical.target: multi-user with GUI
reboot.target: reboot system
You can switch targets using:
sudo systemctl isolate multi-user.targetManaging Boot Targets and Services
Linux uses systemd targets to define different boot and runtime states. The following are commands used to view and configure these targets.
systemctl get-defaultsudo systemctl set-default graphical.targetsystemctl list-units --type=targetTroubleshooting and Special Modes
1. Single-user mode: For maintenance and recovery without networking.
2. Boot loader options allow selecting different kernels or rescue modes.
3. Use journalctl for boot logs:
journalctl -b
We have a sales campaign on our promoted courses and products. You can purchase 1 products at a discounted price up to 15% discount.