ZFS Guide: https://github.com/zfsonlinux/zfs/wiki/Ubuntu-18.04-Root-on-ZFS Ubuntu manual install: https://help.ubuntu.com/lts/installation-guide/amd64/apds04.html#idm45680433488064 https://wiki.archlinux.org/index.php/Fstab https://wiki.debian.org/fstab https://help.ubuntu.com/community/CreateBootPartitionAfterInstall#Add_.2Fboot_to_your_.2Fetc.2Ffstab
System prep:
setxkbmap -option "ctrl:swap_lalt_lctl"
sudo apt update
apt install --yes debootstrap gdisk zfs-initramfs
Dataset options. Didn't have to create our dataset, so review option differences and set them:
# Didn't run this, already have a pool
# zpool create -o ashift=12 \
# -O acltype=posixacl -O canmount=off -O compression=lz4 \
# -O dnodesize=auto -O normalization=formD -O relatime=on -O xattr=sa \
# -O mountpoint=/ -R /mnt \
# rpool /dev/mapper/luks1
# Import our existing pool
cryptsetup luksOpen /dev/disk/by-partlabel/samd-store samd-crypt
zpool import -NR /mnt/zstore zstore
root@xubuntu:/mnt/boot# zfs get acltype,canmount,compression,dnodesize,normalization,relatime,xattr zstore
NAME PROPERTY VALUE SOURCE
zstore acltype off default
zstore canmount on default
zstore compression lz4 local
zstore dnodesize legacy default
zstore normalization none -
zstore relatime on local
zstore xattr on default
zfs create \
-o canmount=off \
-o mountpoint=none \
-o dnodesize=auto \
-o normalization=formD \
-o xattr=sa \
-o acltype=posixacl \
zstore/xubu1904
# start fresh if you want
zfs umount -a
zfs destroy -r zstore/xubu1904
rm -rf /mnt/zstore
# Just a container that gives children mountpoints through inheritance
zfs create -o canmount=off -o mountpoint=/ zstore/xubu1904
# Have to create and mount this now, or the mounts that happen later prevent this mount from happening
# b/c the directory is not empty
zfs create -o canmount=noauto -o mountpoint=/ zstore/xubu1904/os
zfs mount zstore/xubu1904/os
# Another container, has to be present to create the other var datasets below, but we will never mount this
zfs create -o canmount=off zstore/xubu1904/var
# Separate dataset for logs so that if we rollback a snapshot, we don't lose logs for troubleshooting.
zfs create zstore/xubu1904/var/log
# Datasets that should not be in a snapshot
zfs create -o com.sun:auto-snapshot=false zstore/xubu1904/var/cache
zfs create -o com.sun:auto-snapshot=false zstore/xubu1904/var/tmp
# Special settings see Arch wiki for details:
# https://wiki.archlinux.org/index.php/ZFS
zfs create -o recordsize=8K \
-o primarycache=metadata \
-o mountpoint=/var/lib/postgresql \
-o logbias=throughput \
zstore/xubu1904/postgresql
zfs create -o com.sun:auto-snapshot=false -o setuid=off -o devices=off -o sync=disabled zstore/xubu1904/tmp
zfs list -r -o name,canmount,mountpoint zstore/xubu1904
chmod 1777 /mnt/zstore/var/tmp
chmod 1777 /mnt/zstore/tmp
debootstrap disco /mnt/zstore
zfs set devices=off zstore
mount /dev/disk/by-partlabel/boot /mnt/zstore/boot
mount --rbind /dev /mnt/zstore/dev
mount --rbind /proc /mnt/zstore/proc
mount --rbind /sys /mnt/zstore/sys
chroot /mnt/zstore /bin/bash --login
# Don't need this, already done
# ln -s /proc/self/mounts /etc/mtab
apt update
# Select en_US.UTF-8 and make it the default
dpkg-reconfigure locales
dpkg-reconfigure tzdata
apt install --yes --no-install-recommends linux-image-generic
apt install --yes zfs-initramfs
apt install --yes cryptsetup
blkid -s UUID -o value /dev/disk/by-partlabel/samd-store
# 61a576d8-e705-4c4a-95aa-19c2d9644d8c
echo samd-crypt UUID=61a576d8-e705-4c4a-95aa-19c2d9644d8c none luks,discard,initramfs > /etc/crypttab
# mounts
umount /boot/efi
cp /boot/xubu1904/fstab /etc/fstab
# User & groups
addgroup --system lpadmin
addgroup --system sambashare
adduser --no-create-home rsyring
usermod -a -G adm,cdrom,dip,lpadmin,plugdev,sambashare,sudo rsyring
# Packages
apt dist-upgrade --yes
apt install --yes ubuntu-desktop
# Prep boot
zpool set bootfs=zstore/xubu1904/os zstore
# Disable log compression since zfs is already compressing data
for file in /etc/logrotate.d/* ; do
if grep -Eq "(^|[^#y])compress" "$file" ; then
sed -i -r "s/(^|[^#y])(compress)/\1#\2/" "$file"
fi
done
# Connect to the internet first
./mount-zstore.sh
chroot /mnt/zstore /bin/bash --login
exit
./mount-zstore.sh
mkdir /tmp/initrdmount
unmkinitramfs /boot/initrd.img-5.0.0-15-generic /tmp/initrdimg/
lsinitramfs /boot/initrd.img-5.0.0-15-generic
lsinitramfs boot/initrd.img-5.0.0-15-generic | grep crypt
- Have ZFS mount all filesystems in initrc using /etc/defaults/zfs
- rpool=
- root=zfs:AUTO
- root=ZFS=zstore/xubu1904/os
- zfsdebug=on
- Set kernel boot option
- update-initramfs -u -k all
- reconfigure blueman
- swap?