$linuxjunkies
>

mkinitcpio(8)

Create an initial ramdisk (initramfs) image for the Linux kernel.

UbuntuDebianFedoraArch

Synopsis

mkinitcpio [OPTION]... [-o OUTPUT] [KERNELVERSION]

Description

mkinitcpio creates an initial ramdisk (initramfs) image containing the kernel modules, firmware, and hooks needed to mount the root filesystem and boot the system. It reads configuration from /etc/mkinitcpio.conf and supports custom presets for different boot scenarios.

The initramfs is loaded by the bootloader before the kernel mounts the real root filesystem. It typically handles device detection, decryption, LVM setup, and RAID initialization.

Common options

FlagWhat it does
-o, --output FILEwrite the image to FILE instead of default location
-c, --config FILEuse FILE instead of /etc/mkinitcpio.conf
-k, --kernel VERSIONbuild initramfs for kernel VERSION (default: uname -r)
-p, --preset PRESETbuild initramfs from preset in /etc/mkinitcpio.d/PRESET.preset
-L, --listhookslist all available hooks
-M, --listmoduleslist all available modules for current kernel
-H, --hookhelp HOOKshow help text for the specified hook
-n, --nocolordisable colored output
-S, --skiphooks HOOKskip specified hooks (comma-separated)
-A, --add HOOKadd additional hook to the image
-v, --verboseenable verbose output
-t, --tmpdir DIRuse DIR for temporary files instead of /tmp

Examples

Build initramfs for all presets defined in /etc/mkinitcpio.d/linux.preset

mkinitcpio -p linux

Create initramfs for specific kernel version and save to custom location

mkinitcpio -k 6.1.0-arch1-1 -o /boot/initramfs-custom.img

List all available hooks (like filesystems, keyboard, lvm2, encrypt, etc.)

mkinitcpio -L

Show help and documentation for the encrypt hook

mkinitcpio -H encrypt

Create initramfs using alternate configuration file

mkinitcpio -c /etc/mkinitcpio-fallback.conf -o /boot/initramfs-fallback.img

Build initramfs skipping fsck hook and adding sd-vconsole hook

mkinitcpio -S fsck -A sd-vconsole

Build with verbose output to see what modules and hooks are included

mkinitcpio -v -o /boot/initramfs-test.img

Related commands