MKINITRAMFS(8) System Manager's Manual MKINITRAMFS(8)

mkinitramfscreate an initial ramdisk environment

mkinitramfs [-fhv] [-D helperfile] [-H hooksdir] [-I initfile] [-c conffile] [-k kernelversion] [-m modulesdir] [-o initramfs]

The mkinitramfs utility creates an initial ramdisk environment for booting the Linux kernel. The initial ramdisk is in essence a very small environment (early userspace) which loads various kernel modules and sets up necessary things before handing over control to init. This makes it possible to have, for example, encrypted root file systems and root file systems on a software RAID array. mkinitramfs can be extended with custom hooks.

The options are as follows:

helperfile, --helper=helperfile
Specify an alternate device helper file instead of the default /usr/share/mkinitramfs/device-helper.
hooksdir, --hooks=hooksdir
Specify additional directory for hooks. By default, mkinitramfs uses /usr/share/mkinitramfs/hooks and /etc/mkinitramfs/hooks.
initfile, --init=initfile
Specify an alternate init script instead of the default /usr/share/mkinitramfs/init.
conffile, --config=
Specify an alternate configuration file instead of the default /etc/mkinitramfs/config.
, --force
Forcefully overwrite initramfs image.
kernelversion, --kernel=kernelversion
Specify kernel version instead of using the version of current running kernel (“uname -r”). Useful for bootstrapping future system with modular kernel.
modulesdir, --modules=modulesdir
Specify an alternate directory where where kernel modules stored instead of the default /lib/modules.

This option has no effect if or were enabled in configuration file.

initramfs, --output=initramfs
Specify an alternate output file where initramfs image will be stored instead of the default mkinitramfs-"kernelversion" directory, created in TMPDIR or (if unavailable) in /tmp directory.
, --version
Print version and exit.
, --help
Print help and exit.

mkinitramfs uses the TMPDIR environment variable. If set, it uses subdirectories in the given directory to create its temporary working directories. Else it uses /tmp as default value for that purpose. The given directory should be on a filesystem which allows the execution of files stored there, i.e. should not be mounted with the mount option.

/etc/mkinitramfs/config
The default configuration file. See mkinitramfs.config(5) for a description of the available configuration parameters.

/usr/share/mkinitramfs/hooks/,
 
/etc/mkinitramfs/hooks/
Hooks directories.

/usr/share/mkinitramfs/init
Init.

/usr/share/mkinitramfs/device-helper
Device-helper.

Create an initramfs for current running kernel:

mkinitramfs -o /tmp/initramfs-`uname -r`.img

Create an initramfs for specific kernel:

mkinitramfs -o /tmp/initramfs-5.4.224.img -k 5.4.224

Debug initramfs creation (check out written logfile):

sh -x `which mkinitramfs` -o /tmp/initramfs-`uname -r` 2>/tmp/log

If you have modular kernel and you use busybox' modprobe to handle modules, you must note that busybox' modprobe doesn't have ability to install soft dependencies of modules (i.e. modules.softdep). You must install them yourself using hooks. See mkinitramfs.hooks(7) how to do it.

mkinitramfs.config(5), mkinitramfs.cmdline(7), mkinitramfs.hooks(7)

Kernel subsystem documentation: Ramfs, rootfs and initramfs.

The Linux kernel user's and administrator's guide: Using the initial RAM disk (initrd).

The original implementation was done by illiliti <illiliti@protonmail.com> as “tinyramfs” tool.

This implementation was re-worked for Zeppe-Lin by Alexandr Savca <alexandr.savca89@gmail.com>.

May 22, 2023 Zeppe-Lin