Skip to main content

initrd (initialisation RAM disk)

What isare initramfs and initrd?

initrd (initialisationand RAMinitramfs disk) is essentially a set of instructions used to load the kernel. initrd is stored temporarily in system memory whilst the kernel is loaded.

initrd is aare temporary filesystemroot image that'sfilesystems loaded into memory during the linuxearly Linux boot process,process. Their purpose is to provide the filesystemkernel containswith anythe necessary drivers, modules, orand configurationscripts that are required in orderneeded to initialize hardware and mount the real root fs.filesystem before the full operating system loads.

What is initrd (Initial RAM Disk)?

A legacy method using a compressed block device image containing a temporary filesystem. The kernel mounts this image as a virtual disk early in the boot process to access drivers and scripts needed for hardware initialization and mounting the real root filesystem.

What is initramfs (Initial RAM Filesystem)

A modern method using a compressed cpio archive that the kernel unpacks directly into a RAM-based filesystem (tmpfs). It serves the same purpose as initrd but is simpler, faster, and more flexible, becoming the standard approach on most current Linux systems.


Where are initrd files stored?

/boot

The initrd file will be prefaced with just that - initrd:

initrd.img-5.15.0-106-generic

To check which initrd file is currently being treated as the primary one (which will be loaded on boot), you can check the symlinks (in /boot), as below:

initrd.img -> initrd.img-5.15.0-107-generic

initrd.img.old -> initrd.img-5.15.0-106-generic


Creating an initrd file (mkinitrd)

mkinitrd is a command used for creating or modifying an initrd. mkinitrd is typically used on much older systems. Modern systems have tools in place to automatically detect the modules required for the ram disk.

mkinitrd [options] initrdimagename kernel.version
mkinitrd -f /boot/initrd-$(uname -r).img $(uname -r)

Option Function
--preload=modulename Load a module in the initrd image before the loading of other modules.
--with=modulename Load a module in the initrd image after the loading of other modules.
-f Overwrite an existing initrd image file.
-nocompress Disable the compression of the initrd image.