diff --git a/setup/arch-autoinstall.sh b/setup/arch-autoinstall.sh index fb443c6..e1ab659 100755 --- a/setup/arch-autoinstall.sh +++ b/setup/arch-autoinstall.sh @@ -49,6 +49,8 @@ get_mac_suffix() { printf '%s' "${mac//:/}" } +part() { [[ "$1" == *nvme* || "$1" == *mmcblk* ]] && echo "${1}p${2}" || echo "${1}${2}"; } + if $AF_MODE; then echo "Answerfile detected: $ANSWERFILE" # Ensure jq is available @@ -165,6 +167,10 @@ SWAP_SIZE="${RAM_GB}GiB" DISK_SIZE=$(lsblk -b -dn -o SIZE "$DRIVE") DISK_GIB=$((DISK_SIZE / 1024 / 1024 / 1024)) ROOT_GIB=$((DISK_GIB - RAM_GB - 15)) +if (( ROOT_GIB < 8 )); then + echo "ERROR: Not enough disk space. Root would be only ${ROOT_GIB}GiB (need ≥8GiB)." + exit 1 +fi echo "Partition plan:" echo " Boot: ${BOOT_SIZE}" @@ -180,9 +186,9 @@ parted "$DRIVE" --script mklabel gpt \ mkpart ROOT 15GiB "$((15 + ROOT_GIB))"GiB \ mkpart SWAP "$((15 + ROOT_GIB))"GiB 100% -BOOT_PART="${DRIVE}1" -ROOT_PART="${DRIVE}2" -SWAP_PART="${DRIVE}3" +BOOT_PART=$(part "$DRIVE" 1) +ROOT_PART=$(part "$DRIVE" 2) +SWAP_PART=$(part "$DRIVE" 3) ############################################ # FORMAT BOOT + SWAP diff --git a/setup/archbaseos-guided-install.sh b/setup/archbaseos-guided-install.sh index 78f3abe..f30024d 100755 --- a/setup/archbaseos-guided-install.sh +++ b/setup/archbaseos-guided-install.sh @@ -6,6 +6,19 @@ set -euo pipefail +############################################ +# LOGGING +############################################ +LOGFILE="$HOME/archbaseos-guided-install.log" +{ + echo + echo "############################################" + echo " Arch Guided Install Log - Started $(date)" + echo "############################################" + echo +} >> "$LOGFILE" +exec > >(tee -a "$LOGFILE") 2>&1 + ############################################ # Helper Functions ############################################ @@ -27,6 +40,10 @@ pause() { read -rp "Press ENTER to continue..." } +# Returns the correct partition device for a given drive and partition number. +# NVMe and eMMC use a 'p' separator (e.g. /dev/nvme0n1p1), others don't. +part() { [[ "$1" == *nvme* || "$1" == *mmcblk* ]] && echo "${1}p${2}" || echo "${1}${2}"; } + ############################################ # ANSWERFILE ############################################ @@ -157,9 +174,9 @@ parted -s "$DRIVE" mklabel gpt \ mkpart ROOT "${EFI_SIZE}GiB" "$((EFI_SIZE + ROOT_SIZE))GiB" \ mkpart SWAP "$((EFI_SIZE + ROOT_SIZE))GiB" 100% -EFI_PART="${DRIVE}1" -ROOT_PART="${DRIVE}2" -SWAP_PART="${DRIVE}3" +EFI_PART=$(part "$DRIVE" 1) +ROOT_PART=$(part "$DRIVE" 2) +SWAP_PART=$(part "$DRIVE" 3) mkfs.fat -F32 "$EFI_PART" mkswap "$SWAP_PART" @@ -359,7 +376,9 @@ if $AF_MODE && [[ -f /mnt/answerfile.json ]]; then rm -f /mnt/answerfile.json fi -echo "Installation complete!" +cp "$LOGFILE" /mnt/boot/ 2>/dev/null || true + +echo "Installation complete! Log saved to /mnt/boot/$(basename "$LOGFILE")" echo " umount -R /mnt && reboot" if [[ "${_DO_TUI^^}" != "YES" ]]; then echo