Last updated:
GitHub: genpack-artifacts/stub
stub is one of the artifacts built with the genpack toolchain. It serves as a disposable boot environment for installing other Linux distributions on QEMU/KVM virtual machines.
While it operates as a genpack image, its ultimate purpose is to bring up an OS other than genpack. It is a two-stage provisioning tool that acts as an installer on first boot and as a boot loader using kexec on subsequent boots.
Used in combination with the vm command.
# 1. Create a virtual disk for data (8GiB)
vm allocate debian12.img 8
# 2. Start a VM with stub as the system image and debian12.img as the data disk
vm run -d debian12.img stub-$(uname -m).squashfs
# 3. After auto-login inside the VM, run the script for the desired distribution
./debian12.sh
# 4. After installation completes, reboot — from then on, Debian 12 boots directly
| Script | Distribution |
|---|---|
debian12.sh | Debian 12 (Bookworm) |
debian13.sh | Debian 13 (Trixie) |
ubuntu2004.sh | Ubuntu 20.04 (Focal) |
ubuntu2204.sh | Ubuntu 22.04 (Jammy) |
ubuntu2404.sh | Ubuntu 24.04 (Noble) |
ubuntu2604.sh | Ubuntu 26.04 (Resolute) |
| Script | Distribution |
|---|---|
centos6.sh | CentOS 6 |
centos7.sh | CentOS 7 |
centos8stream.sh | CentOS Stream 8 |
centos9stream.sh | CentOS Stream 9 |
centos10stream.sh | CentOS Stream 10 |
almalinux9.sh | AlmaLinux 9 |
rocky8.sh | Rocky Linux 8 |
miraclelinux8.sh | MIRACLE LINUX 8 |
fedora42.sh | Fedora 42 |
| Script | Distribution |
|---|---|
gentoo.sh | Gentoo Linux (built from a stage3 tarball) |
files/usr/lib/genpack-init/00kexec.py)A Python script that runs as a genpack-init plugin on every boot. It checks whether an installed OS kernel and initramfs exist on the data disk (/dev/vdb) or on virtiofs. If found, it loads and transitions to that kernel using kexec.
This allows stub to function as a transparent boot loader after the initial installation, making the VM boot flow look like:
files/root/*.sh)Each script follows a common pattern:
systemd-networkd-wait-onlinedebootstrap or rpmbootstrapThe system is ready for remote management via SSH immediately after installation.
files/build.d/autologin.sh)Sets up root auto-login on both hvc0 (virtio console) and ttyS0 (serial console). When connecting via vm console, a shell is available immediately without a login prompt.
files/build.d/build-llmnrd.sh)Statically builds the Link-Local Multicast Name Resolution Daemon from source. It is deployed to the installed OS, enabling hostname resolution without a DNS server.
| Package | Purpose |
|---|---|
genpack/paravirt | Paravirtualized kernel and base system |
sys-kernel/gentoo-kernel | Minimal kernel built from source |
sys-apps/kexec-tools | Used to transition to the OS kernel |
dev-util/debootstrap | Bootstrapping Debian / Ubuntu systems |
dev-util/rpmbootstrap | Bootstrapping RPM-based systems |
sys-fs/cryptsetup | Disk encryption support |
sys-devel/binutils | Binary utilities |
Since stub is a disposable boot environment that does not require broad hardware support, 1,757 kernel options are disabled in kernel/config.d/unset.config.
Major features disabled include:
KEXEC_SIG — disabled to allow flexible kexec usage)| Architecture | Kernel Configuration | Output File |
|---|---|---|
| x86_64 | unset.config only | stub-x86_64.squashfs |
| aarch64 | savedconfig + unset.config | stub-aarch64.squashfs |
| riscv64 | savedconfig + unset.config | stub-riscv64.squashfs |
stub is a unique entity within the genpack ecosystem. Although it is built and booted as a genpack image, its purpose is to bring up an OS other than genpack. By leveraging genpack-init's plugin mechanism (pybind11 + Python) and the vm command's virtual disk management, it provides a unified environment for provisioning many different distribution VMs using a common procedure in QEMU/KVM environments.
This document was written based on the following repository snapshots: