From 588973b0cdc01dec2aef80870cb6407cde8b8d47 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Tue, 14 Jul 2026 17:05:45 -0700 Subject: [PATCH] Only offer a choice of installing alongside existing data if it's actually possible --- configs/airootfs/root/configurator | 60 ++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 16 deletions(-) diff --git a/configs/airootfs/root/configurator b/configs/airootfs/root/configurator index 1c707a1..bcc6512 100644 --- a/configs/airootfs/root/configurator +++ b/configs/airootfs/root/configurator @@ -828,6 +828,30 @@ open_partition_tool() { sleep 1 } +# If the disk has no partition table or no unallocated free space, the only +# viable path is a full-disk install. Skip the install-mode picker and go +# straight to confirmation. +requires_full_disk_install() { + local pt_type free_space_b + pt_type=$(lsblk -dno PTTYPE "$disk" 2>/dev/null) + + # a) No partition table: disk is empty + [[ -z "$pt_type" ]] && return 0 + + # b) No usable free space + free_space_b=$(parted -ms "$disk" unit B print free /dev/null | \ + awk -F: ' + $NF ~ /free/ { + size=$4; + gsub(/B/, "", size); + if (size+0 > max+0) max=size; + } + END { + print max+0; + }') + [[ -z "$free_space_b" || "$free_space_b" -eq 0 ]] +} + install_mode_form() { local choices=("Full disk install") @@ -842,23 +866,27 @@ install_mode_form() { install_mode=$(gum choose --header "How should Omarchy be installed on $disk?" "${choices[@]}") || abort } -while true; do - install_mode_form +if requires_full_disk_install; then + install_mode="Full disk install" +else + while true; do + install_mode_form - case "$install_mode" in - "Full disk install") - break - ;; - "Free space install (alongside existing data)") - if run_partition_install "$@"; then - exit 0 - fi - ;; - "Choose a different disk") - disk_form - ;; - esac -done + case "$install_mode" in + "Full disk install") + break + ;; + "Free space install (alongside existing data)") + if run_partition_install "$@"; then + exit 0 + fi + ;; + "Choose a different disk") + disk_form + ;; + esac + done +fi confirm_disk_overwrite() { local mode="encrypted"