ZFS on Root guide

This guide assumes you have already created your partition layout needed for your system. We will also assume your partition layout is:

  /dev/sda1 /boot (formatted with vfat)
  /dev/sda2 /
Install ZFS module

Note: The adding of the archzfs-testing repo and pacman -Sy zfs-dkms will also need to be done inside chroot.
First we need to install the ZFS binaries we need and also the kernel module.

In /etc/pacman.conf add:

 Server = https://archzfs.com/$repo/$arch

Now we need to add ArchZFS's gpg key to pacman

 wget https://archzfs.com/archzfs.gpg
 pacman-key -a archzfs.gpg

Note: this will also need to be done inside chroot

Now we need to initialize pacman keyring

 pacman-key --init
 pacman-key --populate artix
 pacman-key -r F75D9D76
 pacman-key --lsign-key F75D9D76

Install ZFS module

 pacman -Sy zfs-dkms

Load the module

 modprobe zfs
Create the ZFS pool

Next we create the ZFS pool, named zroot.
This is to create a standard single pool, no mirror or RAID

 zpool create -o ashift=12 zroot /dev/sda2
Create the ZFS datasets

Next, decide how you want your ZFS datasets(can be looked as partitions) to be laid out.
Create your layout how you want now, or it is near impossible to redo besides doing another install

The following is how I do my basic layout

 zfs set atime=off zroot
 zfs set relatime=on zroot
 zfs create -o compression=lz4 -o mountpoint=none zroot/ROOT
 zfs create -o compression=lz4 -o mountpoint=/ zroot/ROOT/default
 zfs create -o compression=lz4 -o mountpoint=none zroot/HOME
 zfs create -o compression=lz4 -o mountpoint=/home/{USERNAME} zroot/HOME/{USERNAME}
Set ZFS pool to import

Tell the bootloader which pool to import/use

 zpool set bootfs=zroot/ROOT/default zroot

Set ZFS' cachefile

 zpool set cachefile=/etc/zfs/zpool.cache zroot
Artix install preparation

Now we need to export the pool

 zpool export zroot

Now we import the pool, prior to installation. This mounts the pool to the location we need to install Artix Linux in.

 zpool import -d /dev/sda2 -R /mnt zroot

Create the boot directory and mount

 mkdir /mnt/boot
 mount /dev/sda1 /mnt/boot

Now you can follow Installation


General ZFS information

 The more memory you have the better ZFS will do, as ZFS itself uses memory for it's L2ARC for cache
 which is one thing that generally makes ZFS feel faster. I personally run ZFS on a 8GB RAM system fine.

Boot Manager

 I recommend using rEFInd boot manager with ZFS, as it makes it easier, but you can choose to use GRUB and follow guides
on how to configure it.

After installing rEFInd and following the install guide
Create a linux_refind.conf in /boot with the following

 "Boot Artix Linux" "root=ZFS=bootfs rw"

Dataset does not auto mount


Create a zfs init script in /etc/init.d with the following:

 command="zfs mount -a"

Make the init script execuatable:

 chmod +x /etc/init.d/zfs

Add zfs to default runlevel

 rc-update add zfs default

mkinitcpio hook

We also need to add a ZFS hook to the mkinitcpio.conf
Edit /etc/mkinitcpio.conf and change the hook to look like this:

 HOOKS=(base udev autodetect modconf block keyboard zfs filesystems)


 Following the normal installation guide, only add your /boot information, as ZFS does not need to be in it.
 If you created a swap partition add it also to the fstab.


 Currently kmod-27-1 has issue with linux-lts-5.4.20. Downgrade to kmod-26-3

Multiple ZFS partitions

 Only one ZFS partition should be on a single disk, as ZFS auto imports datasets and would cause file conflicts.
 For example, one pool has /usr/bin and another pool's /usr/bin gets imported as well.