diff options
| author | Craig Jennings <c@cjennings.net> | 2026-08-14 09:59:55 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-08-14 09:59:55 -0500 |
| commit | 1a900e50433b0fcd3a192eed1c7989233a6928cf (patch) | |
| tree | fe558b95439053b7bfd3be7297dc8ef00db2f3a9 /tests/unit/test_disk.bats | |
| parent | 4186fcf3f75831b28333dbfb0814318ec88dd0d0 (diff) | |
| download | archangel-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 'tests/unit/test_disk.bats')
| -rw-r--r-- | tests/unit/test_disk.bats | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/unit/test_disk.bats b/tests/unit/test_disk.bats index b962445..462f5d7 100644 --- a/tests/unit/test_disk.bats +++ b/tests/unit/test_disk.bats @@ -320,3 +320,49 @@ partition_disks_setup() { run disk_in_use /dev/zzz999 [ "$status" -eq 1 ] } + +############################# +# get_swap_partition +############################# + +@test "get_swap_partition: SATA disk gets numeric suffix 3" { + run get_swap_partition /dev/sda + [ "$status" -eq 0 ] + [ "$output" = "/dev/sda3" ] +} + +@test "get_swap_partition: NVMe disk gets p-prefixed suffix 3" { + run get_swap_partition /dev/nvme0n1 + [ "$status" -eq 0 ] + [ "$output" = "/dev/nvme0n1p3" ] +} + +############################# +# partition_disk SWAP_SIZE layout +############################# + +@test "partition_disk without SWAP_SIZE keeps the two-partition layout" { + partition_disks_setup + FILESYSTEM=zfs + SWAP_SIZE="" + partition_disk /dev/sda + for c in "${CALLS[@]}"; do + [[ "$c" != *"8200"* ]] + done +} + +@test "partition_disk with SWAP_SIZE carves swap before root so root takes remainder" { + partition_disks_setup + FILESYSTEM=zfs + SWAP_SIZE=100G + partition_disk /dev/nvme0n1 + local swap_idx=-1 root_idx=-1 i=0 + for c in "${CALLS[@]}"; do + [[ "$c" == *"-n 3:0:+100G -t 3:8200"* ]] && swap_idx=$i + [[ "$c" == *"-n 2:0:0"* ]] && root_idx=$i + i=$((i+1)) + done + [ "$swap_idx" -ge 0 ] + [ "$root_idx" -ge 0 ] + [ "$swap_idx" -lt "$root_idx" ] +} |
