summaryrefslogtreecommitdiff
path: root/packages/partitioner.nix
blob: cd36f5d40c5515bd3851ed9f1098bc693325d7e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Apply standard partition layout to a disk device.
{ pkgs, ... }:

pkgs.writeShellScriptBin "partitioner" ''
  set -e

  if [ $# -ne 1 ]; then
    echo "Usage: $0 <disk-device>"
    exit 1
  fi

  DISK=$1

  # Clear existing partitions
  sgdisk -Z "$DISK"

  # 1GB EFI partition (FAT32)
  sgdisk -n 1:0:+1G -t 1:EF00 -c 1:EFI "$DISK"

  # Rest for ZFS
  sgdisk -n 2:0:0 -t 2:BF01 -c 2:ZFS "$DISK"

  mkfs.fat -F32 -nEFI ""

  zpool create \
    -o ashift=12 \
    -O compression=on \
    -O acltype=posixacl \
    -O xattr=sa \
    -O relatime=off
    -O normalization=formD \
    zroot "$DISK"
''