Get the highlights in your inbox every week.
Set up ZFS on Linux with yum | Opensource.com
Set up ZFS on Linux with yum
Use a yum repo to take advantage of the latest ZFS features on Fedora.
I am a Fedora Linux user who runs
yum upgrade daily. While this habit enables me to run all the latest software (one of Fedora's four foundations is "first," and it lives up to that), it also highlights any incompatibilities between the ZFS storage platform and a new kernel.
At first, I just compiled ZFS manually from its Git repo after every kernel update. If I forgot, ZFS would fail to be recognized on the next boot. Luckily, I quickly learned how to set up dynamic kernel module support (DKMS) for ZFS. However, this solution isn't perfect. For one thing, it doesn't utilize the powerful yum system, which can help with resolving dependencies and upgrading. In addition, switching between your own package and an upstream package is pretty easy with yum.
In this article, I will demonstrate how to set up a yum repo for packaging ZFS. The solution has two steps:
- Create RPM packages from the ZFS Git repository
- Set up a yum repo to host the packages
Create RPM packages
To create RPM packages, you need to install the RPM toolchain. Yum provides groups to bundle installing the tools:
sudo dnf group install 'C Development Tools and Libraries' 'RPM Development Tools'
After these have been installed, you must install all the packages necessary to build ZFS from the ZFS Git repo. The packages belong to three groups:
- Autotools to generate build files from platform configurations
- Libraries for building ZFS kernel and userland tools
- Libraries for building RPM packages
sudo dnf install libtool autoconf automake gettext createrepo \
libuuid-devel libblkid-devel openssl-devel libtirpc-devel \
lz4-devel libzstd-devel zlib-devel \
kernel-devel elfutils-libelf-devel \
libaio-devel libattr-devel libudev-devel \
Now you are ready to create your own packages.
OpenZFS provides excellent infrastructure. To build it:
- Clone the repository with
gitand switch to the branch/tag that you hope to use.
- Run Autotools to generate a makefile.
make rpmand, if everything works, RPM files will be placed in the build folder.
$ git clone --branch=zfs-2.0.0-rc3 https://github.com/openzfs/zfs.git zfs
$ cd zfs
$ make rpm
Set up a yum repo
In yum, a repo is a server or local path that includes metadata and RPM files. A consumer sets up an INI configuration file, and the
yum command automatically resolves the metadata and downloads the corresponding packages.
Fedora provides the
createrepo tool to set up a yum repo. First, create the repo and copy all RPM files from the ZFS folder to the repo. Then run
createrepo --update to include all packages in the metadata:
$ sudo mkdir -p /var/lib/zfs.repo
$ sudo createrepo /var/lib/zfs.repo
$ sudo cp *.rpm /var/lib/zfs.repo/
$ sudo createrepo --update /var/lib/zfs.repo
Create a new configuration file in
/etc/yum.repos.d to include the repo path:
$ echo \
"[zfs-local]\\nname=ZFS Local\\nbaseurl=file:///var/lib/zfs.repo\\nenabled=1\\ngpgcheck=0" |\
sudo tee /etc/yum.repos.d/zfs-local.repo
$ sudo dnf --repo=zfs-local list available --refresh
Finally, you have reached the end of the journey! You have a working yum repo and ZFS packages. Now you just need to install them:
$ sudo dnf install zfs
$ sudo /sbin/modprobe zfs
sudo zfs version to see the version of your userland and kernel tools. Congratulations! You have ZFS for Fedora.