I had previously installed Debian with ZFSBootMenu, but wanted to switch to Kubuntu for the KDE LTS support and newer kernel.
Here’s what I did to install Kubuntu with ZFSBootMenu and encrypted home directories. It’s pretty slick. The root is unencrypted, and each user’s home directory is encrypted with their password and unlocked when they login.
Do all the steps to install Ubuntu up through and including “ZFS Configuration” with an unencrypted pool, then (while still in chroot), insert these steps:
Install Kubuntu:
Block GRUB (this allows installing recommends when installing Kubuntu):
cat <<EOF > /etc/apt/preferences.d/no-grub
Package: grub-pc* grub-efi* os-prober
Pin: release *
Pin-Priority: -1
EOF
Install the kubuntu-desktop metapackage.
apt install ubuntu-standard kubuntu-desktop language-pack-en
Configure Kubuntu
Enable networking
cat <<EOF > /etc/netplan/01-network-manager-all.yaml
# Let NetworkManager manage all devices on this system
network:
version: 2
renderer: NetworkManager
EOF
chmod 600 /etc/netplan/01-network-manager-all.yaml
Enable the graphical login
systemctl enable sddm
systemctl set-default graphical.target
Show splash screen
zfs set org.zfsbootmenu:commandline="quiet splash" zroot/ROOT
Add users (repeat steps 3 & 4 for each user):
USERNAME=username-you-want-to-create
Add your user and set a password:
adduser ${USERNAME}
Add your new user to the sudo group:
usermod -aG sudo ${USERNAME}
Create zfs datasets for each user:
Create a new zfs dataset for the new user, use the same password as the login:
zfs create -o encryption=aes-256-gcm -o keyformat=passphrase -o keylocation=prompt zroot/home/${USERNAME}
Create datasets for other directories:
zfs create zroot/home/${USERNAME}/Documents
zfs create zroot/home/${USERNAME}/Downloads
zfs create zroot/home/${USERNAME}/Pictures
Copy in the starting files
cp -a /etc/skel/. /home/${USERNAME}/
Change the ownership on the mountpoint of the dataset to the new user:
chown -R ${USERNAME}:${USERNAME} /home/${USERNAME}
chmod -R 750 /home/${USERNAME}
Setup the ZFS PAM module to unlock and mount the user’s home directory dataset when they login
Install libpam-zfs
apt install libpam-zfs
Edit the PAM configuration file for the ZFS module:
cat <<EOF > /usr/share/pam-configs/zfs_key
Name: Unlock zfs datasets for user
Default: yes
Priority: 1024
Auth-Type: Additional
Auth:
[success=1 default=ignore] pam_succeed_if.so service = polkit-1
optional pam_zfs_key.so homes=zroot/home mount_recursively
Session-Type: Additional
Session:
optional pam_zfs_key.so homes=zroot/home mount_recursively
Password-Type: Additional
Password:
optional pam_zfs_key.so homes=zroot/home mount_recursively
EOF
Update PAM to include the new module
pam-auth-update
Then continue one with the rest of the steps from ZFSBootMenu (continuing with “Install and configure ZFSBootMenu”).