mkrecov is a utility for manipulating Linux initramfs images. It provides a streamlined interface for patching initramfs archives, primarily for system recovery and customization.
A tool to patch initramfs images for recovery or customization.
mkrecov [options]
Options:
-c, --config PATH: Specify a configuration file.-i, --input PATH: Define the inputinitramfsimage path.-o, --output PATH: Set the output path for the modifiedinitramfsimage.-f, --force: Automatically select the firstinitramfsif multiple are found.-h, --help: Display usage information.-v, --version: Show version information.
Requires a C++17 compiler (e.g., g++) and make.
make -j$(nproc)The executable will be in build/mkrecov.
To install mkrecov to /usr/local/bin/ (DIST/bin):
sudo make installTo remove mkrecov from /usr/local/bin/ (DIST/bin):
sudo make uninstallThe configuration file format is TOML-like. An example:
[compression]
type = "gzip"
level = 6
# a comment
[output]
path = "/boot/initramfs-recovery.img"
[files]
recovery_tools = "/usr/local/bin/recovery_menu -> /usr/bin/recovery_menu"
custom_config = "./configs/recovery.conf -> /etc/recovery.conf"
ssh_keys = "/root/.ssh/authorized_keys -> /root/.ssh/authorized_keys"
[binaries]
vim = "/usr/bin/vim -> /usr/bin/vim"
ssh = "/usr/bin/ssh -> /usr/bin/ssh"
cryptsetup = "/usr/bin/cryptsetup -> /usr/bin/cryptsetup"
[hooks]
pre_init = "/usr/bin/recovery_menu"
pre_mountroot = "/usr/bin/check_root"
post_mountroot = "/usr/bin/fix_permissions"There are several options in the configuration file, which includes:
Supported keys: type, level
Specifies the type of compression. Supported values: none, gzip, bzip2, xz, zstd, lz4. Default: gzip
Specifies the level of compression. Default: 6
Supported keys: path
Specifies the path of the output patched initramfs image.
Specifies the files to copy.
Format: human-readable-thing-that-is-ignored = "path/to/source -> path/to/destination"
Specifies the binaries to copy alongside their dynamic libraries.
Format: Same as files.
Supported keys: pre_init, pre_mountessentials, post_mountessentials, pre_mountroot, post_mountroot, pre_switchroot.
Executes a file after the shebang.
Executes a file before mounting essentials (/dev, /sys and /proc).
Executes a file after mounting essentials (/dev, /sys and /proc).
Executes a file before mounting the new root.
Executes a file after mounting the new root.
Executes a file before switching to the new root.