ZFS on Debian 9 (stretch) with Kernel 4.18

Andrew Knapp
Jan 2 · 3 min read

I recently upgraded my Debian 9.6 (stretch) linux machine to the latest 4.18 kernel which is slated for Debian 10 (buster). I used the stretch-backports release to first upgrade my packages, then install the 4.18 kernel image package. It turns out that if you are running zfs on linux through the zfs-dkms package, it doesn’t play nice when you upgrade the kernel. The correct way to upgrade your debian system that’s running zfs is to first uninstall the zfs-dkms package, upgrade your packages to stretch-backports, install the 4.18 kernel image and headers, then reinstall the zfs-dkms package. This should rebuild the kernel modules you need for zfs to work properly in the 4.18 kernel. You will likely want to upgrade your zfs pool once you’ve completed kernel upgrade. I have detailed the procedure below.


Before you upgrade to the 4.18 kernel, you will want to rip out the existing zfs-dkms package (this will remove ZFS from your system):

# sudo apt-get remove zfs-dkms

Next, you will want to add stretch-backport your sources.list.d directory:

#  echo "deb http://ftp.us.debian.org/debian/ stretch-backports main contrib non-free" | sudo tee /etc/apt/sources.list.d/debian_stretch_backports.list

Update your apt repos and upgrade your packages prior to installing the new kernel.

# sudo apt-get update
# sudo apt-get -t stretch-backports upgrade

Next upgrade your kernel to 4.18:

# sudo apt-get -t stretch-backports install linux-image-4.18.0-0.bpo.3-amd64

Install the linux headers for 4.18:

#  sudo apt-get -t stretch-backports install linux-headers-4.18.0-0.bpo.3-amd64

Reboot the server to boot into the new kernel.

# sudo reboot

Verify your kernel.

# uname -a 

You should she output similar to:

Linux 4.18.0-0.bpo.3-amd64 #1 SMP Debian 4.18.20-2~bpo9+1 (2018-12-08) x86_64 GNU/Linux

Reinstall the zfs dkms package. This should rebuild the zfs kernel module for the 4.18 kernel and install then newer zfs package(s).

# sudo apt-get -t stretch-backports install zfs-dkms

After this completes, you’ll likely see the service fail to start with an error complaining about zfs-share.service

Job for zfs-mount.service failed because the control process exited with error code.
See "systemctl status zfs-mount.service" and "journalctl -xe" for details.
zfs-mount.service couldn't start.
Job for zfs-share.service failed because the control process exited with error code.
See "systemctl status zfs-share.service" and "journalctl -xe" for details.
zfs-share.service couldn't start.

To start ZFS properly, issue the following commands:

sudo /sbin/modprobe zfs

sudo systemctl restart zfs-import-cache
sudo systemctl restart zfs-import-scan
sudo systemctl restart zfs-mount
sudo systemctl restart zfs-share

You should now be able to do zpool status and see your pool. If you don’t see your pool, perform a zpool import <pool-name> to import your zfs pool.

Since we’ve upgraded both the kernel and the version of zfs, zpool status will indicate that not all ZFS features are enabled. To upgrade your zpool, do the following.

# sudo zpool upgrade -a

This should conclude your ZFS & Kernel upgrade.


Andrew Knapp

Written by

SRE at Pandora Media, Inc.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade