summaryrefslogtreecommitdiffstats
path: root/recipes-containers/vcontainer/vcontainer-tiny-initramfs-image.inc
diff options
context:
space:
mode:
authorBruce Ashfield <bruce.ashfield@gmail.com>2026-01-23 15:46:16 -0500
committerBruce Ashfield <bruce.ashfield@gmail.com>2026-02-09 03:34:12 +0000
commitabf81c8c676bb8997efe4d92a6e4369dcdd6961a (patch)
tree9d87667bc28e50d1594fb147c7f8b8d3dd3c028f /recipes-containers/vcontainer/vcontainer-tiny-initramfs-image.inc
parent60b7b35234926f690913ad3d83df35d73a69b61f (diff)
downloadmeta-virtualization-abf81c8c676bb8997efe4d92a6e4369dcdd6961a.tar.gz
vcontainer: add tiny initramfs image infrastructure
Add proper Yocto image recipes for the tiny initramfs used by vdkr/vpdmn in the switch_root boot flow: - vcontainer-tiny-initramfs-image.inc: Shared image configuration - vcontainer-preinit_1.0.bb: Preinit script package (shared) - vdkr-tiny-initramfs-image.bb: Tiny initramfs for vdkr - vpdmn-tiny-initramfs-image.bb: Tiny initramfs for vpdmn The tiny initramfs contains only busybox and a preinit script that: 1. Mounts devtmpfs, proc, sysfs 2. Mounts the squashfs rootfs.img from /dev/vda 3. Creates tmpfs overlay for writes 4. Performs switch_root to the real rootfs This replaces ad-hoc file extraction with proper image-based builds, improving reproducibility and maintainability. Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
Diffstat (limited to 'recipes-containers/vcontainer/vcontainer-tiny-initramfs-image.inc')
-rw-r--r--recipes-containers/vcontainer/vcontainer-tiny-initramfs-image.inc70
1 files changed, 70 insertions, 0 deletions
diff --git a/recipes-containers/vcontainer/vcontainer-tiny-initramfs-image.inc b/recipes-containers/vcontainer/vcontainer-tiny-initramfs-image.inc
new file mode 100644
index 00000000..1fef7822
--- /dev/null
+++ b/recipes-containers/vcontainer/vcontainer-tiny-initramfs-image.inc
@@ -0,0 +1,70 @@
1# SPDX-FileCopyrightText: Copyright (C) 2025 Bruce Ashfield
2#
3# SPDX-License-Identifier: MIT
4#
5# vcontainer-tiny-initramfs-image.inc
6# ===========================================================================
7# Shared tiny initramfs image for vdkr/vpdmn switch_root boot flow
8# ===========================================================================
9#
10# This produces a minimal cpio.gz initramfs containing only:
11# - busybox (for mount, switch_root, sh, etc.)
12# - vcontainer-preinit (the /init script)
13#
14# Boot flow:
15# QEMU boots kernel + this initramfs
16# -> /init (vcontainer-preinit) mounts squashfs rootfs.img from /dev/vda
17# -> switch_root into rootfs.img with overlayfs
18# -> ${runtime}-init.sh runs with full container tools
19#
20
21SUMMARY = "Tiny initramfs for vcontainer switch_root"
22DESCRIPTION = "Minimal initramfs containing busybox and preinit script for \
23 mounting squashfs rootfs and performing switch_root."
24LICENSE = "MIT"
25LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
26
27inherit core-image
28
29# Minimal packages: just busybox and the preinit script
30# busybox provides: mount, switch_root, sh, mkdir, sleep, cat, ls, echo, reboot
31PACKAGE_INSTALL = "busybox vcontainer-preinit"
32
33# No extra features - keep it tiny
34IMAGE_FEATURES = ""
35
36# Don't include kernel in initramfs
37PACKAGE_EXCLUDE = "kernel-image-*"
38
39# Output as cpio.gz (standard initramfs format)
40IMAGE_FSTYPES = "${INITRAMFS_FSTYPES}"
41
42# Keep the image small
43IMAGE_ROOTFS_SIZE = "8192"
44IMAGE_ROOTFS_EXTRA_SPACE = "0"
45
46# No locales needed
47IMAGE_LINGUAS = ""
48
49# Suppress the suffix for cleaner naming
50IMAGE_NAME_SUFFIX = ""
51
52# Compatible with x86_64 and aarch64 targets
53COMPATIBLE_HOST = "(x86_64|aarch64).*-linux"
54
55# Create required directories that busybox/preinit expect
56ROOTFS_POSTPROCESS_COMMAND += "create_initramfs_dirs;"
57
58create_initramfs_dirs() {
59 # Create mount points used by preinit
60 install -d ${IMAGE_ROOTFS}/proc
61 install -d ${IMAGE_ROOTFS}/sys
62 install -d ${IMAGE_ROOTFS}/dev
63 install -d ${IMAGE_ROOTFS}/mnt/lower
64 install -d ${IMAGE_ROOTFS}/mnt/upper
65 install -d ${IMAGE_ROOTFS}/mnt/work
66 install -d ${IMAGE_ROOTFS}/mnt/root
67
68 # Create console device node (needed before /dev is mounted)
69 mknod -m 622 ${IMAGE_ROOTFS}/dev/console c 5 1 2>/dev/null || true
70}