The Evolution of Linux Early Boot: initrd to initramfs

Explaining why Linux made the switch from initrd to the newer initramfs


While fixing some boot-related issues on my system, one thing caught my eye: Linux still uses the legacy initrd name as a pointer to the more modern initial file system, the initramfs introduced in 2005. I thought it would be a good idea to explain why Linux made the switch to initramfs. In this post, I’ll try to compare both these systems.

What is an init file system, anyway?

An init file system is a temporary file system that is used by the Linux kernel during the boot process to load the essential kernel modules/drivers and scripts required to mount the actual root file system and start the system.

The bootloader loads both the kernel (vmlinuz) and the initial file system into the RAM (located at /boot) and then passes a pointer to the kernel to point to the initial file system. The first thing that the kernel does after the handover from the bootloader to the kernel is complete is to uncompress itself (vmlinuz) and then start executing the instructions in the init file system.

Why does Linux require an initial file system?

A question can arise: Why is it even required? And this is the core paradox or the “Chicken and egg problem”. To continue the boot process, the root file system needs to be mounted. To mount the root file system, the kernel needs access to the disks, and to read the disk, disk drivers are required, which are stored on the disk the kernel is trying to access.

The kernel is not supplied with everything already baked into it directly. Doing so would make the code difficult to maintain and the boot process slower. And because there can be different types of hardware, providing support for each type of hardware is practically not possible. Therefore, a separate initial root file system is provided with all the required ingredients.

What is inside the initial file system?

The initial file system packs everything that the kernel requires in a single source, speeding the boot process. The following are the resources that such an initial file system supplies:

  • Kernel modules for:
    • Disk controllers
    • filesystems
    • crypto
  • Userspace tools
    • mount
    • cryptsetup
    • lvm
    • udev
  • logic to decide what the real root is

Running instructions in the initial file system

Once the kernel comes into control, it starts to run instructions from the initial file system, loads the required kernel modules, reads the disk, locates the real root file system, and then switches from the initial file system to the real file system. After the switch is made to the actual root file system, the initial file system is discarded, and the real root file system is in control.

Comparing initrd with initramfs

Enough talking about the initial file system, and providing a high-level working, now let’s dig a little deeper and understand how these two work differently and make a comparison.

Aspectinitrd (Initial RAM Disk)initramfs (Initial RAM Filesystem)
EraLinux 2.2 / 2.4 (legacy)Linux 2.6+ (current)
PurposeTemporary root filesystem during early bootSame purpose, redesigned
On-disk formatCompressed block device imageCompressed cpio archive
Internal FSext2 (usually)None (extracted into tmpfs)
How kernel uses itCreates RAM disk and mounts it as /Unpacks directly into RAM
Requires mountYesNo
Root FS typeramdisk block devicetmpfs
SizeFixed at creation timeDynamic (grows as needed)
Boot script/linuxrc/init
Root switch methodpivot_rootswitch_root
Device handlingStatic /dev nodesDynamic (usually udev)
Module loadinginsmod (often manual)modprobe
Userspace toolsVery minimalMore flexible
Error handlingLimitedMuch better
Kernel support statusObsoleteActively supported
Still used todayNo (emulated only)Yes (standard)
initrd V/s initramfs

Why Linux replaced initrd with initramfs

Share this post with your friends on:
Mohit Tomar
Mohit Tomar

A nerd with a passion for computer security, AI/ML, and all things Linux. I enjoy diving deep into servers, coding, and the latest in cybersecurity. Always curious and ready to tackle complex problems with a geeky flair.

Articles: 13

Leave a Reply

Your email address will not be published. Required fields are marked *