BCE-C712 Linux System Administration

0 of 75 lessons complete (0%)

Starting up and Shutting Down

Kernel Loading

You don’t have access to this lesson

Please register or sign in to access the course content.

Kernel loading is a critical step in the Linux boot process, where the Linux kernel, the core component of the operating system, is loaded into memory and begins execution. The kernel is responsible for managing hardware, processes, memory, and system calls, and it provides the foundation for all higher-level software.

Steps Involved in Kernel Loading

  1. Bootloader Stage:
    • When you power on your computer, the BIOS/UEFI firmware initializes the hardware and then locates the bootloader, a small program stored on the disk (usually in the Master Boot Record or EFI partition).
    • The most common bootloader in Linux systems is GRUB (GRand Unified Bootloader).
    • GRUB presents a menu, allowing users to select which operating system or kernel version to boot, if multiple options are available.
  2. Loading the Kernel into Memory:
    • Once a kernel is selected, GRUB loads the kernel image from the disk into memory.
    • The kernel image is a compressed file, usually named vmlinuz, where “vm” stands for “virtual memory” and “linuz” is a variant of “Linux.”
    • Along with the kernel, an initial RAM disk (initrd or initramfs) is loaded. This is a temporary root file system that helps the kernel load drivers and other essential modules until the actual root file system is mounted.
  3. Decompressing the Kernel:
    • After loading into memory, the kernel is decompressed. This step is necessary because the kernel image is stored in a compressed format to save space.
  4. Kernel Initialization:
    • Once decompressed, the kernel begins its initialization process.
    • It performs hardware detection and initializes essential system components, such as the CPU, memory, and device drivers.
    • During this phase, the kernel probes for and sets up all hardware devices, such as network interfaces, storage controllers, and graphics cards.
  5. Mounting the Initial RAM Disk (initrd or initramfs):
    • The initrd or initramfs contains essential drivers and scripts needed to mount the real root file system.
    • The kernel uses this temporary root file system to load additional drivers that may be required to access the root file system, especially for systems using advanced storage setups like LVM or RAID.
  6. Handing Over to Init/Systemd:
    • After the kernel finishes its initialization, it hands control over to the init system (in modern Linux distributions, this is typically systemd).
    • The init system is responsible for starting user-space processes, such as services, daemons, and the login system.
    • At this point, the actual root file system is mounted, and the system is ready for user interaction.

Example: Understanding Kernel Loading through a Practical Scenario

Imagine you have a laptop that uses a solid-state drive (SSD) with an encrypted file system. When you power on the laptop:

  1. BIOS/UEFI starts and checks the hardware.
  2. GRUB loads, presenting you with the option to boot into Linux.
  3. You select Linux, and GRUB loads the compressed kernel and initrd into memory.
  4. The kernel is decompressed, and it begins detecting your SSD and other hardware components.
  5. Since the SSD is encrypted, the kernel uses the initrd to load the necessary encryption drivers.
  6. The kernel then mounts the real root file system and hands control to systemd.
  7. systemd starts services like networking, display managers, etc., and finally, the login screen appears.

Key Concepts:

  • Kernel Image (vmlinuz): The compressed version of the Linux kernel.
  • Bootloader (GRUB): The software that loads the kernel into memory.
  • Initrd/Initramfs: A temporary root file system used during the early boot process.
  • Systemd/Init: The first process started by the kernel to manage system services and processes.

Why Kernel Loading is Important:

  • Hardware Management: The kernel is responsible for detecting and initializing all hardware components, ensuring that devices like your hard drive, keyboard, and network card are ready for use.
  • Security: The kernel handles critical security tasks, such as enforcing access controls and managing encryption (via initrd).
  • System Stability: Proper kernel loading ensures that the operating system is stable and can efficiently manage resources.