Skip to content

HOWTO install Ubuntu 16.10 to a Whole Disk Native ZFS Root Filesystem using Ubiquity GUI installer

Garrett Fields edited this page Jan 4, 2017 · 4 revisions

HOWTO install Ubuntu 16.10 to a Whole Disk Native ZFS Root Filesystem using Ubiquity GUI installer

Currently, the Ubiquity installer in 16.10 does not support the ZFS filesystem. Nor does the installation environment have zfs tools preinstalled. This WIKI explains how to make the installer ZFS capable, install to a ZFS zvol formatted as ext4, then concludes as if you are migrating an existing installation to ZFS. This method is unique to other methods because it utilizes ZFS whole disk formatting and does not require multiple hard drives.

System Requirements

  • 64-bit Ubuntu 16.10 boot/install CD/USB/DVD, full installer not server, netboot or alternative
  • 16Gb+ drive that is or can be completely wiped
  • 4GB memory recommended

Strategy

The Ubiquity installer for 16.10 does not recognize the ZFS filesystem as a usable target, however it can be installed to a ZFS Zvol then manually copied to the ZFS filesystem.

It is best practice, to use devices found in "/dev/disk/by-id/", not /dev/ when creating pools. Some prefer to use "wwn-" devices listed in this directory, however not all devices have these identifiers. Please inventory what you have in your system and use the proper device names as you go along. In the examples below, we'll use a single disk "/dev/disk/by-id/ata-ST9999999999_10000000".

Install ZFS packages to the install environment

As you boot off fresh Ubuntu 16.10 GUI media, it is not ZFS aware. As you start the media, Select "Try Ubuntu", then open the terminal. First activate Ubuntu's "universe" repository, then install the zfs tools. We then create a pool and a ZVOL within that pool. The example below is a single disk pool. Feel free to create mirror or raidz(x) configurations if you wish. Doing so is beyond the scope of this wiki. Following the pool creation, we create 10G zvol within the pool. This creates a block device that can be used just as a physical drive.

$ sudo su
# apt-add-repository universe
# apt-get update
# apt-get install zfs-initramfs
# zpool create -f -o ashift=12 -O atime=off -O compression=lz4 -O normalization=formD alexandria /dev/disk/by-id/ata-ST9999999999_10000000
# zfs create -V 10G alexandria/ubuntu-temp

Run the Ubiquity Installer

From the desktop of the GUI, Start the "Install Ubuntu"

Choose any options you wish until you get to the "Installation Type" screen and select "Something Else"

Listed in the drive section, you will see "/dev/zd0". Select it and choose "New Partition Table". Then, Select /dev/zd0 Free Space and press the "+" button. Select EXT4 and mountpoint=/ In the Bootloader dropdown, select "/dev/zd0" Press "Install Now"

Additional Screens will come up such as timezone and user account creation. Complete these with your information. Eventually you will get an error about the bootloader not being able to be installed. Choose "Continue without a bootloader" At the end of the install select "Continue testing"

Copy your Ubuntu image to the ZFS filesystem

Now you will mount your Zvol, create your ZFS filesystem, then rsync your Ubuntu install from the ZVOL to the zfs filesystem. This example shows how to make a single filesystem for your system. If you wish to have additional filesystems, for example /home or /var, you can create them also before the rsync. Creation and setting mountpoints are beyond the scope of this wiki.

In the terminal ("sudo su" again if you closed the previous window):

# mount /dev/zd0p1 /mnt
# zfs create alexandria/ROOT
# zfs create alexandria/ROOT/ubuntu-1
# rsync -avPX /mnt/. /alexandria/ROOT/ubuntu-1/.

Prepare your ZFS filesystem copy of Ubuntu to be ZFS aware

Your ZFS filesystem needs to have ZFS support added so it can understand itself after reboot. We connect the active /proc, /dev, and /sys mounts to the ZFS filesystem copy and chroot into it. We give it a nameserver, update the repositories, and install zfs binaries. Finally, we remove the root filesystem from fstab, since zfs does this mounting for us.

# for d in proc sys dev; do mount --bind /$d /alexandria/ROOT/ubuntu-1/$d; done
# chroot /alexandria/ROOT/ubuntu-1
# echo "nameserver 8.8.8.8" | tee -a /etc/resolv.conf
# apt-get update
# apt-get install zfs-initramfs
# nano /etc/fstab         ## comment out the line for mountpoint "/"

Create a BIOS Grub partion and install Grub

ZFS whole disk formatting uses GPT partitioning. In order to boot a GPT disk, you need to EFI boot with an EFI partition present, or legacy boot with a GRUB BIOS partition present. The structure created by ZFS whole disk formatting will only allow for the latter to be done. In this section, we create a tiny GRUB BIOS partition in an unused section at the beginning of the drive, create a symbolic link in /dev because grub misidentifies zfs disks, and finally update and install grub to the disk. If you created a multi-disk pool, this should be repeat the "sgdisk" and "ln" commands for all the disks in the pool, then update-grub, followed by "grub-install" against all your disks, so they are all capable of being the boot drive.

# sgdisk -a1 -n2:512:2047 -t2:EF02 /dev/disk/by-id/ata-ST9999999999_10000000
# ln -sf /dev/ata-ST9999999999_10000000-part1 /dev/ata-ST9999999999_10000000
# update-grub
# grub-install /dev/disk/by-id/ata-ST9999999999_10000000

Set Mountpoint and reboot

We now exit the chroot, unmount the /dev, /sys, and /proc from /alexandria/ROOT/ubuntu-1, as well as /alexandria/ROOT/ubuntu-1 itself. We set our ZFS filesystem's mountpoint variable to /, snapshot our filesystem (optional), unmount our Zvol, then export our pool, then finally reboot.

# exit
# umount -R /alexandria/ROOT/ubuntu-1
# zfs set mountpoint=/ alexandria/ROOT/ubuntu-1
# zfs snapshot alexandria/ROOT/ubuntu-1@pre-reboot
# umount /mnt
# zpool export alexandria
# shutdown -r 0

Finish installation

Congratulations, you should have successfully booted Ubuntu 16.10 using ZFS. The remaining steps are all optional. We will do a post install snapshot, destroy the ZVOL used during the installation, and run ubuntu updates. In terminal:

$ sudo zfs snapshot alexandria/ROOT/ubuntu-1@post-reboot
$ sudo zfs destroy alexandria/ubuntu-temp
$ sudo apt-get update
$ sudo apt-get dist-upgrade
$ sudo zfs snapshot alexandria/ROOT/ubuntu-1@post-reboot-updates