MKTIRFS(8)
π MKTIRFS π
okay so bestie, welcome to mktirfs β that's MKTIRFS from section 8 of the tiny-initramfs manual. it's a tool. it makes initramfs images. it's tiny. it's fast. it's iconic. let's go π¦
β¨ SYNOPSIS β¨
mktirfs -o outputfile [options] [kernel-version]
πΈ DESCRIPTION πΈ
so the mktirfs script builds you an initramfs image that has the tiny-initramfs init binary inside it. this is not a casual little baby tool for beginners ngl β invoking mktirfs is meant for expert users who want greater control over their initramfs image. typically it gets called from update-tirfs. π
images made with this utility are designed to be very small and fast, which makes them ideal when the space available in the boot loader is very low. and like, if no modules and no microcode updates are included in the image, it'll be less than 16 kiB in size. yes. sixteen. kilobytes. she's petite. π
but the trade-off is real: this comes at the cost of runtime flexibility and the supported features of the generated images. so it is not meant to replace traditional initramfs implementations (like dracut or initramfs-tools) in the generic case β it's a lean alternative for common use cases. know the difference, bestie. π
please read /usr/share/doc/tiny-initramfs-core/README.md for an overview of the use cases it was designed for and the features it supports. fr fr go read it.
π OPTIONS π
-o,--output=imagefileβ where to store the resulting initramfs image. this option must be specified. no output, no image, no slay. π«Ά-m,--auto-modules=yes/noβ whether to try to automatically detect which modules are required to mount the/and/usrfile systems and include them in the resulting initramfs image.
defaults to yes.
--include-modules=mod1,mod2,...β which modules to directly add to the initramfs image, regardless of the setting for-m. dependencies of the modules will be resolved bymktirfs. this option is useful if the required modules are not properly detected, or if you want to create an image for a different computer. π
by default this list is empty.
-M,--microcode=generic/yes/noβ whether to prepend CPU microcode updates (if installed) to the initramfs image. microcode updates may be prepended to the initramfs, and the kernel will automatically load them at boot time. (this requires theCONFIG_MICROCODE_EARLYkernel option in conjunction with eitherCONFIG_MICROCODE_INTELorCONFIG_MICROCODE_AMDcompiled into the kernel.) the microcode updates can be found in the (non-free) packagesintel-microcodeandamd64-microcode.
if the generic setting is specified, all installed microcode updates will be added to the initramfs image; if yes is specified only the update for the processor on which mktirfs was run on will be included.
microcode updates not being installed (or no microcode updates for the specific processor being available) is not considered to be an error and mktirfs will proceed regardless. she's chill like that.
defaults to yes. is only supported on x86 processors and will be ignored otherwise.
-d,--debug=yes/noβ if set toyes, this option will install a (larger) version of the init binary into the initramfs image that prints additional debug messages while booting, and waits 5 seconds after mounting the root file system before handing control over to the system's init process. this allows the administrator to debug boot problems with initramfs images. π
defaults to no.
kernel-versionβ the kernel version for which to generate the initramfs image. this is only relevant if modules are to be added (either automatically or manually) to the initramfs image. if no modules are included in the initramfs image, the resulting image may be used with any kernel that has the drivers required to mount the root filesystem built in. β
by default the version returned by uname -r is used.
π CONFIGURATION π
except for -o and the kernel version, defaults for all the options may be specified in a configuration file at /etc/tiny-initramfs/tiny-initramfs.conf. this file does not exist by default, but an example version may be found in /usr/share/doc/tiny-initramfs-core/tiny-initramfs.conf.example. π
any settings that update-tirfs is to use when calling mktirfs should be set in that configuration file. periodt.
π§ HOOKS π§
there are no hooks within the initramfs itself β the init binary is a very small statically linked C program. cute, self-contained, no drama.
however, mktirfs supports hooks when it comes to creating the initramfs image. the overall logic of mktirfs is as follows:
- Determine the list of kernel module names (without dependencies) to be added to the initramfs.
- Run start hooks.
- Copy init executable, add directories, copy microcode.
- Run middle hooks.
- Determine dependencies of modules, add all module files.
- Create initramfs image.
- Run end hooks.
- Copy image to its final location.
mktirfs looks for hooks in the /usr/share/tiny-initramfs/hooks.type and /etc/tiny-initramfs/hooks.type directories, e.g. /etc/tiny-initramfs/hooks.start. the directory in /usr/share is the domain of other Debian packages, while the directory in /etc is designated for the administrator of the system. hooks will be called in alphabetical order, and hooks in /etc will override hooks in /usr/share. run-parts(8) is used to determine what hooks should be considered. π¦
hooks are sourced, not executed, so calling exit in a hook aborts the creation of the initramfs image. it also allows the hooks to modify variables that will be interpreted later. main character behaviour, honestly.
note thatmktirfsuses/bin/shas the interpreter, which isdash(1)by default on Debian systems, so not allbash(1)functionality is available within hooks. don't come in expecting bash-isms, bestie. π
the following shell variables are available from within hooks:
VERSIONβ the kernel version for which the initramfs is built.DEBUGβ the value of the-dcommand line option.AUTO_MODULESβ the value of the-mcommand line option.INCLUDE_MODULESβ the value of the--include-modulescommand line option.MICROCODEβ the value of the-Mcommand line option.OUTPUTβ the value of the-ocommand line option. this should not be used, asmktirfsshould only replace it if image creation was successful. π«Άimage_nameβ the temporary file name of the initramfs image that is to be created. will be empty except for end hooks.initramfs_dirβ the temporary directory that contains the contents of the initramfs image. any directories and files placed here will be part of the final initramfs image.early_dirβ the temporary directory that contains the contents of the early part of the initramfs image. this is used for storing microcode updates for the CPU, but the kernel also supports other updates here, e.g. updates to ACPI tables. if this directory is non-empty after the middle hooks, an uncompressed CPIO image of this directory will be prepended to the final initramfs image bymktirfs. if it is empty (no microcode, no other early updates), the initramfs image will just contain the compressed CPIO archive of theinitramfs_dirdirectory.modules_listβ the name of the temporary file that contains the list of module names that will be added to the initramfs image (one line per module name). after the middle hooks all modules, together with their dependencies, will be added to the initramfs image, any module options defined in/etc/modprobe.dfor those modules will also be included.
π₯ EXAMPLE π₯
create a new initramfs image for the current kernel:
mktirfs -o /boot/initrd.img.tiny-$(uname -r)
create a new initramfs image for a specific kernel:
mktirfs -o /boot/initrd.img.tiny-4.2.0 4.2.0
π FILES π
/etc/tiny-initramfs/tiny-initramfs.confβ if present, values in there will be used as defaults for the command line arguments ofmktirfs./usr/share/doc/tiny-initramfs-core/tiny-initramfs.conf.exampleβ an example configuration file that may be copied to the above location./usr/share/tiny-initramfs/hooks.start/usr/share/tiny-initramfs/hooks.middle/usr/share/tiny-initramfs/hooks.endβ if present, hooks created by other Debian packages will be sourced from these directories./etc/tiny-initramfs/hooks.start/etc/tiny-initramfs/hooks.middle/etc/tiny-initramfs/hooks.endβ if present, hooks created by the system administrator will be sourced from these directories. hooks will replace those with the same name as hooks in/usr/share.
π SEE ALSO π
π AUTHORS π
- Christian Seiler
<christian@iwakd.de>
and that's the whole page, bestie β from the tiny-initramfs Manual, dated Jan 2016. go make a 16 kiB image and text me when it boots. mwah π β¨
π¦ where this page comes from
- debian bookworm: tiny-initramfs-core 0.1-5+b13 Β· GLP-3+
- debian trixie: tiny-initramfs-core 0.1-6.1 Β· GLP-3+
- ubuntu jammy: tiny-initramfs-core 0.1-5 Β· GLP-3+
- ubuntu noble: tiny-initramfs-core 0.1-5.1 Β· GLP-3+
- ubuntu questing: tiny-initramfs-core 0.1-6.1
- ubuntu resolute: tiny-initramfs-core 0.1-6.1build1 Β· GLP-3+
- ubuntu stonking: tiny-initramfs-core 0.1-7 Β· GLP-3+
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms