The boot process is how a computer starts up. In Linux, the process is usually done in 4 steps:

  1. Preboot Execution Environment (PXE)
  2. Bootloader
  3. Initial RAM Disk (initrd)
  4. Kernel

The process beings with PXE , which is an environment which may be using connected physical media or a network connection. Inside this environment, a small program executes called the Bootloader. For example, a bootloader like GRUB2 will load two specific items: the initial RAM disc (initrd) and the Kernel.

initrd is a temporary root file system that provides essential drives and tools required prior to booting the full Linux OS. It is a middle step that enables the kernel.

Preboot Execution Environment (PXE)

PXE is a technology that allows a computer to start up over a network connection rather than its own Storage devices. This is particularly useful when there are many computers that need to be setup or maintained remotely.

PXE works by using a network card that supports PXE booting. As the computer starts, the network card will make a DHCP request for an IP address and the location of a TFTP server, which stores the necessary boot files (including the Bootloader, such as GRUB2 for example). Once those files are acquired the bootloader will load an operating system installer or a pre-configured system image.

PXE is common used in businesses, schools, and data centres. This is done to enable installing the OS from a central server rather than manually installing the system on each machine.

Bootloader

The bootloader is responsible for loading the operating system by selecting and launching the Linux Kernel. As the computer starts, the BIOS hands control over to the boot loader, which then allows selection of OS/kernel, if applicable.

From there, GRUB2 will read a config file at /boot/grub/grub.cfg. This contains boot entries for kernel versions, boot parameters, etc. With this done, GRUB2 will load Initial RAM Disk (initrd) and the selected kernel, which together prepare for booting the system

Note

Administrators can modify GRUB2 settings via /etc/default/grub and then running update-grub.

Initial RAM Disk (initrd)

The initrd, or more specifically, initrd.img is an image file with a temporary root file system that gets loaded into memory prior to the real file system loads. This done because the image file contains essential drivers, kernel modules, and tools needed to initialise the computer’s hardware and prepare the system for booting.

For example, if the root partition of the computer is encrypted, initrd contains the encryption modules necessary to unlock the disc.

Note that while initrd is loading, the system will also load the Linux kernel itself. This is done such that required components, such as storage controllers, encryption modules, or system drives are ready to be moved over to the actual root file system - a process that is particularly important when we are booting from media that the kernel cannot directly access at boot.

the initrd is typically located in /boot/initrd.img. It can be generated with mkinitramfs or dracut

initrd can be managed with mkinitrd or dracut.

Kernel

The Kernel manages hardware, processes, memory, and system resources.

Once the bootloader loads the Linux kernel, it initialises the system, detects hardware, mounts the root file system, and starts essential processes.

The kernel behaviour can be adjusted with sysctl, a tool used to modify kernel parameters at runtime, such as networking, memory, and security.

They can also be made permanent by editing /etc/sysctl.conf and applying the changes without a reboot with sysctl -p.

Example

Enable IP forwarding by adding net.ipv4.ip_forward=1 to /etc/sysctl.conf and then apply the new configuration with sysctl -p. This allows the system to permanently route network traffic between interfaces.