From b6525a50fabf3aedf41eee70c164519b00d27704 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Fri, 22 May 2026 18:03:40 -0500 Subject: feat(install): add pre-flight environment and disk-target validation archangel went straight from filesystem selection into a destructive install behind only a root check and a ZFS module load. A missing tool, a BIOS boot, a too-small or in-use disk, or a dead network surfaced as a confusing abort partway through, sometimes after partitioning had already run. Two gates now fail fast. validate_environment runs after filesystem selection, before any disk is touched: it confirms UEFI boot mode and that every required command is present, with the list coming from a new required_commands helper built like pacstrap_packages. validate_install_targets runs after disk selection, before the first wipe: it refuses a target that's mounted, holds active swap, or belongs to an imported pool or md array, rejects disks under 20 GB, and confirms a mirror is reachable via DNS plus a TCP probe (no ICMP, since some networks drop it). I folded the install_failure_cleanup hardening into the same change. It now falls back to lazy unmounts, so a pacstrap-interrupted target with busy bind mounts still releases the pool and unmounts the EFI partition. Without that, the disk-in-use guard would block the very retry the cleanup exists to enable. "Re-run to retry" only holds if the disk is genuinely freed first. The 20 GB floor is decimal on purpose. It reads as the natural minimum and clears a 20 GiB disk image with headroom instead of sitting on the boundary. --- installer/lib/common.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'installer/lib/common.sh') diff --git a/installer/lib/common.sh b/installer/lib/common.sh index 2cd4798..7998eeb 100644 --- a/installer/lib/common.sh +++ b/installer/lib/common.sh @@ -102,6 +102,27 @@ pacstrap_packages() { printf '%s\n' "${common[@]}" "${fs_specific[@]}" } +# Print the external commands the installer needs for the given filesystem, +# one per line: common partitioning/bootstrap tools first, then +# filesystem-specific ones. validate_environment loops over these and +# require_command's each, so a missing tool fails fast on the live ISO +# instead of mid-install. Returns 1 for unknown filesystem. +# +# Usage: mapfile -t cmds < <(required_commands zfs) +required_commands() { + local fs="$1" + local common=( + sgdisk wipefs partprobe mkfs.fat pacstrap + ) + local fs_specific + case "$fs" in + zfs) fs_specific=(zpool zfs) ;; + btrfs) fs_specific=(mkfs.btrfs grub-install) ;; + *) return 1 ;; + esac + printf '%s\n' "${common[@]}" "${fs_specific[@]}" +} + ############################# # Password / Passphrase Input ############################# -- cgit v1.2.3