Skip to content

Instantly share code, notes, and snippets.

@keithpl
Last active April 11, 2024 23:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keithpl/c4a3c89ace838777f8f23f6e2c6efdc9 to your computer and use it in GitHub Desktop.
Save keithpl/c4a3c89ace838777f8f23f6e2c6efdc9 to your computer and use it in GitHub Desktop.
Arch Linux ZFS

Random notes for using ZFS on Arch Linux via DKMS.

Setup archzfs pacman repository by editing /etc/pacman.conf:

[archzfs]
Server = https://archzfs.com/$repo/$arch
sudo pacman-key -r DDF7DB817396A49B2A2723F7403BD972F75D9D76
sudo pacman-key --lsign-key DDF7DB817396A49B2A2723F7403BD972F75D9D76
sudo pacman -Syu
sudo pacman -S linux-lts linux-lts-headers

sudo pacman -S zfs-dkms zfs-utils

sudo systemctl enable zfs-import-cache.service zfs-mount.service
sudo systemctl enable zfs-zed.service zfs.target zfs-import.target

Create zfs-load-key systemd service in /etc/systemd/system/zfs-load-key.service:

[Unit]
Description=Load encryption keys
DefaultDependencies=no
After=zfs-import.target
Before=zfs-mount.service

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/zfs load-key -a
StandardInput=tty-force

[Install]
WantedBy=zfs-mount.service

Enable zfs-load-key service

sudo systemctl daemon-reload
sudo systemctl enable zfs-load-key
find /dev/disk/by-id/ata-* | cut -d '/' -f 5 | xargs

sudo zpool create -f -o ashift=12 -O acltype=posixacl -O compression=lz4 -O atime=on \
  -O relatime=on -O xattr=sa -O recordsize=1M -m /mnt/deadpool deadpool raidz2 <DEVICE LIST>
  
sudo zpool add deadpool cache <L2ARC DEVICE>

sudo systemctl enable --now zfs-scrub-weekly@deadpool.timer

sudo openssl rand -hex -out /root/deadpool.key 32
sudo chmod 0600 /root/deadpool.key

sudo zfs create -o encryption=aes-256-gcm -o keylocation=file:///root/deadpool.key \
  -o keyformat=hex -o mountpoint=/mnt/deadpool/crypt deadpool/crypt

Nice random zfs list commands.

sudo zpool list -vPH
sudo zfs list -o name,used,avail,refer,compressratio,compress,recordsize,encryption,mountpoint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment