fix: install our staged init at /init too, not just /sbin/init
Some checks failed
CI / Go Tests (push) Successful in 1m29s
CI / Shellcheck (push) Failing after 33s
CI / Build Go Binaries (amd64, linux, linux-amd64) (push) Failing after 1m7s
CI / Build Go Binaries (arm64, linux, linux-arm64) (push) Failing after 1m12s

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) <noreply@anthropic.com>
This commit is contained in:
2026-05-14 15:01:20 -06:00
parent 863f498cc2
commit 5cf81049f6

View File

@@ -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
# 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"
echo " Removed upstream /init (kernel will fall through to /sbin/init)"
fi
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"