From c90d9da15910f568fca06050f8875d435de4f502 Mon Sep 17 00:00:00 2001 From: vxtls <187420201+vxtls@users.noreply.github.com> Date: Wed, 4 Mar 2026 18:55:04 -0500 Subject: [PATCH] fix(boot): add minimal early mounts for /dev and /proc in stage0 resume path --- rootfs.py | 23 ++++++++++++++++++++++ seed/script-generator.c | 2 ++ steps-guix/guix-hash-compat-1.5.0/pass1.sh | 6 +++++- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/rootfs.py b/rootfs.py index 748a41ea..e58cf77d 100755 --- a/rootfs.py +++ b/rootfs.py @@ -131,6 +131,29 @@ lines.append("PAYLOAD_REQUIRED=False\\n") with open(config_path, "w", encoding="utf-8") as cfg: cfg.writelines(lines) +# Ensure resumed stage0-image /init has minimal early mounts for runtime. +init_path = os.path.join(mountpoint, "init") +mount_marker = "# LB_STAGE0_EARLY_MOUNTS" +if os.path.isfile(init_path): + with open(init_path, "r", encoding="utf-8", errors="ignore") as init_file: + init_content = init_file.read() + + if mount_marker not in init_content: + first_newline = init_content.find("\\n") + if first_newline != -1: + mount_block = ( + mount_marker + "\\n" + + "mount | grep ' on /dev ' >/dev/null 2>&1 || (mkdir -p /dev; mount -t devtmpfs devtmpfs /dev)\\n" + + "mount | grep ' on /proc ' >/dev/null 2>&1 || (mkdir -p /proc; mount -t proc proc /proc)\\n" + ) + init_content = ( + init_content[: first_newline + 1] + + mount_block + + init_content[first_newline + 1 :] + ) + with open(init_path, "w", encoding="utf-8") as init_file: + init_file.write(init_content) + if build_guix_also: dest_steps_guix = os.path.join(mountpoint, "steps-guix") if os.path.isdir(dest_steps_guix): diff --git a/seed/script-generator.c b/seed/script-generator.c index 50a3ef93..e54cd539 100644 --- a/seed/script-generator.c +++ b/seed/script-generator.c @@ -534,6 +534,8 @@ void output_resume_network_init(FILE *out) { fputs("if [ -f /steps/bootstrap.cfg ]; then\n", out); fputs(". /steps/bootstrap.cfg\n", out); fputs("fi\n", out); + fputs("mount | grep ' on /dev ' >/dev/null 2>&1 || (mkdir -p /dev; mount -t devtmpfs devtmpfs /dev)\n", out); + fputs("mount | grep ' on /proc ' >/dev/null 2>&1 || (mkdir -p /proc; mount -t proc proc /proc)\n", out); fputs("if [ \"${CHROOT}\" = False ] && command -v dhcpcd >/dev/null 2>&1; then\n", out); fputs("dhcpcd --waitip=4 || true\n", out); fputs("fi\n", out); diff --git a/steps-guix/guix-hash-compat-1.5.0/pass1.sh b/steps-guix/guix-hash-compat-1.5.0/pass1.sh index 41f280fe..891ff45b 100644 --- a/steps-guix/guix-hash-compat-1.5.0/pass1.sh +++ b/steps-guix/guix-hash-compat-1.5.0/pass1.sh @@ -14,12 +14,15 @@ src_compile() { src_install() { local compat_src + local compat_bin compat_src="${DESTDIR}/usr/libexec/guix-hash-compat/guix-1.5.0" + compat_bin="${DESTDIR}/usr/bin/guix-hash-compat" mkdir -p "${compat_src}" cp -a . "${compat_src}/" + mkdir -p "$(dirname "${compat_bin}")" - install -D -m 0755 /dev/stdin "${DESTDIR}/usr/bin/guix-hash-compat" <<'EOS' + cat > "${compat_bin}" <<'EOS' #!/bin/sh set -e @@ -31,4 +34,5 @@ fi cd "${src_dir}" exec ./pre-inst-env guix hash "$@" EOS + chmod 0755 "${compat_bin}" }