mkinitramfs
Create initial RAM disk/filesystem image
SYNOPSIS
mkinitramfs [-k version] [-c compression] [-d directory] [-m module] [-o outfile] [-u] [-v] [-h]
PARAMETERS
-k version
Specify the kernel version. Defaults to the running kernel.
-c compression
Specify the compression method to use. Common options are gzip, bzip2, lzma, xz, and lz4. Defaults to gzip.
-d directory
Specify the directory to use as the root of the initramfs. This allows you to use your own directory structure.
-m module
Add a specific module to the initramfs. This option can be used multiple times.
-o outfile
Specify the output file name. Defaults to /boot/initrd.img-version.
-u
Update an existing initramfs image.
-v
Enable verbose output.
-h
Show help message.
DESCRIPTION
The mkinitramfs command is used to create an initial RAM disk (initramfs) image. The initramfs is a gzipped cpio archive that the kernel loads into memory during the early boot process. This allows the system to mount the root filesystem and proceed with the normal boot sequence. It typically contains essential modules, drivers, and scripts needed to access the root partition (e.g., for LVM, RAID, or encrypted partitions).
The image is placed in /boot by default. mkinitramfs is often automatically run after kernel upgrades or when installing new kernel modules to ensure the initramfs contains the necessary drivers for the new kernel. The specific contents and configuration options of the initramfs are highly dependent on the distribution and its configuration files.
CAVEATS
The exact behavior and available options of mkinitramfs can vary significantly between different Linux distributions. Some distributions may provide wrapper scripts or alternative tools for managing initramfs images. Configuration files (e.g., /etc/initramfs-tools/initramfs.conf on Debian-based systems) also heavily influence the contents of the created image. Incorrectly configured initramfs images can render the system unbootable.
CONFIGURATION FILES
Many distributions use configuration files (e.g., /etc/initramfs-tools/initramfs.conf on Debian-based systems) to control the behavior of mkinitramfs. These files allow you to specify modules to include, scripts to run during boot, and other settings.
BOOT PROCESS
The initramfs is loaded by the bootloader (e.g., GRUB) and executed by the kernel. It typically mounts the root filesystem, loads necessary drivers, and performs other initialization tasks before handing over control to the init process (e.g., systemd or SysVinit).
HISTORY
The concept of an initramfs evolved from the earlier initrd (initial RAM disk). The initrd used a block device backed by RAM, while the initramfs uses a gzipped cpio archive loaded directly into memory. This change offered improved performance and flexibility. The `mkinitramfs` command itself has evolved over time, with variations across different distributions. Its primary purpose has remained consistent: to provide a minimal environment for the kernel to initialize the system before mounting the root filesystem.
SEE ALSO
update-initramfs(8), dracut(8), mkinitrd(8)