Skip to content

Instantly share code, notes, and snippets.

@felix-schwarz
Last active March 10, 2020 15:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save felix-schwarz/2a9ef78effb26e9d940b9fcbfb1285c1 to your computer and use it in GitHub Desktop.
Save felix-schwarz/2a9ef78effb26e9d940b9fcbfb1285c1 to your computer and use it in GitHub Desktop.
How-To: install Ubunutu 18.04 LTS on ZFS root

How-To: install Ubunutu 18.04 LTS on ZFS root

DISCLAIMER: make sure you have backed up all your data before following these steps. Use these steps solely on your own risk!

Basic install

  • Install Ubuntu 18.04 using server installer, but change partitioning as follows
EFI partition: 1gb
/boot partition ext4: 1gb
/ partition ext4: 4gb (or size for swap usage)

Prepare and partition for ZFS

  • Update to latest
apt-get update && apt-get upgrade
  • Add latest ZFS version
add-apt-repository --yes ppa:jonathonf/zfs
  • Install zfs tools
apt install zfs-dkms zfs-initramfs gdisk
  • Add partitions to partition table
gdisk /dev/sda
  • Enter n for new partition
  • Enter +512G as size and a504 as partition type
  • Enter p to see partition table
  • Enter w to write partition table
  • Repeat for sdb
  • Reboot
  • Create pool
zpool create -o ashift=12 -O atime=off -O compression=lz4 tank mirror /dev/disk/by-id/XXXXXpartX  /dev/disk/by-id/YYYYYpartY
  • Create datasets

zfs create -o mountpoint=none -o canmount=off tank/os
zfs create tank/os/root
  • Copy / to ZFS
rsync -a --one-file-system / /tank/os/root/

Make system bootable

  • Change into chroot environment
cd /tank/os/root
mount --bind /boot boot
mount --bind /dev dev
mount --bind /proc proc
mount --bind /sys sys
mount --bind /run run
chroot .

Update grub

update-grub
grub-install /dev/sda
grub-install /dev/sdb

Reboot and select ext4 install

exit
reboot

Set root mountpoint

zfs set mountpoint=legacy /tank/os/root/

Reboot into ZFS system

reboot

Verify ZFS is now root OS

zfs list

Diagnostic: check for ZFS in initrd

$ lsinitramfs /boot/initrd.img-4.8.0-58-generic | grep zfs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment