Skip to content

rpm: Add support for building akmod packages (2.4 branch) - #19141

Merged
behlendorf merged 1 commit into
openzfs:zfs-2.4.5-stagingfrom
ElCoyote27:akmod-2.4.5-staging
Sep 21, 2026
Merged

behlendorf merged 1 commit into
openzfs:zfs-2.4.5-stagingfrom
ElCoyote27:akmod-2.4.5-staging

Conversation

@ElCoyote27

Copy link
Copy Markdown
Contributor

Backport of #19099 to zfs-2.4.5-staging.

Cherry-pick applied cleanly — all modified files are identical
or trivially different across branches.

Tested on Fedora 43 (kernel 7.2.5) and RHEL 10.2 (kernel 6.12)
with ZFS 2.4.4 — full akmod lifecycle verified.

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

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.

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 (2.4 branch) Sep 19, 2026
@behlendorf
behlendorf merged commit bb1c7ed into openzfs:zfs-2.4.5-staging Sep 21, 2026
26 of 29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants