Course contentsShow
← Linux
Lesson 262 of 1,8193. The Filesystem Hierarchy and POSIX StandardsFree lesson

Booting and the Initial Ramdisk

Analyze how the kernel loads the root filesystem during the early stages of the boot process.

In this lesson, you will learn how the Linux kernel uses an initial RAM disk to bridge the gap between starting up and accessing your actual hard drive.

The Chicken-and-Egg Boot Problem

When you turn on your computer, the kernel starts up, but it faces a difficult dilemma: it needs to load drivers to "talk" to your storage drives (like an SSD or hard drive), but those drivers are stored inside files on those very same drives. How can it read the files if it doesn't have the drivers loaded yet?

This is where the Initial Ramdisk (often called initrd or initramfs) comes into play. Think of it as a tiny, temporary "emergency room" filesystem that the bootloader loads into your computer's RAM alongside the kernel.

The Two-Stage Loading Process

Because the kernel cannot mount your main "Root Partition" (which we discussed in the previous lesson) immediately, it follows a two-stage approach:

  1. Stage 1 (The Ramdisk): The kernel mounts the initrd as a temporary root filesystem. Because this exists entirely in RAM, it doesn't need drivers to "access" it—it’s already there. This tiny environment contains just enough tools and kernel modules to initialize your hardware, such as the drivers needed to talk to your SATA or NVMe controller.
  2. Stage 2 (The Real Root): Once the initrd scripts load the necessary drivers, the system finds your actual hard drive. It then performs a "pivot_root" operation, effectively throwing away the temporary RAM disk and mounting your real / (root) directory from your disk.

You can see the result of this transition if you look at your own system logs. The kernel reports the mounting process like this:

[    0.912345] Freeing unused kernel memory: 1024K
[    0.923456] Attempting to mount /dev/sda1 as root...
[    0.934567] Mounting real root filesystem.

By using this temporary storage in memory, Linux stays flexible—you don't need to bake every single possible driver into the kernel itself, which would make the kernel file massive and slow to load.

Key Takeaway: The Initial Ramdisk acts as a temporary, memory-based bridge that provides the kernel with the necessary drivers to mount the permanent filesystem on your hard drive.