#1103478 kmod: Unable to load compressed modules in initramfs.

Package:
kmod
Source:
kmod
Description:
tools for managing Linux kernel modules
Submitter:
Ethan R
Date:
2025-07-02 11:43:02 UTC
Severity:
normal
Tags:
#1103478#5
Date:
2025-04-18 02:21:10 UTC
From:
To:
Dear Maintainer,

It appears that some modes of kmod (modprobe, modinfo) require the
liblzma.so.5 library in order to operate with compressed kernel modules
(module.ko.xz).  However, liblzma.so.5 does not show up in the output of "ldd
/usr/bin/kmod", so this library is not included in initramfs images
created by the initramfs-tools package.  This prevents loading
compressed modules in early userspace using modprobe.

I recommend modifying "/usr/share/initramfs-tools/hooks/kmod" to
explicitly copy the liblzma.so.5 library into initramfs images using the
copy_file function.

Thanks for your work supporting Debian.

#1103478#10
Date:
2025-04-18 17:36:33 UTC
From:
To:
I can confirm that

copy_exec /lib/<architecture>/liblzma.so.5

in /usr/share/initramfs-tools/hooks/kmod fixes the problem for me.

—Ethan

#1103478#13
Date:
2025-04-25 12:24:24 UTC
From:
To:
We believe that the bug you reported is fixed in the latest version of
kmod, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 1099801@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Marco d'Itri <md@linux.it> (supplier of updated kmod package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@ftp-master.debian.org)
Format: 1.8
Date: Fri, 25 Apr 2025 11:50:41 +0200
Source: kmod
Architecture: source
Version: 34.2-2
Distribution: unstable
Urgency: medium
Maintainer: Marco d'Itri <md@linux.it>
Changed-By: Marco d'Itri <md@linux.it>
Closes: 1099801
Changes:
 kmod (34.2-2) unstable; urgency=medium
 .
   * kmod.initramfs-hook: if compressed modules have been copied to the
     initramfs and CONFIG_MODULE_DECOMPRESS=n (which is not the default
     in Debian kernels) then also copy the compression libraries needed
     by kmod to load them. (Closes: #1099801)
Checksums-Sha1:
 c87862acf41acf478696d7ebd34432bc17f75c49 1819 kmod_34.2-2.dsc
 cae7eeaa09da06449a3202ebd921fc87d477ef4b 12144 kmod_34.2-2.debian.tar.xz
 b6fae61c0814fa89c9d0eed3f7f130f8ba573940 8820 kmod_34.2-2_amd64.buildinfo
Checksums-Sha256:
 a36884eceaccc3647b5181233282578548d1f1fc39bfb5c1d4459982fb52505a 1819 kmod_34.2-2.dsc
 93c9d227cf07a7c18a7292a79e51c94a6ea23e0ef4626ab2c31b5d711c73cefe 12144 kmod_34.2-2.debian.tar.xz
 2687876426bd4c2189d4397e0e790880551443207f140602a1d9bedb24f135db 8820 kmod_34.2-2_amd64.buildinfo
Files:
 7187fe05cd92c03f94151a48c0c32e31 1819 admin important kmod_34.2-2.dsc
 18d0e2c97cb725b68830650ce5b5d1ea 12144 admin important kmod_34.2-2.debian.tar.xz
 2a777caf82f3f2d8bbacfbd79bd7cc46 8820 admin important kmod_34.2-2_amd64.buildinfo
-----BEGIN PGP SIGNATURE-----

iHUEARYKAB0WIQQnKUXNg20437dCfobLPsM64d7XgQUCaAtewgAKCRDLPsM64d7X
gQgfAQDl9La0sWS8OnyGyt3BxxMWCs0m1F60UPlU+bLNlL+bhAEA+g3T26u1oepR
BBxoUDuWVjuZeE+PjBTDMECn/5Ih7gc=
=VCZI
-----END PGP SIGNATURE-----

#1103478#22
Date:
2025-05-12 15:40:32 UTC
From:
To:
Dear Maintainer,

The fix for this is incomplete, and breaks initramfs generation for
architectures that do not end in linux-gnu.

One one of those systems, it is not quickly apparent what the issue is as you
simply get the following output during initramfs generation:

E: /usr/share/initramfs-tools/hooks/kmod failed with return 1.

The problem is that for example, on armel or armhf, the multiarch directory
exist as /usr/lib/arm-linux-gnueabi for armel, and /usr/lib/arm-linux-gnueabihf
as armhf, and we only glob at the start, not the ending.

One potential workaround is to add a glob at the end ala '*-linux-gnu*' but
another could be to use a find on /usr/lib something like

find /usr/lib/ -path "*/liblzma.so.5" -type f -exec copy_exec {} \;

I do not know how that would work on a system that actually does have
multiple architectures installed but I would assume it would copy in all of
the enabled architecture's liblzma.so.5 files.

I think the double glob would be the fastest fix, even if it does seem
inelegant.

#1103478#33
Date:
2025-07-02 11:41:31 UTC
From:
To:
Hello Marco,

you brought this bug up on #debian-arm. It was there discovered,
that the current implementation is broken on multiarch systems, for
example amd64 + i386, which seems popular.
On such installs, users can end up with the wrong liblzma.so.5.x.y in
the initramfs.
interpolate $(DEB_HOST_MULTIARCH) at build-time of the kmod debian
package into debian/kmod.initramfs-hook.

So that this:
	  copy_exec /usr/lib/*-linux-gnu/liblzma.so.5
becomes during build time:
      copy_exec /usr/lib/amd64-linux-gnu/liblzma.so.5

Including /usr/share/dpkg/architecture.mk in d/rules should make
DEB_HOST_MULTIARCH available.

I hope this is enough info for you to figure out the nitty gritty
details.

Best,
Chris