Skip to content

Obsidian-OS/mkrecov

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mkrecov

mkrecov is a utility for manipulating Linux initramfs images. It provides a streamlined interface for patching initramfs archives, primarily for system recovery and customization.

TL;DR

A tool to patch initramfs images for recovery or customization.

Usage

mkrecov [options]

Options:

  • -c, --config PATH: Specify a configuration file.
  • -i, --input PATH: Define the input initramfs image path.
  • -o, --output PATH: Set the output path for the modified initramfs image.
  • -f, --force: Automatically select the first initramfs if multiple are found.
  • -h, --help: Display usage information.
  • -v, --version: Show version information.

Building

Requires a C++17 compiler (e.g., g++) and make.

make -j$(nproc)

The executable will be in build/mkrecov.

Installation

To install mkrecov to /usr/local/bin/ (DIST/bin):

sudo make install

Uninstallation

To remove mkrecov from /usr/local/bin/ (DIST/bin):

sudo make uninstall

Config file format

The 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"

Options

There are several options in the configuration file, which includes:

compression

Supported keys: type, level

type

Specifies the type of compression. Supported values: none, gzip, bzip2, xz, zstd, lz4. Default: gzip

level

Specifies the level of compression. Default: 6


output

Supported keys: path

path

Specifies the path of the output patched initramfs image.


files

Specifies the files to copy.

*

Format: human-readable-thing-that-is-ignored = "path/to/source -> path/to/destination"


binaries

Specifies the binaries to copy alongside their dynamic libraries.

*

Format: Same as files.


hooks

Supported keys: pre_init, pre_mountessentials, post_mountessentials, pre_mountroot, post_mountroot, pre_switchroot.

pre_init

Executes a file after the shebang.

pre_mountessentials

Executes a file before mounting essentials (/dev, /sys and /proc).

post_mountessentials

Executes a file after mounting essentials (/dev, /sys and /proc).

pre_mountroot

Executes a file before mounting the new root.

post_mountroot

Executes a file after mounting the new root.

pre_switchroot

Executes a file before switching to the new root.

About

A utility for manipulating Linux initramfs images.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published