OpenZFS
OpenZFS, formerly ZFS on Linux, is a project aimed at bringing the ZFS file system to the Linux kernel.
If using a BSD, ZFS should be supported out of the box.
Contents
Installation
Arch
The first step is almost always downgrading the kernel.
version=major.minor.patch-release sudo pacman -U https://archive.archlinux.org/packages/l/linux-lts/linux-lts-$version-x86_64.pkg.tar.zst https://archive.archlinux.org/packages/l/linux-lts-headers/linux-lts-headers-$version-x86_64.pkg.tar.zst sudo mkinitcpio -P sudo grub-mkconfig -o /boot/grub/grub.cfg
To determine which kernel version is supported, try installing ZFS from the unofficial repository.
sudo pacman-key -r DDF7DB817396A49B2A2723F7403BD972F75D9D76 sudo pacman-key --lsign-key DDF7DB817396A49B2A2723F7403BD972F75D9D76 sudo bash -c 'echo "[archzfs]\nServer = https://archzfs.com/$repo/$arch\n" >> /etc/pacman.conf' sudo pacman -Syu archzfs-linux
If the last command gives an error about an unsatisfiable dependency involving the kernel, the indicated version is what to use in the above snippet.
With a supported kernel and the ZFS module installed, try booting.
Pools
The lowest level of ZFS is pools.
Identify disks by their IDs like:
$ ls -lh /dev/disk/by-id/ total 0 lrwxrwxrwx 1 root root 1 Jan 01 12:30 ata-ABCDE lrwxrwxrwx 1 root root 1 Jan 01 12:30 ata-FGHIJ lrwxrwxrwx 1 root root 1 Jan 01 12:30 ata-KLMNO lrwxrwxrwx 1 root root 1 Jan 01 12:30 ata-PQRST
With these 4 drives of N GB storage each, create a RAIDz2 pool where 2N GB will be dedicated to parity rather than storage. The pool will be fault tolerant for up to 2 failed drives.
sudo zpool create -f tank raidz2 ata-ABCDE ata-FGHIJ ata-KLMNO ata-PQRST
Alternatively create a RAIDz1 pool where just N GB will be dedicated to parity (but the pool will only be fault tolerant of 1 drive failure).
Alternatively alternatively, create a Mirror pool to maximize fault tolerance (up to 3 failed drives) but leaving just N GB of storage.
Pools can be created with encryption, but it is not recommended. A pool's encryption setting is inherited, so the pool is permanently locked to this singular cryptographic algorithm.
The pool will be mounted to a root-level directory named after the pool (/tank in this case).
Check the status of pools with zpool status.
To ensure that the pools mount at boot, try:
sudo systemctl enable zfs-import-cache.service zfs.target zfs-import.target
Datasets
To create a dataset within a pool, try:
sudo zfs create tank/data
To create an encrypted dataset, try:
sudo zfs create -o encryption=on -o keyformat=passphrase tank/enc
The default cryptographic algorithm is aes-256-gcm.
To mount an encrypted dataset, try:
sudo zfs load-key tank/enc sudo zfs mount tank/enc
Administration
Consider disabling access times.
sudo zfs set atime=off tank # or sudo zfs set atime=off tank/data
Consider enabling compression. Upstream considers this to be a reasonable default, even for uncompressible files.
sudo zfs set compression=on tank
The default compression algorithm is lz4.
ZFS pools must be scrubbed to ensure that bit rot is addressed before backups are lost. To trigger this manually, try:
sudo zpool scrub tank
Alternatively, enable a timer to automate this:
sudo systemctl enable [email protected]