Skip to content

ArchLinux Partitioning

With this guide you will install archlinux on an efi based System. Everything except /boot will be located on ZFS. ZFS will be fully encrypted and you will get the abillity to remote unlock your fully encryptet ZFS at boot.

Create Partitions

parted --script /dev/nvme0n1 mklabel gpt \
  mkpart non-fs 0% 2 \
  mkpart primary 2 514 \
  mkpart primary 514 95%
  set 1 bios_grub on \
  set 1 name boot \
  set 2 boot on \
  set 2 efi on \
  set 2 name EFI
  set 3 name ZFS

- hosts: arch
    - parted: number=1 device=/dev/nvme0n1 state=absent
    - parted: number=2 device=/dev/nvme0n1 state=absent
    - parted: number=3 device=/dev/nvme0n1 state=absent
    - parted: number=4 device=/dev/nvme0n1 state=absent
    - name: create boot partition
      parted: name=boot number=1 device=/dev/nvme0n1 state=present flags=bios_grub label=gpt part_end=2MiB
    - name: create EFI partition
      parted: name=EFI number=2 device=/dev/nvme0n1 state=present flags=boot label=gpt part_start=2MiB part_end=514MiB
    - name: create ZFS partition
      parted: name=ZFS number=3 device=/dev/nvme0n1 state=present label=gpt part_start=514MiB part_end=95%
    - name: get partition infos
      parted: device=/dev/nvme0n1
      register: part
    - debug: var=part

    - name: /dev/nvme0n1p2 goes vfat
      filesystem: fstype=vfat dev=/dev/nvme0n1p2

Create root pool

zpool create -o ashift=12 \
  -O acltype=posixacl -O canmount=off -O compression=on \
  -O dnodesize=auto -O normalization=formD -O relatime=on -O xattr=sa \
  -O encryption=aes-256-gcm -O keylocation=prompt -O keyformat=passphrase \
  -O mountpoint=none -R /mnt \
  zroot /dev/nvme0n1p3

Create Datasets

zfs create -o canmount=off -o mountpoint=none zroot/ROOT
zfs create -o canmount=noauto -o mountpoint=/ zroot/ROOT/arch
zfs mount zroot/ROOT/arch

zfs create -o mountpoint=/home zroot/home
zpool set bootfs=zroot/ROOT/arch zroot

Create boot and EFI partition

mkfs.vfat -F32 /dev/nvme0n1p2
mkdir /mnt/boot
mount /dev/nvme0n1p2 /mnt/boot

Create zpool.cache

zpool set cachefile=/etc/zfs/zpool.cache zroot
mkdir -p /mnt/etc/zfs/
cp /etc/zfs/zpool.cache /mnt/etc/zfs/zpool.cache

Last update: August 21, 2021