I have a server 18.04 with custom ZFS kernel modules (0.8.x vs provided 0.7.x).
Periodically, when I update the kernel, I have to recompile the ZFS kernel module, which otherwise would get automatically disabled.
Last time I had to fiddle a while to get it done so this time I would like to know the correct steps involved, in advance.
I think
- updating the kernel and kernel sources
- downloading module source and compiling the module
- removing previous kmod packages and installing the new ones
However, since the kernel module is required to access some filesystems which are currently mounted, what is the next step? simply reboot to have the new module mounted?
I also have, at some point, to enable the auto-import service, see https://unix.stackexchange.com/questions/338260/zfs-mounting-only-one-of-my-pools-on-boot
If you update a module for the currently running kernel, you need to discontinue use of the module (ie:
umount
all the filesystems),rmmod zfs
, have the new module available, andmodprobe zfs
to load it again. Rebooting is usually easier, but you may find example elsewhere to help accomplish this while the system is running, if desired.# # Stop using the module
# rmmod zfs
# modprobe zfs
If you wish to automatically compile and install updates for a module each time you update your kernel, you may be interested in DKMS. There is a great DKMS Packaging Guide which discusses this in detail.
The idea is that you have a module, or some change to the kernel that you want applied with each kernel update. You can automate the compiling and installation of the modules when
apt
updates the kernel used. You can find good examples of this with VirtualBox as well with some NVIDIA DKMS drivers.Another good example that shows how to set this up is patjak's bcwc_pcie. The procedure to have
bcwc_pcie
, orfacetimehd
module compiled against and made available to new kernels is documented:Setting up DKMS (auto-compile on kernel update)
This assumes you have already followed the Debian/Ubuntu deb package steps. You will need to verify
dkms.conf
that the module namefacetimehd
and version number0.1
are correct and either update thedkms.conf
or adjust the instructions where-m
and-v
are used.# apt install debhelper dkms
# dpkg -r bcwc-pcie
# mkdir /usr/src/facetimehd-0.1
$ cd bcwc_pcie
# cp -r * /usr/src/facetimehd-0.1/
# cd /usr/src/facetimehd-0.1/
# rm backup-*tgz bcwc-pcie_*deb
# make clean
# dkms add -m facetimehd -v 0.1
# dkms build -m facetimehd -v 0.1
# dkms mkdsc -m facetimehd -v 0.1 --source-only
# dkms mkdeb -m facetimehd -v 0.1 --source-only
# cp /var/lib/dkms/facetimehd/0.1/deb/facetimehd-dkms_0.1_all.deb /root/
# rm -r /var/lib/dkms/facetimehd/
# dpkg -i /root/facetimehd-dkms_0.1_all.deb
If you have any trouble, please read this guide on making a DKMS package: http://www.xkyle.com/building-linux-packages-for-kernel-drivers/
The only part missing from this
bcwc_pcie
example is that this codebase isn't updated, while the module code you are compiling may change over time. This can be most easily done if you can find a latest download, vs specific versions of the source you're trying to compile.We can look at the
dkms.conf
at the DKMS Community Doc:and man page:
You can create a directory to contain a script which downloads and extracts the latest version of ZFS in preparation for the build. This will help to automate the process. You could use
git
or download and extract thelatest
source. Here is an example of how to determine the latest download URL for ZFS:You mention a complication with
systemd
services being disabled. Does setting up your own ZFSdkms
setup resolve this issue? Do you have packages installed that rely on the actualzfs-dkms
package that would cause it to conflict? At the very least, you could hook intoPOST_INSTALL
and runsystemctl enable
to enable whatever services are being disabled.That being said, ZFS is a pretty popular filesystem, and should have a DKMS package already available. It seems that this is true, and that
zfs-dkms
is available in universe. You can look into specifics of this package and see if this already availablezfs-dkms
does the trick for you.