mbuto - Host-agnostic initramfs image builder for lightweight virtual machines
mbuto [OPTIONS] [ADD_ON]...
mbuto (Minimal Builder Using Terse Options) builds Linux initramfs images suitable for lightweight virtual machine environments, without relying on distribution-specific tools (such as dracut(8), debootstrap(8), mkinitramfs(8), etc.) or containerised environments.
Programs are sourced from the host, together with required dynamic libraries. Kernel modules, links, and initial device nodes are configured manually. A convenience support for distribution packages is supplied, with the sole function of extracting packages, ignoring dependencies, without an actual installation process.
For pre-defined profiles covering common tasks and use cases, see PROFILES.
ADD_ON can be a list of additional programs, kernel module names, device nodes, or generic files. The type is auto-detected.
-c gzip|lz4|lzma|auto|none
Compression method for CPIO file: auto picks the method resulting in the shortest decompression time, measured on the output image (average of five runs). Default is none.
-d |
Do not strip binary objects. By default, debugging information is stripped from copied binary objects. |
-f path
Path for initramfs output. By default, a temporary file is created.
If the initramfs image already exists, add the given ADD_ON to it.
-k version
Installed kernel version to source associated modules from. By default, the currently running kernel version (as reported by uname(1)) is used.
-m path
Relative root directory for /lib/modules. Default: /
-p profile
Profile for add-ons, specific init script and format of printed command result. Can be one of base, bash, kata, kata_debug, passt, kselftests. See PROFILES below for further details.
-s script|-
Path to fix-up script to run before init, which can be used to replace the one defined by the profile. - disables the pre-init fix-up script.
-v |
Enable verbose operation. |
|||
-h |
Display help message with usage and options. |
Environmental variables can be used to replace:
PROGS |
Base programs, to be included in the image, defined by the profile. |
LIBS_DLOPEN Additional libraries, not directly linked from programs, typically loaded via dlopen(3) by matching libraries, in the form:
MATCHING_LIBRARY ADDITIONAL_LIBRARY
KMODS |
Base kernel modules, defined by the profile. | ||
NODES |
Device nodes, copied from host if just the name is given, and created otherwise if in the form: |
NAME,TYPE,MAJOR,MINOR
LINKS |
Link to programs by name, as space-separated pairs of: |
PROGRAM PATH
DIRS |
List of initial set of empty directories | ||
COPIES |
Lists of paths to be copied, recursively, preserving attributes and parents. |
Profiles define sets of base programs, links, kernel modules, and pre-init scripts to cover common use cases. These profiles are currently available:
base |
The bare minimum to start an interactive shell. | ||
bash |
Start bash with a few kernel modules and tools to enable basic filesystem usage and networking configuration. | ||
kata |
Creates a guest image suitable for usage with Kata Containers (https://katacontainers.io): source kata-agent and perform cgroup setup in pre-init. |
kata_debug
Creates a guest image intented to debug issues with Kata Containers (https://katacontainers.io): include some more utilities on top of the ones sourced by the kata profile, and starts an interactive shell before starting kata-agent.
passt |
Creates a guest image used to run the test suite of passt(1) (https://passt.top), including a number of networking utilities among others. |
kselftests
Creates a guest image including a set of Linux kernel selftests (https://kselftest.wiki.kernel.org/) together with the tools needed to run them.
Modules and test programs are selected depending on the given test collections, and, for convenience, this profile also triggers installation of modules and test programs to temporary directories.
The following
sub-options are provided:
-C collection
Select a collection of tests to run. Collections are defined by the set of targets in tools/testing/selftests/Makefile of the Linux kernel tree.
-T collection:test
Select a specific test to run, within a collection. Available tests are listed by TEST_PROGS variables in the Makefile of a test subdirectory.
Build a base image as temporary file
$ mbuto
Applying profile base
Creating image: /tmp/tmp.hbRUmHpR3a
Size: bin 353k lib 4.0M kmod 213k total 4.6M compressed 4.5M
/tmp/tmp.hbRUmHpR3a
Build a base image including grep and needed libraries
$ mbuto grep
Applying profile base
Creating image: /tmp/tmp.RXC8K7altF
Size: bin 562k lib 4.0M kmod 213k total 4.8M compressed 4.7M
/tmp/tmp.RXC8K7altF
Run an interactive shell with qemu(1)
$ kvm -kernel
/boot/vmlinuz-$(uname -r) -initrd $(mbuto) \
-nodefaults -nographic -append console=ttyS0 -serial
stdio
Run the timens kselftests collection
$ cd linux
$ kvm -kernel arch/x86/boot/bzImage \
-initrd $(mbuto -p kselftests -C timens) \
-nodefaults -nographic -append console=ttyS0 -serial
stdio
Run the rtcpie kselftest from the timers collection
$ cd linux
$ mbuto -p kselftests -T timers.rtcpie -f test.img
$ kvm -kernel arch/x86/boot/bzImage -initrd test.img \
-nodefaults -nographic -append console=ttyS0 -serial
stdio
Stefano Brivio <sbrivio@redhat.com>, Sevinj Aghayeva <sevinj.aghayeva@gmail.com>
Please send reports or patches via e-mail to the authors.
Copyright (c) 2020-2022 Red Hat GmbH.
mbuto is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
qemu(1), supermin(1), dracut(8), mkinitramfs(8), debootstrap(8).
See example terminal captures at https://mbuto.sh.