Skip to content

rpm: Add support for building akmod packages (main branch) - #19099

Merged
behlendorf merged 1 commit into
openzfs:masterfrom
ElCoyote27:akmod-feature
Sep 19, 2026
Merged

behlendorf merged 1 commit into
openzfs:masterfrom
ElCoyote27:akmod-feature

Conversation

@ElCoyote27

Copy link
Copy Markdown
Contributor

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.
  • 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.
  • 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.

How it works

The akmod infrastructure requires the akmods package on the target system.
When akmod-zfs is installed, it places a zfs-kmod src.rpm in
/usr/src/akmods/. The akmods service then automatically rebuilds it
for each new kernel via rpmbuild --define 'kernels <uname-r>' --rebuild.

This follows the same pattern used by negativo17's nvidia-kmod.

Usage

make rpm-akmod    # Build akmod-zfs, kmod-zfs (meta), zfs-kmod-common
make srpm-akmod   # Build source RPM only

Testing

Tested the full akmod lifecycle on:

  • Fedora 43 (kernel 7.1.13) — ZFS 2.4.4 akmod backport
  • RHEL 9.8 (kernel 5.14.0-687) — ZFS 2.3.9 akmod backport

Verified: build → install akmod-zfs → akmods --force → kmod-zfs-<kernel> automatically built and installed → remove kmod → akmods --force rebuilds it.

Closes #16949

Signed-off-by: Vincent S. Cojot vcojot@redhat.com

@ElCoyote27 ElCoyote27 changed the title rpm: Add support for building akmod packages rpm: Add support for building akmod packages (main) Sep 11, 2026
@ElCoyote27 ElCoyote27 changed the title rpm: Add support for building akmod packages (main) rpm: Add support for building akmod packages (main branch) Sep 11, 2026
@behlendorf behlendorf added Component: Packaging custom packages Status: Code Review Needed Ready for review and testing labels Sep 11, 2026

@behlendorf behlendorf left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool, this is a lot smaller than I would have expected. Let me kick the tires a bit.

@ElCoyote27

Copy link
Copy Markdown
Contributor Author

@behlendorf Sorry for the late reply, had gone to bed last night (I'm in Europe).
Please note that I had also backported the patch to 2.4.x and 2.3.z. It worked as expected and was able to verify on Fedora43 and RHEL9. Please let me know if there are any changes needed.
Best,
Vincent

@tonyhutter

Copy link
Copy Markdown
Contributor

Thank you for this PR!

I did a quick make rpm-akmod and got these RPMs:

$ ls *.rpm
akmod-zfs-2.4.99-1080.g78f49e1dd.el10.x86_64.rpm  kmod-zfs-2.4.99-1080.g78f49e1dd.el10.x86_64.rpm  zfs-kmod-2.4.99-1080.g78f49e1dd.el10.src.rpm  zfs-kmod-common-2.4.99-1080.g78f49e1dd.el10.noarch.rpm

$ rpm -ql akmod-zfs-2.4.99-1080.g78f49e1dd.el10.x86_64.rpm 
/usr/src/akmods/zfs-kmod-2.4.99-1080.g78f49e1dd.el10.src.rpm
/usr/src/akmods/zfs-kmod.latest

$ rpm -ql kmod-zfs-2.4.99-1080.g78f49e1dd.el10.x86_64.rpm
(contains no files)

$ rpm -qi kmod-zfs-2.4.99-1080.g78f49e1dd.el10.x86_64.rpm
Name        : kmod-zfs
Version     : 2.4.99
Release     : 1080.g78f49e1dd.el10
Architecture: x86_64
Install Date: (not installed)
Group       : System Environment/Kernel
Size        : 0
License     : CDDL
Signature   : (none)
Source RPM  : zfs-kmod-2.4.99-1080.g78f49e1dd.el10.src.rpm
Build Date  : Mon 14 Sep 2026 04:39:05 PM PDT
Build Host  : centos10
URL         : https://github.com/openzfs/zfs
Summary     : Metapackage which tracks in zfs kernel module for newest kernel
Description :
This is a meta-package without payload which sole purpose is to require the
zfs kernel module(s) for the newest kernel,
to make sure you get it together with a new kernel.

I then did:

sudo dnf install akmod-zfs-2.4.99-1080.g78f49e1dd.el10.x86_64.rpm zfs-kmod-common-2.4.99-1080.g78f49e1dd.el10.noarch.rpm

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:

$ sudo akmods --rebuild
Checking kmods exist for 6.12.0-211.47.1.el10_2.x86_64 [  OK  ]
Building and installing zfs-kmod [  OK  ]
$ sudo modprobe zfs

So far so good! I haven't tried a kernel upgrade yet though.

Question: can you tell me why make rpm-akmod also creates a kmod-zfs package? I would have assumed it would only build a akmod-zfs package, but maybe I'm missing something.

@ElCoyote27

ElCoyote27 commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor Author

@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.

@tonyhutter

Copy link
Copy Markdown
Contributor

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_64

I 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_64

I'm guessing thats normal with akmods, right?

@ElCoyote27

Copy link
Copy Markdown
Contributor Author

@tonyhutter Hi Tony, I saw that too. Please allow me to dig a little deeper and update here.

@ElCoyote27

ElCoyote27 commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor Author

Ok, I found it.
Negativo17's akmod doesn't have a -devel rpm. ZFS has one and so it always gets built and installed as well.

NVIDIA spec (from negativo17):

%{expand:%(kmodtool --target %{_target_cpu} --repo negativo17.org --kmodname %{name} %{?buildforkernels:--%{buildforkernels}} %{?kernels:--for-kernels "%{?kernels}"} 2>/dev/null) }

ZFS spec:

%{expand:%(bash %{SOURCE10} --target %{_target_cpu} %{?repo:--repo %{?repo}} --kmodname %{name} %{?buildforkernels:--%{buildforkernels}} --devel %{?prefix:--prefix "%{?prefix}"} %{?kernels:--for-kernels "%{?kernels}"} %{?kernelbuildroot:--buildroot "%{?kernelbuildroot}"} 2>/dev/null) }

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:

  1. Spec: Change --devel to %{?_with_devel:--devel} (opt-in via --with devel)
  2. rpm.am: Add --with devel to rpm-kmod/srpm-kmod targets only
  3. Akmod flow: No --with devel → no devel packages when akmods rebuilds

@ElCoyote27
ElCoyote27 force-pushed the akmod-feature branch 2 times, most recently from c79f806 to 8315c85 Compare September 17, 2026 07:47
@ElCoyote27

Copy link
Copy Markdown
Contributor Author

Tests successful, PR updated. I will update here if something new resurfaces

@ElCoyote27

ElCoyote27 commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor Author

Verified on RHEL 9.8:

# lsb_release -a
LSB Version:    :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-
amd64:printing-4.1-noarch:trialuse-4.1-amd64:trialuse-4.1-noarch
Distributor ID: RedHatEnterprise
Description:    Red Hat Enterprise Linux release 9.8 (Plow)
Release:        9.8
Codename:       Plow

# rpm -qa|grep zfs
zfs-release-2-3.el9.noarch
libzfs6-2.3.9-2.8.el9.x86_64
zfs-2.3.9-2.8.el9.x86_64
akmod-zfs-2.3.9-2.8.el9.x86_64
libzfs6-devel-2.3.9-2.8.el9.x86_64
pam_zfs_key-2.3.9-2.8.el9.x86_64
python3-pyzfs-2.3.9-2.8.el9.noarch

# akmods --force
Checking kmods exist for 5.14.0-687.48.1.el9_8.x86_64      [  OK  ]

# rpm -qa|grep zfs
zfs-release-2-3.el9.noarch
libzfs6-2.3.9-2.8.el9.x86_64
zfs-2.3.9-2.8.el9.x86_64
akmod-zfs-2.3.9-2.8.el9.x86_64
libzfs6-devel-2.3.9-2.8.el9.x86_64
pam_zfs_key-2.3.9-2.8.el9.x86_64
python3-pyzfs-2.3.9-2.8.el9.noarch
kmod-zfs-5.14.0-687.48.1.el9_8.x86_64-2.3.9-2.8.el9.x86_64

@ElCoyote27

Copy link
Copy Markdown
Contributor Author

Verified on Fedora43:

# lsb_release -a
LSB Version:
Distributor ID: Fedora
Description:    Fedora release 43 (Forty Three)
Release:        43
Codename:       FortyThree

# rpm -qa|grep zfs
libvirt-daemon-driver-storage-zfs-11.6.0-3.fc43.x86_64
zfs-release-3-0.fc43.noarch
libzfs7-2.4.4-2.43.fc43.x86_64
akmod-zfs-2.4.4-2.43.fc43.x86_64
zfs-2.4.4-2.43.fc43.x86_64
zfs-kmod-common-2.4.4-2.43.fc43.noarch

# akmods --force
Checking kmods exist for 7.2.5-100.fc43.x86_64             [  OK  ]
Building and installing zfs-kmod                           [  OK  ]

# rpm -qa|grep zfs
libvirt-daemon-driver-storage-zfs-11.6.0-3.fc43.x86_64
zfs-release-3-0.fc43.noarch
libzfs7-2.4.4-2.43.fc43.x86_64
akmod-zfs-2.4.4-2.43.fc43.x86_64
zfs-2.4.4-2.43.fc43.x86_64
zfs-kmod-common-2.4.4-2.43.fc43.noarch
kmod-zfs-7.2.5-100.fc43.x86_64-2.4.4-2.43.fc43.x86_64

@ElCoyote27

Copy link
Copy Markdown
Contributor Author

Verified on RHEL 10.2:

# lsb_release -a
LSB Version:    :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch:trialuse-4.1-amd64:trialuse-4.1-noarch
Distributor ID: RedHatEnterprise
Description:    Red Hat Enterprise Linux release 10.2 (Coughlan)
Release:        10.2
Codename:       Coughlan

# rpm -qa|grep zfs
libzfs7-2.4.4-2.2.el10.x86_64
zfs-2.4.4-2.2.el10.x86_64
akmod-zfs-2.4.4-2.2.el10.x86_64
zfs-kmod-common-2.4.4-2.2.el10.noarch
pam_zfs_key-2.4.4-2.2.el10.x86_64

# akmods --force
Checking kmods exist for 6.12.0-211.55.1.el10_2.x86_64     [  OK  ]
Building and installing nvidia-kmod                        [  OK  ]
Building and installing zfs-kmod                           [  OK  ]

# rpm -qa|grep zfs
libzfs7-2.4.4-2.2.el10.x86_64
zfs-2.4.4-2.2.el10.x86_64
akmod-zfs-2.4.4-2.2.el10.x86_64
zfs-kmod-common-2.4.4-2.2.el10.noarch
pam_zfs_key-2.4.4-2.2.el10.x86_64
kmod-zfs-6.12.0-211.55.1.el10_2.x86_64-2.4.4-2.2.el10.x86_64

@behlendorf

Copy link
Copy Markdown
Contributor

One possible fix is to make --devel opt-in

That's reasonable, today the only consumer of the kmod-zfs-devel packages is Lustre and for those builds it can be enabled when needed. If you can resolve the checkstyle warning I think this will be ready to go.

@behlendorf behlendorf added Status: Accepted Ready to integrate (reviewed, tested) and removed Status: Code Review Needed Ready for review and testing labels Sep 18, 2026
@ElCoyote27

ElCoyote27 commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor Author

checkstyle warning

Hi @behlendorf ,
What did you mean by 'checkstyle warning'? I didn't get that..
Oh, it was the long commit message.. working on it now. :)
Thank you,
Vincent

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>
@github-actions github-actions Bot removed the Status: Accepted Ready to integrate (reviewed, tested) label Sep 18, 2026
@behlendorf behlendorf added the Status: Accepted Ready to integrate (reviewed, tested) label Sep 18, 2026
@behlendorf
behlendorf merged commit 7636c39 into openzfs:master Sep 19, 2026
44 of 48 checks passed
@ElCoyote27

Copy link
Copy Markdown
Contributor Author

@behlendorf @tonyhutter Thank you very much. I am glad you liked this PR too. :)
What can I do to request a backport to 2.3.z and 2.4.z ? Is there anything I can help with?

@ElCoyote27

Copy link
Copy Markdown
Contributor Author

Backport PRs submitted to the staging branches:

All cherry-picks applied cleanly.

@behlendorf

Copy link
Copy Markdown
Contributor

@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.

behlendorf pushed a commit that referenced this pull request Sep 21, 2026
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
behlendorf pushed a commit that referenced this pull request Sep 21, 2026
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
behlendorf pushed a commit that referenced this pull request Sep 21, 2026
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
@ElCoyote27

Copy link
Copy Markdown
Contributor Author

@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.

@ElCoyote27

Copy link
Copy Markdown
Contributor Author

I can't wait for the next 2.3 and 2.4 releases.. :) Thank you so much!

lundman pushed a commit to openzfsonwindows/openzfs that referenced this pull request Sep 27, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component: Packaging custom packages Status: Accepted Ready to integrate (reviewed, tested)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RFE: provide an akmod package

3 participants