Low Orbit Flux Logo 2 F

CentOS ZFS

CentOS ZFS

We are going to cover installing ZFS on CentOS. These instructions should work pretty well for RHEL too. Ubuntu is better. Ubuntu provides the ZFS packages right in their own repos so you don’t have to add any additional repos to get it working. If you’re here you probably have a reason for wanting to know about Centos ZFS. It is still a totally valid choice of distro. There is nothing wrong with CentOS or RHEL they can both still run ZFS very well.

CentOS ZFS Install Steps

Install the repo for your version of CentOS or RHEL. You will use this command but you will need to swap out <dist> for your version.


sudo yum install http://download.zfsonlinux.org/epel/zfs-release.<dist>.noarch.rpm

Here are a few examples:

RHEL / CentOS 7.3 Package:


sudo yum install http://download.zfsonlinux.org/epel/zfs-release.el7_3.noarch.rpm

RHEL / CentOS 7.4 Package:


sudo yum install http://download.zfsonlinux.org/epel/zfs-release.el7_4.noarch.rpm

RHEL / CentOS 8.1 Package:


sudo yum install http://download.zfsonlinux.org/epel/zfs-release.el8_1.noarch.rpm

Check here for more repos:

Check the finger print to make sure it hasn’t been tampered with.


gpg --quiet --with-fingerprint /etc/pki/rpm-gpg/RPM-GPG-KEY-zfsonlinux

The finger print will look like this:


pub  2048R/F14AB620 2013-03-21 ZFS on Linux <zfs@zfsonlinux.org>
      Key fingerprint = C93A FFFD 9F3F 7B03 C310  CEB6 A9D5 A1C0 F14A B620
sub  2048R/99685629 2013-03-21

DKMS vs kABI

Only pick one of these.

kABI-tracking kmod

To use kABI instead of DKMS set “enabled=0” for the dkms repo and “enabled=1” for the kmod repo in this file:


sudo vi /etc/yum.repos.d/zfs.repo

Install ZFS:


sudo yum update -y
sudo yum install zfs

DKMS


sudo yum install epel-release
sudo yum update -y
sudo yum install "kernel-devel-uname-r == $(uname -r)" zfs

CentOS ZFS - Keep Going

Now that you’ve installed the packages you can reboot:


sudo reboot

Check if the module is loaded:


sudo lsmod | grep zfs

If not, load it and check again:


sudo modprobe zfs
sudo lsmod | grep zfs

Test it. Check your device names and use them to create a zpool.


sudo lsblk
sudo zpool create pool1 /dev/sdb /dev/sdc

Check that it worked:


sudo zpool list
df -h

Chown it for a non-root user if you want:


sudo chown -Rfv user1:user1 /pool1

Test creating files:


cd /pool1
touch test1.txt
echo "my test data" > test2.txt

What if you have kABI-tracking kmod and upgrade to a newer CentOS 7.x?

You will need to uninstall and reinstall the packages. Make sure you swap for whatever version you are running ex: el7_3 or el7_4.


sudo yum remove zfs zfs-kmod spl spl-kmod libzfs2 libnvpair1 libuutil1 libzpool2 zfs-release
sudo yum install http://download.zfsonlinux.org/epel/zfs-release.<dist>.noarch.rpm
sudo yum autoremove
sudo yum clean metadata
sudo yum install zfs 

Removing DKMS and Installing kABI-tracking kmod

Remove the packages like this.


sudo yum remove zfs zfs-kmod spl spl-kmod libzfs2 libnvpair1 libuutil1 libzpool2 zfs-release

Uninstalling the package doesn’t always work 100% correctly. We need to manually remove some files as well.


sudo find /lib/modules/ \( -name "splat.ko" -or -name "zcommon.ko" \
-or -name "zpios.ko" -or -name "spl.ko" -or -name "zavl.ko" -or \
-name "zfs.ko" -or -name "znvpair.ko" -or -name "zunicode.ko" \) \
-exec /bin/rm {} \;

Change the repo and install the package the same way we covered above.

CentOS ZFS - Alternate Option - Using a Fedora 28 Repo

If you really want you can pull in ZFS from the Fedora repo. I don’t know why anyone would do this but you can. To be fair a good time to do this might be if a new version of CentOS is released and there isn’t a repo ready for it yet.


dnf install http://download.zfsonlinux.org/fedora/zfs-release.fc28.noarch.rpm
sed -i "s/\$releasever/28/g" /etc/yum.repos.d/zfs.repo
dnf install kernel-devel zfs
reboot

Test it:


zpool create pool1 mirror sdb sdc
zfs status
dnf list installed | grep zfs

References