8.50. Kmod-33

The Kmod package contains libraries and utilities for loading kernel modules

Approximate build time: less than 0.1 SBU
Required disk space: 11 MB

8.50.1. Installation of Kmod

Prepare Kmod for compilation:

./configure --prefix=/usr     \
            --sysconfdir=/etc \
            --with-openssl    \
            --with-xz         \
            --with-zstd       \
            --with-zlib       \
            --disable-manpages

The meaning of the configure options:

--with-openssl

This option enables Kmod to handle PKCS7 signatures for kernel modules.

--with-xz, --with-zlib, and --with-zstd

These options enable Kmod to handle compressed kernel modules.

--disable-manpages

This option disables generating the man pages which requires an external program.

Compile the package:

make

The test suite of this package requires raw kernel headers (not the sanitized kernel headers installed earlier), which are beyond the scope of LFS.

Install the package and recreate some symlinks for compatibility with Module-Init-Tools (the package that previously handled Linux kernel modules). The building system will create all these symlinks in /usr/bin, but we only want lsmod there and all other symlinks in /usr/sbin instead:

make install

for target in depmod insmod modinfo modprobe rmmod; do
  ln -sfv ../bin/kmod /usr/sbin/$target
  rm -fv /usr/bin/$target
done

8.50.2. Installation of Kmod - x32bit

Clean previous build but keep man pages as they cannot be recreated since xsltproc isn't installed yet:

sed -e "s/^CLEANFILES =.*/CLEANFILES =/" -i man/Makefile
make clean

Prepare Kmod for compilation:

CC="gcc -mx32" ./configure \
    --host=x86_64-pc-linux-gnux32 \
    --prefix=/usr                 \
    --libdir=/usr/libx32          \
    --sysconfdir=/etc             \
    --with-openssl                \
    --with-xz                     \
    --with-zstd                   \
    --with-zlib                   \
    --disable-manpages            \
    --with-rootlibdir=/usr/libx32

Compile the package:

make

Install the package:

make DESTDIR=$PWD/DESTDIR install
cp -Rv DESTDIR/usr/libx32/* /usr/libx32
rm -rf DESTDIR

8.50.3. Contents of Kmod

Installed programs: depmod (link to kmod), insmod (link to kmod), kmod, lsmod (link to kmod), modinfo (link to kmod), modprobe (link to kmod), and rmmod (link to kmod)
Installed library: libkmod.so

Short Descriptions

depmod

Creates a dependency file based on the symbols it finds in the existing set of modules; this dependency file is used by modprobe to automatically load the required modules

insmod

Installs a loadable module in the running kernel

kmod

Loads and unloads kernel modules

lsmod

Lists currently loaded modules

modinfo

Examines an object file associated with a kernel module and displays any information that it can glean

modprobe

Uses a dependency file, created by depmod, to automatically load relevant modules

rmmod

Unloads modules from the running kernel

libkmod

This library is used by other programs to load and unload kernel modules