blob: 1fef7822dbe19c27e2a7031f5e13552a16ad47b9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# SPDX-FileCopyrightText: Copyright (C) 2025 Bruce Ashfield
#
# SPDX-License-Identifier: MIT
#
# vcontainer-tiny-initramfs-image.inc
# ===========================================================================
# Shared tiny initramfs image for vdkr/vpdmn switch_root boot flow
# ===========================================================================
#
# This produces a minimal cpio.gz initramfs containing only:
# - busybox (for mount, switch_root, sh, etc.)
# - vcontainer-preinit (the /init script)
#
# Boot flow:
# QEMU boots kernel + this initramfs
# -> /init (vcontainer-preinit) mounts squashfs rootfs.img from /dev/vda
# -> switch_root into rootfs.img with overlayfs
# -> ${runtime}-init.sh runs with full container tools
#
SUMMARY = "Tiny initramfs for vcontainer switch_root"
DESCRIPTION = "Minimal initramfs containing busybox and preinit script for \
mounting squashfs rootfs and performing switch_root."
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
inherit core-image
# Minimal packages: just busybox and the preinit script
# busybox provides: mount, switch_root, sh, mkdir, sleep, cat, ls, echo, reboot
PACKAGE_INSTALL = "busybox vcontainer-preinit"
# No extra features - keep it tiny
IMAGE_FEATURES = ""
# Don't include kernel in initramfs
PACKAGE_EXCLUDE = "kernel-image-*"
# Output as cpio.gz (standard initramfs format)
IMAGE_FSTYPES = "${INITRAMFS_FSTYPES}"
# Keep the image small
IMAGE_ROOTFS_SIZE = "8192"
IMAGE_ROOTFS_EXTRA_SPACE = "0"
# No locales needed
IMAGE_LINGUAS = ""
# Suppress the suffix for cleaner naming
IMAGE_NAME_SUFFIX = ""
# Compatible with x86_64 and aarch64 targets
COMPATIBLE_HOST = "(x86_64|aarch64).*-linux"
# Create required directories that busybox/preinit expect
ROOTFS_POSTPROCESS_COMMAND += "create_initramfs_dirs;"
create_initramfs_dirs() {
# Create mount points used by preinit
install -d ${IMAGE_ROOTFS}/proc
install -d ${IMAGE_ROOTFS}/sys
install -d ${IMAGE_ROOTFS}/dev
install -d ${IMAGE_ROOTFS}/mnt/lower
install -d ${IMAGE_ROOTFS}/mnt/upper
install -d ${IMAGE_ROOTFS}/mnt/work
install -d ${IMAGE_ROOTFS}/mnt/root
# Create console device node (needed before /dev is mounted)
mknod -m 622 ${IMAGE_ROOTFS}/dev/console c 5 1 2>/dev/null || true
}
|