A Beginner's Guide to the Linux Boot Process and System Workflow

 Linux Boot Process

Introduction
When you press the power button on a computer that is running Linux, a lot of things occur before you see the login screen or the desktop appear to view. Understanding what has happened behind the scenes before the login prompt is the primary responsibility of system admins. The boot process is the sequence of steps that the system follows to start up and load the operating system. The boot process makes it easy for administrators to pinpoint the function of each step for system troubleshooting, system optimization and mastering the Linux internals.

In the previous post, we discussed what Linux is and its Distributions. In this post, we’ll walk through each step of the Linux boot process, from hardware initialization to the login prompt and explain how the Linux operating system works behind the scenes.

  1.    Visual Representation of Boot Process
  2.     Linux Boot Process
  3.    Key Files and Directories in the Boot Process
  4.     Linux System Workflow 

     1. Visual Representation of Boot Process

[Power On]

     ↓

[BIOS/UEFI]

     ↓

[Bootloader (GRUB)]

     ↓

[Kernel + initramfs/initrd]

     ↓

[Real Root File System Mounted]

     ↓

[Init /systemd]

     ↓

[Services/Targets]

     ↓

[Login Prompt or GUI]


2. Linux Boot Process

The Linux boot process is a sequence of steps that the system follows to start up and load the operating system. It consists of several stages, from powering on the hardware to launching the user interface. Here is a detailed, step-by-step explanation of the Linux boot process.



Step 2.1 Power on and BIOS: (Basic input/output System)
When you power on the computer, the BIOS (basic input/output System) or UEFI (Unified Extensible Firmware Interface) firmware is activated. BIOS/UEFI performs a power-on Self-Test (POST) to check hardware components (CPU, RAM, storage, etc.). It initializes hardware devices and looks for a bootable device (e.g., hard drive, USB or CD/DVD). Boot order is determined by the BIOS/UEFI settings.

Step 2.2 Bootloader (GRUB)
The BIOS/UEFI loads the boot loader from the Master Boot Record (MBR) or EFI partition. In Linux, the most common boot loader is GRUB (Grand Unified Boot Loader). Grub displays a menu (if configured) to allow the user to choose an operating system or kernel version. Grub loads the selected Linux kernel and initial RAM disk (initrd) in memory.

Step 2.3 Kernel Initialization
The Linux kernel is loaded into memory and starts executing. Kernel decompresses itself and initializes essential hardware components (CPU, memory, storage, etc.). It mounts the initrd (initial RAM disk), which contains a temporary root file system and drivers needed to boot the system. Kernel loads necessary drivers and modules to access the root file system on the hard drive.

Step 2.4 Init Process (systemd or SysV init)
The kernel starts the init process, which is the first user space process (PID 1). In modern Linux systems, systemd is the most common init system (replacing older systems like SysVinit). Systemd initializes the system by starting and managing services, mounting file systems and setting up the environment. It reads configuration files from /etc/systemd/ and /lib/systemd/ to determine which services need to start.

Step 2.5 Run levels/Targets
The system enters a specific run level (SysVinit) or target (systemd). Available Run Levels in Linux

0 - Halt

1 - Single user mode

2 - Multiuser without NFS

3 - Multiuser mode with networking

4 - Unused

5 - X11 (GUI)

6 – Reboot


· SysVinit: Run levels (0-6) define the system state (e.g., single-user mode, multi-user mode or graphical mode).
·   Systemd: Targets (e.g., graphical.target, multi-user.target) are used instead of run levels.

The default run level/target is defined in configuration files (e.g.,/etc/inittab for SysVinit or /etc/systemd/system/default target for systemd).


Step 2.6 Services and Daemons

Essential services and daemons are started.

  •  Services as networking, logging and hardware management are initialized.
  •  Systemd or SysVinit starts services based on the run level/target
Step 2.7 Login Prompt or Graphical Interface
The system displays a login prompt or starts a graphical user interface. In text mode, a terminal login prompt is displayed. In graphical mode, a display manager (e.g., GDM, LightDM) starts and provides a graphical login screen. After logging in, the user's desktop environment (e.g., GNOME, KDE) or window manager is launched.


3. Key files and directories in the Boot Process


·    GRUB Configuration: /boot/grub/grub.cfg

·     Kernel: /boot/vmlinuz-<version>

·     Initrd: /boot/initrd.img-<version>

·     systemd Config: /etc/systemd/

· Run level/Target Configuration:/etc/inittab (SysVinit) or /etc/systemd/system/default.target (systemd)

Understanding the boot process is essential for troubleshooting boot issues, optimizing startup time and customizing the system.


4. Linux System Workflow?

Linux operates using a modular design in which several key component works together:


1. Kernel

·       The kernel is the core of the Linux operating system.

·       It manages hardware resources as CPU, memory, devices and allows software to interact with the hardware.

· It handles tasks as process management, memory management and device communication


2. Shell

   ·       Shell is a command-line interface (CLI) that allows users to interact with the system.

   ·        Common shells include Bash (Bourne Again Shell), Zsh and Fish.

   ·        Users can run commands, execute scripts and automate tasks using the shell


3. System Libraries

·    Libraries provide already defined code that applications can use to perform common tasks.

·       For example, the GNU C Library (glibc) is essential for running programs on Linux


4. System Utilities

These are programs and tools that perform specific tasks such as file management, network configuration and software installation. Examples include ls, cp, mv, grep and apt.


5. Desktop Environment (Optional)

Linux can run in a graphical user interface (GUI) mode using desktop environments like GNOME, KDE Plasma or XFCE. These environments provide a user-friendly interface with windows, icons, and menu.


6. Applications

Linux supports a wide range of applications, from web browsers (e.g. Firefox) to office suites (e.g. LibreOffice) and development tools (e.g. VS Code). Linux distributions have package managers (e.g. apt, yum and pacman) to easily install and update software.

For more updates and information keep visiting SeekLinux.

Post a Comment

Previous Post Next Post