Create disk labels and partitions

This section is for disks you want to erase completely and make into ZFS pool members.

grub-probe doesn’t support whole-disk device pools [TODO: Check these facts], so the disks we use in zfs pools must hold a disk label, and the partitions in it are pool devices instead. [Actually, grub-probe doesn’t support luks either. grub-probe might not support a lot of things, but that can be worked around by manually setting GRUB_DEVICE in /etc/default/grub to the real or mapped device which holds the zfs pool(s). This may also require editing line 139 of/usr/sbin/grub_mkconfig to ignore grub-probe errors. ]

AND, a single large partition can be mis-interpreted as whole-disk [TODO: Check these facts], so add a little partition at the end to keep the device scanner from finding it. We might as well use that as an EFI system partition. [TODO: Does ZFS handle EFI system data already, without this? EDIT: Almost certainly not. It might even be a good idea to also create a boot ext2 partition, similar to how booting from luks usually works. ]

As an example, to initialize a disk (using disk id because it’s safer to use descriptions than arbitrary floating letters like sd-a, b, c):

1

2

3

4

5

6

$sudo parted--/dev/disk/by-id/ata-ST9999999999_10000000\

mklabel gptY\

mkpart zfs zfs0%-512MB\

mkpart efi fat32-512MB100%\

set2boot on

Create the pool

Hereafter we’ll assume a pool name of “alexandria”, after the famous library, in the examples, but you can use anything you wish. It’s a proper name, and you get to decide what to call this group of storage devices.

Also, this uses the “raidz” organizing type for its new virtual device. Read the “zpool” man page for what the different virtual device types are. This is up to you. Don’t just follow this example. Know what organization you want to have with your devices and fill in the pieces here. You can also add devices later.

Create the root filesystem

Assuming pool name “alexandria”…

1

2

3

$sudo zfs create alexandria/ROOT

$sudo zfs create alexandria/ROOT/ubuntu-1

Copy data from old root to new

If you’re installing fresh, you can skip this section. [TODO: *Since Ubiquity doesn’t support ZFS yet, you actually cannot do a straight fresh install. You have to install to a temporary place and copy the files to zfs. This can be a second device, or a Zvol on the pool. Install Ubuntu using Ubiquity, mount the zvol/device, then continuing with below.]

Assuming pool name “alexandria”…

1

2

3

4

$sudo mkdir/tmp/oldroot

$sudo mount--bind/!$

$sudo rsync-avPX/tmp/oldroot/./alexandria/ROOT/ubuntu-1/.# [Do we need `-H`, `-A`, or `-W` flags? Why use `-P`? Also, it might be simpler to use `--one-file-system` rsync flag, like so: `rsync --one-file-system -aAXHW / /alexandria/ROOT/ubuntu-1/`. But are we really instructing people to do the copy on a running system?]

Clean up fstab and prepare grub

Assuming pool name “alexandria”…

Remove the root mount lines from /alexandria/ROOT/ubuntu-1/etc/fstab

[TODO: We don’t need to set boot, rpool, or bootfs. root=ZFS=alexandria/ROOT/ubuntu-1is all that’s necessary. Moreover, update-grub via /etc/grub/10_linux does plenty of work to detect the correct zpool and volume and set root itself. In /etc/default/grub, I only had to specify GRUB_DEVICE because grub-probe failed (see note above).]

Finish installation

Migrating path users, skip this section.

If you’re in the install-fresh path, you will need to signal the advanced settings where you will be mounting the zfs device. Don’t format it. ZFS carries its own formatting and you should leave it alone. [TODO: verify ubiquity will recognize zfs devices as mountable and ready for install]