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 Mar 25, 2018

@jaytaylor I'm really glad that this writeup helped someone, and also that you liked it :)

I noticed your comment just now because I was following this guide again to install ZFS on an OEL7 VM for a different writeup I'm going to do, and decided to check out the things you pointed out.

I didn't have the issue you're seeing with the THIS_KERNEL_PACKAGE variable. I remember when I wrote it that the inner loop was really unusual for me and it was because of the way I was filtering text out... it's a little fuzzy for me. Regardless, your change didn't do anything in the VM I'm using (though there is another issue that I'll get to in a moment):

[root@localhost ~]# for i in $(yum -v list kernel-uek-devel --show-duplicates); do echo $(uname -r | sed 's/\.x86_64//') | grep -o $i; done
[root@localhost ~]# for i in $(yum -v list kernel-uek-devel --show-duplicates); do echo $(uname -r) | grep -o $i; done
4.1.12-94.3.9.el7uek that I'm pulling apart the loop, that's why I used grep -o. I don't normally use that switch but this was the solution I came up with when I initially encountered what you're talking about. I'll keep an eye on this when I test this guide again later from a completely fresh install from a slightly newer kernel.

In the example above, the output is duplicated because I'm using --show-duplicates which was necessary for some reason. I'm going to throw in a uniq and that should sort that problem out.

I didn't see any difference with respect to $OS_RELEASE versus $OS_RELEASE_MAJOR between our gists.

You're right that the ol7_UEKR4 repo is required. I ended up adding it for some other reason manually so my guide didn't consider it. I'll update it soon. You don't need to create your own repo file as this repo is already in the OEL installation, but it's disabled. You can turn it on with yum-config-manager --enable ol7_UEKR4

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