rpm: Add support for building akmod packages (main branch) - #19099
Conversation
behlendorf
left a comment
There was a problem hiding this comment.
Very cool, this is a lot smaller than I would have expected. Let me kick the tires a bit.
|
@behlendorf Sorry for the late reply, had gone to bed last night (I'm in Europe). |
|
Thank you for this PR! I did a quick I then did: That installed fine. I tried modprobing zfs, but it failed, since I hadn't done the akmods build yet. I next did the build and the modprobe worked: So far so good! I haven't tried a kernel upgrade yet though. Question: can you tell me why |
|
@tonyhutter Thank you very much for taking the time to review this. I am sooooo glad you like this PR. :) For the kmod-zfs rpm, it's a meta package and it's not supposed to be installed and it holds no files. I found the same issue in the negativo17 code and kept the logic. The kmod-zfs rpm just has the 'Requires: akmod-zfs'. It's generated automatically by kmodtool's print_akmodmeta() function — I can't easily suppress it without modifying kmodtool further. It's an artifact of the build, not a requirement. The zfs package requires the virtual provide zfs-kmod. Both akmod-zfs and the meta-package provide it: Also, since the akmod package itself needs compiler tools, it would be best to provide it in the regular zfs repos, not the zfs-kmod repos, similar to the zfs-dkms rpm. |
|
I tried this PR with a kernel update on Alma 10 and it worked as expected: $ sudo akmods --rebuild
Checking kmods exist for 6.12.0-211.47.1.el10_2.x86_64 [ OK ]
Building and installing zfs-kmod [ OK ]
# Old kernel '6.12.0-211.47.1'
$ uname -a
Linux centos10 6.12.0-211.47.1.el10_2.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Aug 13 10:40:14 EDT 2026 x86_64 GNU/Linux
$ sudo modprobe zfs
$ sudo dmesg | tail -n 1
[ 9945.642035] ZFS: Loaded module v2.4.99-1081.g194bdbcf3, ZFS pool version 5000, ZFS filesystem version 5
# Install new '6.12.0-211.53.1' kernel
$ sudo dnf update
# Try to reboot... but it correctly prevented from doing so since akmod is
# automatically building the module! Nice!
$ sudo reboot
Operation inhibited by "akmods" (PID 217215 "systemd-inhibit", user root), reason is "Akmods Transaction running".
User hutter is logged in on sshd.
Please retry operation after closing inhibitors and logging out other users.
'systemd-inhibit' can be used to list active inhibitors.
Alternatively, ignore inhibitors and users with 'systemctl reboot -i'.
# I immediatey check 'top' and see `nproc` number of gcc threads
# running as user 'akmod'. Very nice!
# Reboot comes back up with new kernel
$ uname -a
Linux centos10 6.12.0-211.53.1.el10_2.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Sep 11 07:00:06 EDT 2026 x86_64 GNU/Linux
# Sure enough, the newly-built module is loaded
$ sudo dmesg | grep -i zfs
[ 2.398682] ZFS: Loaded module v2.4.99-1081.g194bdbcf3, ZFS pool version 5000, ZFS filesystem version 5
# Modules
$ find /lib/modules | grep zfs
/lib/modules/6.12.0-211.47.1.el10_2.x86_64/extra/zfs
/lib/modules/6.12.0-211.47.1.el10_2.x86_64/extra/zfs/spl.ko
/lib/modules/6.12.0-211.47.1.el10_2.x86_64/extra/zfs/zfs.ko
/lib/modules/6.12.0-211.53.1.el10_2.x86_64/weak-updates/zfs
/lib/modules/6.12.0-211.53.1.el10_2.x86_64/weak-updates/zfs/zfs.ko
/lib/modules/6.12.0-211.53.1.el10_2.x86_64/weak-updates/zfs/spl.ko
/lib/modules/6.12.0-211.53.1.el10_2.x86_64/extra/zfs
/lib/modules/6.12.0-211.53.1.el10_2.x86_64/extra/zfs/spl.ko
/lib/modules/6.12.0-211.53.1.el10_2.x86_64/extra/zfs/zfs.ko
# RPMs installed
$ rpm -qa | grep zfs
zfs-release-3-0.el10.noarch
libzfs7-2.4.99-1081.g194bdbcf3.el10.x86_64
zfs-2.4.99-1081.g194bdbcf3.el10.x86_64
akmod-zfs-2.4.99-1081.g194bdbcf3.el10.x86_64
zfs-kmod-common-2.4.99-1081.g194bdbcf3.el10.noarch
zfs-dracut-2.4.99-1081.g194bdbcf3.el10.noarch
zfs-test-2.4.99-1081.g194bdbcf3.el10.x86_64
pam_zfs_key-2.4.99-1081.g194bdbcf3.el10.x86_64
python3-pyzfs-2.4.99-1081.g194bdbcf3.el10.noarch
kmod-zfs-devel-6.12.0-211.47.1.el10_2.x86_64-2.4.99-1081.g194bdbcf3.el10.x86_64
kmod-zfs-devel-2.4.99-1081.g194bdbcf3.el10.x86_64
kmod-zfs-6.12.0-211.47.1.el10_2.x86_64-2.4.99-1081.g194bdbcf3.el10.x86_64
kmod-zfs-devel-6.12.0-211.53.1.el10_2.x86_64-2.4.99-1081.g194bdbcf3.el10.x86_64
kmod-zfs-6.12.0-211.53.1.el10_2.x86_64-2.4.99-1081.g194bdbcf3.el10.x86_64I wanted to point out that when you build the akmod, it actually builds & installs kmod-zfs and kmod-zfs-devel RPMs: $ rpm -qa | grep zfs
zfs-kmod-common-2.4.99-1081.g194bdbcf3.el10.noarch
akmod-zfs-2.4.99-1081.g194bdbcf3.el10.x86_64
$ sudo akmods --rebuild
Checking kmods exist for 6.12.0-211.53.1.el10_2.x86_64 [ OK ]
Building and installing zfs-kmod [ OK ]
$ rpm -qa | grep zfs
zfs-kmod-common-2.4.99-1081.g194bdbcf3.el10.noarch
akmod-zfs-2.4.99-1081.g194bdbcf3.el10.x86_64
kmod-zfs-devel-6.12.0-211.53.1.el10_2.x86_64-2.4.99-1081.g194bdbcf3.el10.x86_64
kmod-zfs-devel-2.4.99-1081.g194bdbcf3.el10.x86_64
kmod-zfs-6.12.0-211.53.1.el10_2.x86_64-2.4.99-1081.g194bdbcf3.el10.x86_64I'm guessing thats normal with akmods, right? |
|
@tonyhutter Hi Tony, I saw that too. Please allow me to dig a little deeper and update here. |
|
Ok, I found it. NVIDIA spec (from negativo17): ZFS spec: The difference: nvidia has no -devel. That's why nvidia never produces devel packages. ZFS has --devel hardcoded, so devel packages are always produced — including when akmods rebuilds. One possible fix is to make --devel opt-in. When akmods rebuilds the src.rpm, it just does rpmbuild --define "kernels ..." --rebuild — no way to pass extra flags. So we'd need to flip the default. The idea would be to:
|
c79f806 to
8315c85
Compare
|
Tests successful, PR updated. I will update here if something new resurfaces |
|
Verified on RHEL 9.8: |
|
Verified on Fedora43: |
|
Verified on RHEL 10.2: |
That's reasonable, today the only consumer of the |
Hi @behlendorf , |
Add akmod (Automatic Kernel Module) support to ZFS, providing a third packaging option alongside the existing DKMS and kmod packages. Akmod packages automatically build binary kmod RPMs when new kernels are installed, enabling: - Automatic kernel module rebuilds on kernel updates - Distribution of binary kmod RPMs without recompilation - Seamless minor version upgrades on RHEL/Fedora and clones Key changes: - rpm/generic/zfs-kmod.spec.in: Add conditional akmod support via rpmbuild --define '_enable_akmod 1'. When enabled, sets buildforkernels=akmod and repo=rpmfusion so kmodtool generates an akmod-zfs package. Add -common subpackage for shared license/doc files. Guard chmod and %files sections for empty kernel_versions. Make kmod-devel packages opt-in via %bcond_with devel to prevent akmods from installing unnecessary devel packages on every kernel update. When devel is not enabled, devel header files are cleaned from the buildroot to avoid unpackaged-files errors. - config/rpm.am: Add 'make rpm-akmod' and 'make srpm-akmod' targets. These targets use the generic spec with _enable_akmod and intentionally omit kernel-specific defines (kernels, ksrc, kobj) so kmodtool enters its akmod-only code path. The existing rpm-kmod/srpm-kmod targets pass --with devel to preserve the current behavior of producing devel packages. - config/zfs-build.m4: Update comments to document the akmod vs regular kmod distinction for RPM_DEFINE_KMOD. - scripts/kmodtool: Fix a pre-existing bug where print_rpmtemplate_kmoddevelpkg (the common kmod-NAME-devel package) was called inside the per-kernel loop in print_customrpmtemplate and print_rpmtemplate, causing duplicate %package definitions when multiple kernel-devel packages are installed. Move it outside the loop so it is emitted once. The akmod infrastructure requires the 'akmods' package on the target system. When the akmod-zfs RPM is installed, it places a zfs-kmod src.rpm in /usr/src/akmods/. The akmods service then automatically rebuilds it for the running kernel via rpmbuild --define 'kernels <uname-r>' --rebuild. Usage: make rpm-akmod # Build akmod-zfs, kmod-zfs, zfs-kmod-common make rpm-kmod # Build kmod with devel packages (unchanged) Tested on Fedora 43 (kernel 7.1), RHEL 9.8 (kernel 5.14), and Alma Linux 10 (kernel 6.12). Verified akmods rebuilds produce only kmod-zfs (no devel packages) after kernel updates. Signed-off-by: Vincent S. Cojot <vcojot@redhat.com>
8315c85 to
98088ec
Compare
|
@behlendorf @tonyhutter Thank you very much. I am glad you liked this PR too. :) |
|
Backport PRs submitted to the staging branches:
All cherry-picks applied cleanly. |
|
@ElCoyote27 thanks for the backports against the staging branches. I'll get these merged so they'll be available as an option for the next point releases. |
Add akmod (Automatic Kernel Module) support to ZFS, providing a third packaging option alongside the existing DKMS and kmod packages. Akmod packages automatically build binary kmod RPMs when new kernels are installed, enabling: - Automatic kernel module rebuilds on kernel updates - Distribution of binary kmod RPMs without recompilation - Seamless minor version upgrades on RHEL/Fedora and clones Key changes: - rpm/generic/zfs-kmod.spec.in: Add conditional akmod support via rpmbuild --define '_enable_akmod 1'. When enabled, sets buildforkernels=akmod and repo=rpmfusion so kmodtool generates an akmod-zfs package. Add -common subpackage for shared license/doc files. Guard chmod and %files sections for empty kernel_versions. Make kmod-devel packages opt-in via %bcond_with devel to prevent akmods from installing unnecessary devel packages on every kernel update. When devel is not enabled, devel header files are cleaned from the buildroot to avoid unpackaged-files errors. - config/rpm.am: Add 'make rpm-akmod' and 'make srpm-akmod' targets. These targets use the generic spec with _enable_akmod and intentionally omit kernel-specific defines (kernels, ksrc, kobj) so kmodtool enters its akmod-only code path. The existing rpm-kmod/srpm-kmod targets pass --with devel to preserve the current behavior of producing devel packages. - config/zfs-build.m4: Update comments to document the akmod vs regular kmod distinction for RPM_DEFINE_KMOD. - scripts/kmodtool: Fix a pre-existing bug where print_rpmtemplate_kmoddevelpkg (the common kmod-NAME-devel package) was called inside the per-kernel loop in print_customrpmtemplate and print_rpmtemplate, causing duplicate %package definitions when multiple kernel-devel packages are installed. Move it outside the loop so it is emitted exactly once. The akmod infrastructure requires the 'akmods' package to be installed on the target system. When the akmod-zfs RPM is installed, it places a zfs-kmod src.rpm in /usr/src/akmods/. The akmods service then automatically rebuilds it for the running kernel via rpmbuild --define 'kernels <uname-r>' --rebuild. Usage: make rpm-akmod # Build akmod-zfs, kmod-zfs (meta), zfs-kmod-common make rpm-kmod # Build kmod with devel packages (unchanged behavior) Tested on Fedora 43 (kernel 7.1), RHEL 9.8 (kernel 5.14), and Alma Linux 10 (kernel 6.12). Verified akmods rebuilds produce only kmod-zfs (no devel packages) after kernel updates. Reviewed-by: Tony Hutter <hutter2@llnl.gov> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Vincent S. Cojot <vcojot@redhat.com> Closes #19099
Add akmod (Automatic Kernel Module) support to ZFS, providing a third packaging option alongside the existing DKMS and kmod packages. Akmod packages automatically build binary kmod RPMs when new kernels are installed, enabling: - Automatic kernel module rebuilds on kernel updates - Distribution of binary kmod RPMs without recompilation - Seamless minor version upgrades on RHEL/Fedora and clones Key changes: - rpm/generic/zfs-kmod.spec.in: Add conditional akmod support via rpmbuild --define '_enable_akmod 1'. When enabled, sets buildforkernels=akmod and repo=rpmfusion so kmodtool generates an akmod-zfs package. Add -common subpackage for shared license/doc files. Guard chmod and %files sections for empty kernel_versions. Make kmod-devel packages opt-in via %bcond_with devel to prevent akmods from installing unnecessary devel packages on every kernel update. When devel is not enabled, devel header files are cleaned from the buildroot to avoid unpackaged-files errors. - config/rpm.am: Add 'make rpm-akmod' and 'make srpm-akmod' targets. These targets use the generic spec with _enable_akmod and intentionally omit kernel-specific defines (kernels, ksrc, kobj) so kmodtool enters its akmod-only code path. The existing rpm-kmod/srpm-kmod targets pass --with devel to preserve the current behavior of producing devel packages. - config/zfs-build.m4: Update comments to document the akmod vs regular kmod distinction for RPM_DEFINE_KMOD. - scripts/kmodtool: Fix a pre-existing bug where print_rpmtemplate_kmoddevelpkg (the common kmod-NAME-devel package) was called inside the per-kernel loop in print_customrpmtemplate and print_rpmtemplate, causing duplicate %package definitions when multiple kernel-devel packages are installed. Move it outside the loop so it is emitted exactly once. The akmod infrastructure requires the 'akmods' package to be installed on the target system. When the akmod-zfs RPM is installed, it places a zfs-kmod src.rpm in /usr/src/akmods/. The akmods service then automatically rebuilds it for the running kernel via rpmbuild --define 'kernels <uname-r>' --rebuild. Usage: make rpm-akmod # Build akmod-zfs, kmod-zfs (meta), zfs-kmod-common make rpm-kmod # Build kmod with devel packages (unchanged behavior) Tested on Fedora 43 (kernel 7.1), RHEL 9.8 (kernel 5.14), and Alma Linux 10 (kernel 6.12). Verified akmods rebuilds produce only kmod-zfs (no devel packages) after kernel updates. Reviewed-by: Tony Hutter <hutter2@llnl.gov> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Vincent S. Cojot <vcojot@redhat.com> Closes #19099
Add akmod (Automatic Kernel Module) support to ZFS, providing a third packaging option alongside the existing DKMS and kmod packages. Akmod packages automatically build binary kmod RPMs when new kernels are installed, enabling: - Automatic kernel module rebuilds on kernel updates - Distribution of binary kmod RPMs without recompilation - Seamless minor version upgrades on RHEL/Fedora and clones Key changes: - rpm/generic/zfs-kmod.spec.in: Add conditional akmod support via rpmbuild --define '_enable_akmod 1'. When enabled, sets buildforkernels=akmod and repo=rpmfusion so kmodtool generates an akmod-zfs package. Add -common subpackage for shared license/doc files. Guard chmod and %files sections for empty kernel_versions. Make kmod-devel packages opt-in via %bcond_with devel to prevent akmods from installing unnecessary devel packages on every kernel update. When devel is not enabled, devel header files are cleaned from the buildroot to avoid unpackaged-files errors. - config/rpm.am: Add 'make rpm-akmod' and 'make srpm-akmod' targets. These targets use the generic spec with _enable_akmod and intentionally omit kernel-specific defines (kernels, ksrc, kobj) so kmodtool enters its akmod-only code path. The existing rpm-kmod/srpm-kmod targets pass --with devel to preserve the current behavior of producing devel packages. - config/zfs-build.m4: Update comments to document the akmod vs regular kmod distinction for RPM_DEFINE_KMOD. - scripts/kmodtool: Fix a pre-existing bug where print_rpmtemplate_kmoddevelpkg (the common kmod-NAME-devel package) was called inside the per-kernel loop in print_customrpmtemplate and print_rpmtemplate, causing duplicate %package definitions when multiple kernel-devel packages are installed. Move it outside the loop so it is emitted once. The akmod infrastructure requires the 'akmods' package on the target system. When the akmod-zfs RPM is installed, it places a zfs-kmod src.rpm in /usr/src/akmods/. The akmods service then automatically rebuilds it for the running kernel via rpmbuild --define 'kernels <uname-r>' --rebuild. Usage: make rpm-akmod # Build akmod-zfs, kmod-zfs, zfs-kmod-common make rpm-kmod # Build kmod with devel packages (unchanged) Tested on Fedora 43 (kernel 7.1), RHEL 9.8 (kernel 5.14), and Alma Linux 10 (kernel 6.12). Verified akmods rebuilds produce only kmod-zfs (no devel packages) after kernel updates. Reviewed-by: Tony Hutter <hutter2@llnl.gov> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Vincent S. Cojot <vcojot@redhat.com> Closes #19099
|
@behlendorf Thank you so much, Brian. I am very happy to have contributed something meaningful to (the packaging of) ZoL after all these decades using ZFS. |
|
I can't wait for the next 2.3 and 2.4 releases.. :) Thank you so much! |
Add akmod (Automatic Kernel Module) support to ZFS, providing a third packaging option alongside the existing DKMS and kmod packages. Akmod packages automatically build binary kmod RPMs when new kernels are installed, enabling: - Automatic kernel module rebuilds on kernel updates - Distribution of binary kmod RPMs without recompilation - Seamless minor version upgrades on RHEL/Fedora and clones Key changes: - rpm/generic/zfs-kmod.spec.in: Add conditional akmod support via rpmbuild --define '_enable_akmod 1'. When enabled, sets buildforkernels=akmod and repo=rpmfusion so kmodtool generates an akmod-zfs package. Add -common subpackage for shared license/doc files. Guard chmod and %files sections for empty kernel_versions. Make kmod-devel packages opt-in via %bcond_with devel to prevent akmods from installing unnecessary devel packages on every kernel update. When devel is not enabled, devel header files are cleaned from the buildroot to avoid unpackaged-files errors. - config/rpm.am: Add 'make rpm-akmod' and 'make srpm-akmod' targets. These targets use the generic spec with _enable_akmod and intentionally omit kernel-specific defines (kernels, ksrc, kobj) so kmodtool enters its akmod-only code path. The existing rpm-kmod/srpm-kmod targets pass --with devel to preserve the current behavior of producing devel packages. - config/zfs-build.m4: Update comments to document the akmod vs regular kmod distinction for RPM_DEFINE_KMOD. - scripts/kmodtool: Fix a pre-existing bug where print_rpmtemplate_kmoddevelpkg (the common kmod-NAME-devel package) was called inside the per-kernel loop in print_customrpmtemplate and print_rpmtemplate, causing duplicate %package definitions when multiple kernel-devel packages are installed. Move it outside the loop so it is emitted once. The akmod infrastructure requires the 'akmods' package on the target system. When the akmod-zfs RPM is installed, it places a zfs-kmod src.rpm in /usr/src/akmods/. The akmods service then automatically rebuilds it for the running kernel via rpmbuild --define 'kernels <uname-r>' --rebuild. Usage: make rpm-akmod # Build akmod-zfs, kmod-zfs, zfs-kmod-common make rpm-kmod # Build kmod with devel packages (unchanged) Tested on Fedora 43 (kernel 7.1), RHEL 9.8 (kernel 5.14), and Alma Linux 10 (kernel 6.12). Verified akmods rebuilds produce only kmod-zfs (no devel packages) after kernel updates. Reviewed-by: Tony Hutter <hutter2@llnl.gov> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Vincent S. Cojot <vcojot@redhat.com> Closes openzfs#19099
Add akmod (Automatic Kernel Module) support to ZFS, providing a third
packaging option alongside the existing DKMS and kmod packages.
Akmod packages automatically build binary kmod RPMs when new kernels
are installed, enabling:
Key changes
rpmbuild --define '_enable_akmod 1'. When enabled, setsbuildforkernels=akmodandrepo=rpmfusionso kmodtool generates anakmod-zfspackage. Add-commonsubpackage for shared license/docfiles. Guard
chmodand%filessections for emptykernel_versions.make rpm-akmodandmake srpm-akmodtargets.These targets use the generic spec with
_enable_akmodandintentionally omit kernel-specific defines (
kernels,ksrc,kobj)so kmodtool enters its akmod-only code path.
regular kmod distinction for
RPM_DEFINE_KMOD.print_rpmtemplate_kmoddevelpkg(the commonkmod-NAME-develpackage)was called inside the per-kernel loop in
print_customrpmtemplateand
print_rpmtemplate, causing duplicate%packagedefinitions whenmultiple
kernel-develpackages are installed. Move it outside theloop so it is emitted exactly once.
How it works
The akmod infrastructure requires the
akmodspackage on the target system.When
akmod-zfsis installed, it places azfs-kmodsrc.rpm in/usr/src/akmods/. Theakmodsservice then automatically rebuilds itfor each new kernel via
rpmbuild --define 'kernels <uname-r>' --rebuild.This follows the same pattern used by negativo17's nvidia-kmod.
Usage
Testing
Tested the full akmod lifecycle on:
Verified: build → install
akmod-zfs→akmods --force→kmod-zfs-<kernel>automatically built and installed → remove kmod →akmods --forcerebuilds it.Closes #16949
Signed-off-by: Vincent S. Cojot vcojot@redhat.com