From 5cf81049f616bfe29f0d51b4ae87b384146f7b35 Mon Sep 17 00:00:00 2001 From: Adolfo Delorenzo Date: Thu, 14 May 2026 15:01:20 -0600 Subject: [PATCH] fix: install our staged init at /init too, not just /sbin/init MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The kernel ALWAYS runs /init when booting from an initramfs. If /init doesn't exist, the kernel falls back to the legacy root-mount path (looking for a real root partition via root= cmdline), which we don't want — our system IS the initramfs. Previous fix removed piCore's /init to stop it from being run; that caused the kernel to skip the initramfs entrypoint entirely and panic with 'Cannot open root device' (error -6). Correct fix: replace piCore's /init with a copy of our init.sh. The kernel runs /init -> our staged boot, which is exactly what we want. Keep /sbin/init as well (some boot paths exec it directly, e.g. via init= cmdline override) and the existing init=/sbin/init in grub-arm64.cfg as a belt. Co-Authored-By: Claude Opus 4.7 (1M context) --- build/scripts/inject-kubesolo.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/build/scripts/inject-kubesolo.sh b/build/scripts/inject-kubesolo.sh index 3aa8550..ce30071 100755 --- a/build/scripts/inject-kubesolo.sh +++ b/build/scripts/inject-kubesolo.sh @@ -55,14 +55,14 @@ rm -f "$ROOTFS/sbin/init" cp "$PROJECT_ROOT/init/init.sh" "$ROOTFS/sbin/init" chmod +x "$ROOTFS/sbin/init" -# Remove piCore/TC's /init at the rootfs root. The kernel's init search order -# is /init -> /sbin/init -> ..., so leaving piCore's /init in place causes the -# kernel to run that instead of ours, which then segfaults (it tries to do -# piCore-specific TCE handling on a host that doesn't have it). -if [ -e "$ROOTFS/init" ]; then - rm -f "$ROOTFS/init" - echo " Removed upstream /init (kernel will fall through to /sbin/init)" -fi +# Replace the upstream /init at the rootfs root with our staged init. +# The kernel ALWAYS runs /init when booting from an initramfs (legacy root-mount +# fallback otherwise). piCore/TC ship their own /init; ours has to take its +# place so the kernel runs our staged boot, not piCore's TCE handler. +rm -f "$ROOTFS/init" +cp "$PROJECT_ROOT/init/init.sh" "$ROOTFS/init" +chmod +x "$ROOTFS/init" +echo " Installed staged init at /init and /sbin/init" # Init stages mkdir -p "$ROOTFS/usr/lib/kubesolo-os/init.d"