Skip to content

Instantly share code, notes, and snippets.

Last active June 7, 2019 19:46
Show Gist options
  • Save RulerOf/caddd8db5b781527537965e9b0a9d362 to your computer and use it in GitHub Desktop.
Save RulerOf/caddd8db5b781527537965e9b0a9d362 to your computer and use it in GitHub Desktop.
Installing ZFS on Linux on Oracle Linux 7

Installing ZFS on Linux on Oracle Linux 7

We're going to add ZFS support to our Oracle Linux installation. We'll just add the ZFS on Linux Repo, verify the binary signature from GitHub, install the files, ensure the driver loads properly, and verify that it's functional. We'll save things like array creation for another document.

This is mostly a transcription of the process from the CentOS/RHEL ZoL installation manual.


This will install ZFS v0.7 release on OEL 7.7 and earlier, and ZFS 0.8 on OEL 7.8 and later.

Install the repo file

Add the ZFSonLinux repo and verify the fingerprint.

Note — manual fingerprint verification is atypical but we'll do it anyway just for kicks.

# Get OS release number in the format used by the ZoL repo
OS_RELEASE=$(rpm -q --qf "%{VERSION}" $(rpm -q --whatprovides redhat-release) | sed 's/\./_/g')
# Populate this from GitHub if necessary
# Install repo
sudo yum install -y$OS_RELEASE.noarch.rpm
# Get repo fingerprint and normalize it (remove spaces)
REPO_FINGERPRINT=$(gpg --quiet --with-fingerprint /etc/pki/rpm-gpg/RPM-GPG-KEY-zfsonlinux | grep "Key fingerprint =" | sed -e 's/ //g' -e 's/Keyfingerprint=//g')
# Compare
if [ $(echo $GITHUB_FINGERPRINT | sed -e 's/ //g') == "$REPO_FINGERPRINT" ]; then
  echo "Fingerprint verified."

Install the DKMS-style packages

Add the EPEL repo if we haven't already:

# Get OS Release number
OS_RELEASE=$(rpm -q --qf "%{VERSION}" $(rpm -q --whatprovides redhat-release))
# Pull the major version number from that
OS_RELEASE_MAJOR=$(echo $OS_RELEASE | cut -d. -f1)
# Install the corresponding EPEL repo
sudo yum install -y$OS_RELEASE_MAJOR.noarch.rpm

Install the DKMS ZoL package. Note that we're installing kernel-uek-devel instead of kernel-devel because OL7 ships with the UEK instead of the regular kernel by default. You could always install both packages without any issue if you're unsure.

# Enable the Oracle Linux kernel repo
sudo yum-config-manager --enable ol7_UEKR4
# Match the installed kernel to a specific kernel-uek-devel release
THIS_KERNEL_PACKAGE=$(for i in $(yum -v list kernel-uek-devel --show-duplicates); do echo $(uname -r) | grep -o $i; done | uniq)
# Install the kernel headers first because zfs needs them but does not depend on them
sudo yum install -y kernel-uek-devel-$THIS_KERNEL_PACKAGE
sudo yum install -y zfs

Load the driver

Use modprobe to load the driver, and then you can confirm by tailing dmesg:

[root@drew-metal ~]# modprobe zfs
[root@drew-metal ~]# dmesg | tail
[165105.669011] <6>fioinf Fusion-io ioDrive Duo 640GB 0000:0e:00.0: Attach succeeded.
[552041.207486] SPL: Loaded module v0.7.3-1
[552042.862591] ZFS: Loaded module v0.7.3-1, ZFS pool version 5000, ZFS filesystem version 5
[root@drew-metal ~]# 

Set driver to load on boot

The DKMS-style package seems to have a problem ensuring that the driver is set to load on system startup. We have to set that up manually (details):

# Link the dependent services together in systemd
systemctl preset zfs-import-cache zfs-import-scan zfs-mount zfs-share zfs-zed
# Then enable the zfs-import-scan service that chains the entire set
systemctl enable zfs-import-scan

Verify that they're all set to load up correctly:

[root@drew-metal ~]# systemctl list-unit-files | grep zfs
zfs-import-cache.service                      enabled 
zfs-import-scan.service                       enabled 
zfs-mount.service                             enabled 
zfs-share.service                             enabled 
zfs-zed.service                               enabled                                    enabled 

Reboot, then test a zfs list:

[root@drew-metal ~]# zfs list
no datasets available
Copy link

RulerOf commented Jun 7, 2019

And about a year later... I've edited this gist to include the fixes I mentioned above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment