Skip to content

Instantly share code, notes, and snippets.

@kyhwana
Created December 26, 2023 23:01
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 kyhwana/48e381bd82492a9a3f52d12939626cb6 to your computer and use it in GitHub Desktop.
Save kyhwana/48e381bd82492a9a3f52d12939626cb6 to your computer and use it in GitHub Desktop.
Enabling ZFS encryption on ubuntu 23.10
Ubuntu 23.10 lets you select the advanced option of using ZFS, but not encrypting it.
#assuming you want to use zstd compression, if not remove the compress=zstd bits, as it defaults to lz4
#This doesn't encrypt the boot pool.
#ROOT is the root zfs dataset.
1) Install ubuntu 23.10 as normal, select the advanced/experimental options when installing and select ZFS
2) Once the install is done, reboot back into the installer (via USB/DVD/etc)
3) "Try ubuntu" and open a terminal, then sudo -i to root
4) zpool import -f rpool
5) zfs list (get rpool/ROOT/ubuntu_<x>, where <x> will be some random numbers/letter we need this for later)
6) zfs snapshot -r rpool/ROOT@copy
7) zfs send -R rpool/ROOT@copy | zfs receive rpool/copyroot
8) zfs destroy -r rpool/ROOT
9) zfs create -o encryption=on -o keyformat=passphrase -o compress=zstd rpool/ROOT
10) Enter passphrase twice
11) zfs send -R rpool/copyroot/ubuntu_<x>@copy | zfs receive -o encryption=on -o compress=zstd rpool/ROOT/ubuntu_<x>
12) zfs destroy -r rpool/copyroot
13) zfs destroy -r rpool/ROOT/ubuntu_<x>@copy
14) zpool export rpool
15) reboot
For some reason this first boot gets stuck on the UEFI spinning screen, wait a few minutes then reset the machine and it will boot properly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment