fix(boot): add minimal early mounts for /dev and /proc in stage0 resume path

This commit is contained in:
vxtls 2026-03-04 18:55:04 -05:00
parent 8ad179e1e6
commit c90d9da159
3 changed files with 30 additions and 1 deletions

View file

@ -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):

View file

@ -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);

View file

@ -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}"
}