mkinitcpio
Create initial RAM disk environment
TLDR
Perform a dry run (print what would be done without actually doing it)
Generate ramdisk environments based on all existing presets (used to regenerate all the initramfs images after a change in /etc/mkinitcpio.conf)
Generate a ramdisk environment based on the linux preset
Generate a ramdisk environment based on the linux-lts preset
Generate an initramfs image using an alternative configuration file
Generate an initramfs image for a kernel other than the one currently running (the installed kernel releases can be found in /usr/lib/modules/)
List all available hooks
Display help for a specific hook
SYNOPSIS
mkinitcpio [options] [image]
PARAMETERS
-c
Use
-d
Use
-g
Generate initramfs image.
-k
Use kernel version
-m
Add kernel module
-H
Add hook
-p
Use preset
-r
Use modules from
-S
Set the kernel version string.
-t
Print what would be done to standard output.
-u
Update all initramfs images for the current kernel.
-A
Update initramfs image for kernel
-v
Be verbose.
-V
Print version and exit.
-X
Disable auto-compression.
-h
Show help.
DESCRIPTION
mkinitcpio is a command-line tool used to create initial ramdisk environments, also known as initrd images, which are necessary for booting a Linux system.
An initrd is a small filesystem that is loaded into memory by the bootloader before the root filesystem is mounted. It contains essential device drivers and utilities that are needed to mount the root filesystem and complete the boot process.
mkinitcpio reads configuration files located in /etc/mkinitcpio.conf and /etc/mkinitcpio.d/ to determine which modules and hooks to include in the initrd image. The modules are kernel modules providing hardware support, filesystems etc. while the hooks are shell scripts doing a variety of tasks at different stages of the initrd creation, such as compressing the image, adding files or generating configuration files.
mkinitcpio allows for highly customized initrd images, enabling users to tailor the boot process to their specific hardware and software configurations. This customization is important for systems with non-standard hardware or complex boot requirements, such as encrypted root partitions or custom filesystem configurations.
The output is a cpio archive which optionally can be compressed (default compression method is gzip).
CAVEATS
Using incorrect configurations with mkinitcpio can render your system unbootable. Ensure you understand the implications of changes made to mkinitcpio.conf or custom hooks.
CONFIGURATION FILES
/etc/mkinitcpio.conf: Main configuration file for mkinitcpio.
/etc/mkinitcpio.d/*.preset: Configuration presets defining kernel versions and image filenames.
HOOKS
Hooks are shell scripts which are executed at different stages of initrd creation. They can perform actions such as copying files, generating configuration files, or setting up networking. They are placed under /usr/lib/initcpio/hooks/.
HISTORY
mkinitcpio has evolved as a replacement for older initrd generation tools. It was designed to be more flexible and configurable, allowing for better adaptation to modern Linux systems with diverse hardware configurations. It is widely used in Arch Linux and other distributions to generate initrd images.