ZFS Install Guide


This wiki will show you how to install Funtoo on ZFS (rootfs).



ZFS designed for 64-bit systems. We only recommending and supporting 64-bit platforms and installations!

ZFS recommendation is to control entire disk, hence, guide reflecting only installing ZFS on whole disk and legacy boot. Installing on UEFI requires separate partition for /boot, formatted into FAT32 and not covered here, though, installation on UEFI is certainly possible. Guide also not describing anything related to encryption.

Downloading the ISO (With ZFS)

In order to install Funtoo on ZFS, you will need an environment such as live media with ZFS tools provided.

Creating a bootable USB from ISO (From a Linux Environment)

After you download the iso, you can do the following steps to create a bootable USB: TBA.

Booting the ISO

Creating ZFS partitions

We are letting ZFS automatically partition the drive. We use "partition" term, so it would be more familiar for many.

Creating of pool

#  mkdir /mnt/funtoo
#  zpool create -f -o ashift=12 -o cachefile=/tmp/zpool.cache -O normalization=formD -m none -R /mnt/funtoo -d -o feature@async_destroy=enabled -o feature@empty_bpobj=enabled -o feature@lz4_compress=enabled -o feature@spacemap_histogram=enabled -o feature@enabled_txg=enabled -o feature@extensible_dataset=enabled -o feature@bookmarks=enabled rpool /dev/sda

ashift 12 stands for 4-K block size sectors. Such type of hard drives are common nowadays.

Pool name is irrelevant, rpool used in this guide.

Create the zfs datasets

Create rootfs

#  zfs create -o mountpoint=none rpool/ROOT
#  zfs create -o mountpoint=/ rpool/ROOT/funtoo

Create optional datasets

Described below datasets are examples and optional. It's up to users to perform creation of their own datasets.

#  zfs create -o mountpoint=/home rpool/HOME
#  zfs create -o mountpoint=/root rpool/HOME/root
Portage directories
#  zfs create -o mountpoint=none -o setuid=off rpool/FUNTOO
#  zfs create -o mountpoint=/usr/portage -o atime=off rpool/FUNTOO/portage
#  zfs create -o mountpoint=/usr/portage/distfiles rpool/FUNTOO/distfiles
Build directory
#  zfs create -o mountpoint=/var/tmp/portage -o compression=lz4 -o sync=disabled rpool/FUNTOO/build
Setting bootfs

When booting from ZFS, you must specify a boot device and a root file system within the pool that was identified by the boot device. By default, the dataset selected for booting is the one identified by the pool's bootfs property.

# zpool set bootfs=rpool/ROOT/funtoo rpool

Installing Funtoo

Now that initial ZFS pool created, datasets ready, we can perform stage3 unpack and basic system installation. This part does not differ much from regular Funtoo Linux installation. http://www.funtoo.org/Install#Installing_the_Stage_3_tarball. We recommend using funtoo-current stages for ZFS.

# cd /mnt/funtoo
# wget http://build.funtoo.org/funtoo-current/x86-64bit/generic_64/stage3-latest.tar.xz
Extract the contents with the following command, substituting in the actual name of your stage 3 tarball (in case of arch optimized stage).

# tar xpf stage3-latest.tar.xz
Now we need to create chroot environment by following:

# cd /mnt/funtoo
# mount -t proc none proc
# mount --rbind /sys sys
# mount --rbind /dev dev
Important step is to copy ZFS cache we created at the very beginning of our rpool creation into chroot.

# mkdir -p /mnt/funtoo/etc/zfs
# cp /tmp/zpool.cache /mnt/funtoo/etc/zfs/zpool.cache
You'll also want to copy over resolv.conf in order to have proper resolution of Internet hostnames from inside the chroot:

# cp /etc/resolv.conf /mnt/funtoo/etc/

We are ready to chroot

# chroot /mnt/funtoo /bin/bash
# export PS1="(chroot) $PS1"; cd

Installing ZFS userspace and bootloader

Installing the ZFS userspace tools and kernel modules

In order to install ZFS packages we need to get portage tree first:

# emerge --sync
# emerge sys-fs/zfs

Installing GRUB 2

Install grub2:

# echo "sys-boot/grub libzfs" >> /etc/portage/package.use
# emerge grub

Initial kernel build

Funtoo stage3 have precompiled kernel but initramfs needs rebuilding to include ZFS binaries. This possible with --zfs argument:

# genkernel initramfs --no-clean --no-mountboot --zfs

Configuring the Bootloader

sys-boot/grub require small partition, called Bios boot partition. Remember, that we let ZFS partition whole drive. By design, during this, a very small unpartitioned space left at the beginning of the disk. We will use sgdisk, which is part of sys-apps/gptfdisk to format free space into BIOS partition.

# sgdisk --new=2:48:2047 --typecode=2:EF02 --change-name=2:"BIOS boot partition" /dev/sda

Installing GRUB2 to disk is as easy as:

# grub-install /dev/sda
Now it's time for us to create grub's configuration file:

# grub-mkconfig -O /boot/grub/grub.cfg

Final configuration

After reboot

Forgot to reset password?


Starting from scratch

Starting again reusing the same disk partitions and the same pool