summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--recipes-containers/vcontainer/files/vcontainer-preinit.sh (renamed from recipes-containers/vcontainer/files/vdkr-preinit.sh)6
-rw-r--r--recipes-containers/vcontainer/vcontainer-preinit_1.0.bb43
-rw-r--r--recipes-containers/vcontainer/vcontainer-tiny-initramfs-image.inc70
-rw-r--r--recipes-containers/vcontainer/vdkr-tiny-initramfs-image.bb13
-rw-r--r--recipes-containers/vcontainer/vpdmn-tiny-initramfs-image.bb13
5 files changed, 142 insertions, 3 deletions
diff --git a/recipes-containers/vcontainer/files/vdkr-preinit.sh b/recipes-containers/vcontainer/files/vcontainer-preinit.sh
index 08738022..6f1b7e09 100644
--- a/recipes-containers/vcontainer/files/vdkr-preinit.sh
+++ b/recipes-containers/vcontainer/files/vcontainer-preinit.sh
@@ -3,7 +3,7 @@
3# 3#
4# SPDX-License-Identifier: GPL-2.0-only 4# SPDX-License-Identifier: GPL-2.0-only
5# 5#
6# vdkr-preinit.sh 6# vcontainer-preinit.sh
7# Minimal init for initramfs - mounts rootfs and does switch_root 7# Minimal init for initramfs - mounts rootfs and does switch_root
8# 8#
9# This script runs from the initramfs and: 9# This script runs from the initramfs and:
@@ -12,7 +12,7 @@
12# 3. Creates overlayfs with tmpfs for writes 12# 3. Creates overlayfs with tmpfs for writes
13# 4. Executes switch_root to the overlay root filesystem 13# 4. Executes switch_root to the overlay root filesystem
14# 14#
15# The real init (/init or /sbin/init on rootfs) then runs vdkr-init.sh logic 15# The real init (/init or /sbin/init on rootfs) then continues boot
16 16
17# Mount essential filesystems first (needed to check cmdline) 17# Mount essential filesystems first (needed to check cmdline)
18mount -t proc proc /proc 18mount -t proc proc /proc
@@ -31,7 +31,7 @@ log() {
31 [ "$QUIET" = "0" ] && echo "$@" 31 [ "$QUIET" = "0" ] && echo "$@"
32} 32}
33 33
34log "=== vdkr preinit (squashfs) ===" 34log "=== vcontainer preinit (squashfs) ==="
35 35
36# Wait for block devices to appear 36# Wait for block devices to appear
37log "Waiting for block devices..." 37log "Waiting for block devices..."
diff --git a/recipes-containers/vcontainer/vcontainer-preinit_1.0.bb b/recipes-containers/vcontainer/vcontainer-preinit_1.0.bb
new file mode 100644
index 00000000..078a5617
--- /dev/null
+++ b/recipes-containers/vcontainer/vcontainer-preinit_1.0.bb
@@ -0,0 +1,43 @@
1# SPDX-FileCopyrightText: Copyright (C) 2025 Bruce Ashfield
2#
3# SPDX-License-Identifier: MIT
4#
5# vcontainer-preinit_1.0.bb
6# ===========================================================================
7# Package containing the preinit script for vcontainer tiny initramfs
8# ===========================================================================
9#
10# This package installs the preinit script as /init for use in a tiny
11# initramfs. The script:
12# 1. Mounts essential filesystems (/proc, /sys, /dev)
13# 2. Mounts the squashfs rootfs from /dev/vda with overlayfs
14# 3. Executes switch_root to the real root filesystem
15#
16# Used by: vdkr-tiny-initramfs-image.bb, vpdmn-tiny-initramfs-image.bb
17#
18
19SUMMARY = "Preinit script for vcontainer initramfs"
20DESCRIPTION = "Minimal init script that mounts squashfs rootfs with overlayfs \
21 and performs switch_root for vcontainer QEMU environment."
22HOMEPAGE = "https://git.yoctoproject.org/meta-virtualization/"
23LICENSE = "GPL-2.0-only"
24LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0-only;md5=801f80980d171dd6425610833a22dbe6"
25
26SRC_URI = "file://vcontainer-preinit.sh"
27
28S = "${UNPACKDIR}"
29
30# This package only provides the init script - no dependencies
31# The initramfs image will pull in busybox separately
32RDEPENDS:${PN} = ""
33
34do_install() {
35 install -d ${D}
36 install -m 0755 ${S}/vcontainer-preinit.sh ${D}/init
37}
38
39# Package the /init script
40FILES:${PN} = "/init"
41
42# Prevent QA warnings about /init location
43INSANE_SKIP:${PN} += "file-rdeps"
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}
diff --git a/recipes-containers/vcontainer/vdkr-tiny-initramfs-image.bb b/recipes-containers/vcontainer/vdkr-tiny-initramfs-image.bb
new file mode 100644
index 00000000..42aa8637
--- /dev/null
+++ b/recipes-containers/vcontainer/vdkr-tiny-initramfs-image.bb
@@ -0,0 +1,13 @@
1# SPDX-FileCopyrightText: Copyright (C) 2025 Bruce Ashfield
2#
3# SPDX-License-Identifier: MIT
4#
5# vdkr-tiny-initramfs-image.bb - Tiny initramfs for vdkr
6#
7# Build with:
8# bitbake mc:vruntime-aarch64:vdkr-tiny-initramfs-image
9# bitbake mc:vruntime-x86-64:vdkr-tiny-initramfs-image
10#
11# Output: ${DEPLOY_DIR_IMAGE}/vdkr-tiny-initramfs-image-${MACHINE}.cpio.gz
12
13require vcontainer-tiny-initramfs-image.inc
diff --git a/recipes-containers/vcontainer/vpdmn-tiny-initramfs-image.bb b/recipes-containers/vcontainer/vpdmn-tiny-initramfs-image.bb
new file mode 100644
index 00000000..c407f013
--- /dev/null
+++ b/recipes-containers/vcontainer/vpdmn-tiny-initramfs-image.bb
@@ -0,0 +1,13 @@
1# SPDX-FileCopyrightText: Copyright (C) 2025 Bruce Ashfield
2#
3# SPDX-License-Identifier: MIT
4#
5# vpdmn-tiny-initramfs-image.bb - Tiny initramfs for vpdmn
6#
7# Build with:
8# bitbake mc:vruntime-aarch64:vpdmn-tiny-initramfs-image
9# bitbake mc:vruntime-x86-64:vpdmn-tiny-initramfs-image
10#
11# Output: ${DEPLOY_DIR_IMAGE}/vpdmn-tiny-initramfs-image-${MACHINE}.cpio.gz
12
13require vcontainer-tiny-initramfs-image.inc