mkinitcpio” is a tool in Arch Linux used to generate an initial RAM disk (initrd or initramfs) image. This image is used to boot the Linux kernel and prepare the environment for the main operating system. The initrd image contains all the necessary files, drivers, and tools needed to mount the root file system and start the main operating system.
The “mkinitcpio” command takes one or more presets as input, which define the configuration of the initrd image. The presets specify the kernel modules to be included, the files to be copied, and the hooks to be executed during the boot process. The tool then creates the initrd image and saves it to a specified location.
The initrd image is loaded into memory by the boot loader and executed before the main operating system starts. It performs various tasks, such as setting up the device tree, loading necessary kernel modules, and mounting the root file system. The initrd image is an important component of the boot process and plays a crucial role in ensuring the stability and compatibility of the system.
If you encounter the below error while running the command mkinitcpio:
mkinitcpio: command not found
you may try installing the below package in ArchLinux distribution:
# pacman -S mkinitcpio
mkinitcpio Command Examples
1. Perform a dry run (print what would be done without actually doing it):
2. Generate a ramdisk environment based on the `linux` preset:
# mkinitcpio --preset linux
3. Generate a ramdisk environment based on the `linux-lts` preset:
# mkinitcpio --preset linux-lts
4. Generate ramdisk environments based on all existing presets (used to regenerate all the initramfs images after a change in `/etc/mkinitcpio.conf`):
# mkinitcpio --allpresets
5. Generate an initramfs image using an alternative configuration file:
# mkinitcpio --config path/to/mkinitcpio.conf --generate path/to/initramfs.img
6. Generate an initramfs image for a kernel other than the one currently running (the installed kernel releases can be found in `/usr/lib/modules/`):
# mkinitcpio --kernel kernel_version --generate path/to/initramfs.img
7. List all available hooks:
# mkinitcpio --listhooks
8. Display help for a specific hook:
# mkinitcpio --hookhelp hook_name