installer-iso: persist auto-install logs to the staging disk

This commit is contained in:
2026-07-24 19:43:43 +02:00
parent 2543a1246b
commit ff92e24ff7
2 changed files with 108 additions and 34 deletions
+19
View File
@@ -342,6 +342,17 @@ local_install_prepare_and_reboot() {
[ "$stage_fstype" != btrfs ] \
|| die "$stagedir is btrfs: findiso= mounts the volume's top level, so a path inside a subvolume never resolves. Stage on a non-btrfs partition (ext4/vfat/ntfs)."
# PARTUUID of the staging partition. Handed to the installer as
# homelab.logpart= so it can mount this partition rw and persist its whole
# run — disko + nixos-install output included — to a file next to the iso.
# This partition is on a DIFFERENT disk from the one disko wipes (guarded
# above), so unlike $boot it SURVIVES the install: a failed attempt otherwise
# leaves nothing to debug, its journal having died on tmpfs at the reboot.
# Best-effort — an LVM/mdraid stage_src has no PARTUUID, in which case logging
# is simply skipped rather than blocking the install.
local stage_partuuid
stage_partuuid="$(lsblk -no PARTUUID "$stage_src" 2>/dev/null | head -1 | tr -d ' ' || true)"
# Last chance to back out. This is the most destructive command in the
# script — it reboots the machine you are typing at and the wipe that
# follows is unattended — so it confirms just like `flash` and `kexec-local`
@@ -354,6 +365,11 @@ local_install_prepare_and_reboot() {
echo " -> $osdisk_real ** WIPED, unattended, after the reboot **"
# Unquoted on purpose: collapses the one-per-line list onto one line.
echo " staging: $stagedir (on $(echo $stage_disks))"
if [ -n "$stage_partuuid" ]; then
echo " logs: $stagedir/homelab-install-$config.log (on the staging disk — survives the wipe)"
else
echo " logs: (none — $stagedir has no PARTUUID; installer output won't survive the wipe)"
fi
echo " one-shot: $boot_mode"
read -rp ">> type 'yes' to build the installer, reboot into it and wipe $osdisk_real: " ok
[ "$ok" = yes ] || die "aborted"
@@ -426,6 +442,9 @@ local_install_prepare_and_reboot() {
local cmdline volumeID
volumeID="$(nix eval --raw .#nixosConfigurations.installer-iso.config.isoImage.volumeID)"
cmdline="init=$toplevel/init nohibernate root=LABEL=$volumeID boot.shell_on_fail loglevel=4 lsm=landlock,yama,bpf findiso=$iso_relpath homelab.install=$config homelab.keypart=$boot_partuuid"
# Only when the staging partition has a PARTUUID (see stage_partuuid). Points
# the installer's homelab-auto-install.service at the surviving disk to log to.
[ -n "$stage_partuuid" ] && cmdline="$cmdline homelab.logpart=$stage_partuuid"
case "$boot_mode" in
systemd-boot)