aboutsummaryrefslogtreecommitdiff
path: root/installer/lib/disk.sh
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-08-14 09:59:55 -0500
committerCraig Jennings <c@cjennings.net>2026-08-14 09:59:55 -0500
commit1a900e50433b0fcd3a192eed1c7989233a6928cf (patch)
treefe558b95439053b7bfd3be7297dc8ef00db2f3a9 /installer/lib/disk.sh
parent4186fcf3f75831b28333dbfb0814318ec88dd0d0 (diff)
downloadarchangel-1a900e50433b0fcd3a192eed1c7989233a6928cf.tar.gz
archangel-1a900e50433b0fcd3a192eed1c7989233a6928cf.zip
feat(install): optional SWAP_SIZE carves a swap partition for hibernate
Hibernate needs a resume target outside the pool (swap-on-zvol deadlocks, a long-standing OpenZFS issue), and that's only decidable at partition time. SWAP_SIZE=100G in a config file carves partition 3 (type 8200) physically between EFI and root. Root still takes the remainder and the EFI=1/ROOT=2 numbering contract holds. validate_config rejects malformed sizes and multi-disk layouts. get_swap_partition handles nvme vs sata naming. This only partitions: formatting, encryption, and the resume chain stay manual for now. The change ran the real velox reinstall on 2026-08-13 (EFI=512M, SWAP=100G, ROOT=remainder).
Diffstat (limited to 'installer/lib/disk.sh')
-rw-r--r--installer/lib/disk.sh18
1 files changed, 17 insertions, 1 deletions
diff --git a/installer/lib/disk.sh b/installer/lib/disk.sh
index ae7801b..ba2d3a2 100644
--- a/installer/lib/disk.sh
+++ b/installer/lib/disk.sh
@@ -25,12 +25,18 @@ partition_disk() {
wipefs -af "$disk" || error "Failed to wipe signatures on $disk"
sgdisk --zap-all "$disk" || error "Failed to zap GPT on $disk"
sgdisk -n 1:0:+${efi_size} -t 1:EF00 -c 1:"EFI" "$disk" || error "Failed to create EFI partition on $disk"
+ # Optional swap partition for hibernate: physically between EFI and
+ # root (carved first so root's 0:0 takes the remainder), numbered 3 so
+ # the EFI=1/ROOT=2 contract every downstream caller relies on holds.
+ if [[ -n "${SWAP_SIZE:-}" ]]; then
+ sgdisk -n 3:0:+${SWAP_SIZE} -t 3:8200 -c 3:"SWAP" "$disk" || error "Failed to create swap partition on $disk"
+ fi
sgdisk -n 2:0:0 -t 2:$root_type -c 2:"ROOT" "$disk" || error "Failed to create root partition on $disk"
partprobe "$disk" 2>/dev/null || true
sleep 1
- info "Partitioned $disk: EFI=${efi_size}, ROOT=remainder"
+ info "Partitioned $disk: EFI=${efi_size}${SWAP_SIZE:+, SWAP=${SWAP_SIZE}}, ROOT=remainder"
}
# Partition every disk in SELECTED_DISKS, format each EFI partition,
@@ -92,6 +98,16 @@ get_root_partition() {
fi
}
+# Partition 3 exists only when SWAP_SIZE was set at partition time.
+get_swap_partition() {
+ local disk="$1"
+ if [[ "$disk" =~ nvme ]]; then
+ echo "${disk}p3"
+ else
+ echo "${disk}3"
+ fi
+}
+
#############################
# Disk Selection (Interactive)
#############################