Installing Arch Linux on ZFS
The Zettabyte File System (ZFS) is an advanced copy-on-write filesystem designed to preserve data integrity from a multitude of possible corruption scenarios as well as provide simple administration features. ZFS makes disk administration effortless with support ZFS storage pools (zpools) and automatic mount handling. First released in 2005 for Solaris OS, ZFS has since become the flag bearer for next generation filesystems.
ZFS was first developed and released by Sun (now owned by Oracle) as Open Source Software licensed under the Common Development and Distribution License (CDDL) which is famously incompatible with the GNU Public License. This incompatiblity prevents ZFS from being merged into the mainline kernel, and generally presents some obsticles for users that want to use ZFS in Linux.
- 1 Notes before installation
- 2 Boot from the installation media
- 3 Setup pacman
- 4 Install needed packages
- 5 Partition the destination drive
- 6 Format the destination disk
- 7 Setup the ZFS filesystem
Notes before installation
- This guide uses the unofficial archzfs repository hosted at http://demizerone.com/archzfs. This repository is maintained by Jesus Alvarez and is signed with his PGP key: 0EE7A126.
- The ZFS packages are tied to the kernel version they were built against. This means it will not be possible to perform kernel updates until new packages (or package sources) are released by the ZFS package maintainer.
- This guide currently targets UEFI compatible systems. It should be relatively easy to install ZFS on bios compatible systems using this guide. The sections for BIOS installions exist in this article as stubs to allow easy contributions of content.
Boot from the installation media
If you have an existing Arch Linux installation handy, it is possible to create a custom archiso installation media with the ZFS tools pre-installed by following this guide.
Otherwise, you will need the latest archise installation media burned to a CD or a USB key. If you are installing onto a UEFI system, see Unified Extensible Firmware Interface#Create UEFI bootable USB from ISO for creating UEFI compatible installation media.
Activate the required network connection and then edit
/etc/pacman.d/mirrorlist and configure the mirrors for pacman to use. Once that is done, edit
/etc/pacman.conf and add the archzfs repository:
# nano /etc/pacman.conf
[archzfs] Server = http://demizerone.com/archzfs/archiso/$arch
Next, add the archzfs maintainer's PGP key to the local trust:
# pacman-key -r 0EE7A126 # pacman-key --lsign-key 0EE7A126
Finally, update the pacman databases,
# pacman -Syy
Install needed packages
This is also the best time to install your favorite text editor, otherwise nano will have to be used.
# pacman -S archzfs dosfstools gptfdisk vim
Partition the destination drive
Use the cgdisk partition utility and create a GPT partition table:
Part Size Type ==== ===== ============= 1 512M EFI (ef00) 2 512M Ext4 (8200) 2 XXXG Solaris Root (bf00)
This section has not been written yet.
Format the destination disk
Format the EFI partition to FAT32
mkfs.vfat -F 32 /dev/sda1 -n EFIBOOT
Format the Ext4 boot partition
mkfs.ext4 /dev/sda2 -L BOOT
This section has not been written yet.
Setup the ZFS filesystem
First, make sure the ZFS modules are loaded,
# modprobe zfs
Create the root zpool
# zpool create rpool /dev/disk/by-id/<id-to-partition>
Create the root filesystem
# zfs create rpool/ROOT
create the decendent file system that will hold the installation:
# zfs create rpool/ROOT/arch
We will set the mountpoints after we have created the filesystems so that they are not mounted automatically by ZFS.
If so desired, sub-filesystem mount points such as /home and /root can be created with the following commands:
# zfs create rpool/HOME # zfs create rpool/HOME/root
For safety, umount all zfs filesystems if they are mounted:
# zfs umount -a
Configure the root filesystem
Now it is time to set the mount point of the root filesystem:
# zfs set mountpoint=/ rpool/ROOT/arch
and optionally, any sub-filesystems:
# zfs set mountpoint=/home rpool/HOME # zfs set mountpoint=/root rpool/HOME/root
Set the bootfs property on the decendent root filesystem so the bootloader knows where to find the operating system.
# zpool set bootfs=rpool/ROOT/arch rpool
Export the pool,
# zpool export rpool
Finally, re-import the pool,
# zpool import -d /dev/disk/by-id -R /mnt rpool
If there is an error in this step, you can export the pool to redo the command. The ZFS filesystem is now ready to use.