AKMS(8)

πŸ“¦
version 0.3.0 Β· 2 versions
, in alpine 3.22, alpine 3.23

✨ AKMS(8) ✨ β€” Alpine Kernel Module Support πŸ’…

okay so like, this is the manual page for akms (section 8 of the manual, bestie), the Alpine Kernel Module Support tool. grab a snack, we're getting into it 🫢


🌸 NAME 🌸

akms β€” Alpine Kernel Module Support ✨


πŸŽ€ SYNOPSIS πŸŽ€

akms (install | build) [options] <srcdir | all>

akms (uninstall | unbuild) [options] <modname>[/<modver>]

akms status [options] [<modname>[/<modver>]]

akms [-h] [--help] [-V]

πŸ¦‹ DESCRIPTION πŸ¦‹

so akms(8) (aka AKMS) is this iconic tool that builds out-of-tree (external) Linux kernel modules from source for each installed kernel on your system, in an automated and organized fashion. like, no cap, fully automated. the whole concept is that your kernel modules get automatically rebuilt whenever a new kernel version lands on your machine. main character energy fr πŸ’…

AKMS is principally inspired by DKMS (Dynamic Kernel Module Support), which a lot of Linux distros use. but AKMS was designed specifically for Alpine Linux and apk(8), implemented with simplicity, reliability, and security in mind. periodt. πŸ‘‘

Builds are always executed under an unprivileged user inside a sandbox (using bwrap(1)) with isolated Mount, IPC, PID, Network, UTS, Cgroup, and User (if possible) namespaces. so yeah, it's sealed up nicely 🫧

The built kernel objects are automatically compressed with the same compression format as other modules installed with the given kernel. the supported formats are: "gz", "xz" (requires xz tool), and "zst" (requires zstd tool). slay πŸ—œοΈ

Another advantage of AKMS over DKMS is that you don't need to have all the dependencies for building modules permanently installed on the system. if some dependencies are missing, they're automatically installed in a disposable overlay over your real root filesystem (using OverlayFS and bubblewrap). the original reason for using overlay was to dodge the limitation of the APK triggers β€” they run inside a "transaction" that holds an exclusive repository lock. which means no packages could be installed if akms(8) was executed by a trigger. mounting a disposable overlay on top of / for building the modules overcomes this limitation and also gives you other benefits too. lowkey genius πŸ’‘


✨ ACTIONS ✨

  • install β€” Build and install kernel module from the _srcdir_ for the kernel version(s) specified by --kernel. _srcdir_ can be either the absolute path of the module's source directory containing an AKMBUILD(5) file, or a glob(7) pattern matching one or more module source directories in /usr/src (can be changed by parameter modules_srcdir in akms.conf(5)). A special value "all" can be used to build and install all modules found under /usr/src.

If the given module version is already built for the specified kernel, it will not be rebuilt, unless --rebuild is used.

If the module is already installed, it will verify that the installed kernel objects in /lib/modules/<kernelver>/kernel/extra/akms/ match the ones stored in the state directory (refer to section FILES for more information).

If another version of the module is installed for the given kernel, it will be automatically uninstalled right before installing the new one. out with the old, in with the new πŸ’–

  • build β€” The same as install, but it will only build the module without installing into /lib/modules. it's giving "look but don't touch" πŸ™ˆ
  • uninstall β€” Uninstall the specified module(s) from /lib/modules/<kernelver>/kernel/extra/akms/. A special value "all" can be used to uninstall all modules installed for the kernel version(s) specified by --kernel.

If keep_uninstalled is not enabled in akms.conf(5) or --no-keep is specified, it will also remove the uninstalled module version from the state directory (refer to section FILES).

  • unbuild β€” Remove the specified module version(s) built for the kernel version specified by --kernel from the state directory (refer to section FILES). A special value "all" can be used to unbuild all modules built for the specified kernel. If _modver_ is not specified, all not installed versions will be removed.

If the specified module version is installed, it will not be removed unless --force is used. ⚠️

  • status β€” Print state of modules found in the state directory (refer to section MODULE STATE). The list can be filtered by the module name (_modname_), version (_modver_), kernel (--kernel), and status (--status). vibe check on your modules πŸ”

πŸ”₯ OPTIONS πŸ”₯

πŸ’œ Common Options

The following options are available for all actions, bestie.

  • -q, --quiet β€” Be quiet, print only warn and error messages. This option overrides parameter log_level specified in akms.conf(5). shhh 🀫
  • -v, --verbose β€” Be verbose, print even debug messages. This option overrides parameter log_level specified in akms.conf(5). tell me EVERYTHING πŸ—£οΈ
  • -V, --version β€” Print the program version and exit.
  • -h, --help β€” Print the help message and exit.

🧚 Install and Build Options

The following options are available for the install and build actions.

  • -K, --keep β€” Keep uninstalled modules in the state directory (/var/lib/akms). This option overrides parameter keep_uninstalled specified in akms.conf(5). See akms.conf(5) for more information.
  • --no-keep β€” The opposite of --keep. πŸ’€
  • -k <kernelver>, --kernel <kernelver> β€” Specify for which _kernelver_ to build and install the module (e.g. 5.10.53-0-lts). A special value "all" can be used to build and install the module for all the installed kernels (based on /usr/share/kernel/*/kernel.release).

If not specified, the module will be built and installed for the installed kernel that has the same flavour as the currently running kernel. 🍦

  • -r, --rebuild β€” Rebuild (and install) the module even if it has been already built. do it again, do it bigger πŸ’…
  • --[no-]overlay β€” Whether to install the build dependencies into the root overlay created on top of /, or on the host system. This option overrides parameter use_overlayfs specified in akms.conf(5) (enabled by default).
  • --skip-cleanup β€” Do not unmount and delete the root overlay used for building and do not uninstall the build dependencies. leaving the mess behind, iconic 🫧

πŸ“ Uninstall Options

The following options are available for the uninstall action.

  • -K, --keep β€” Keep uninstalled modules in the state directory (/var/lib/akms). This option overrides parameter keep_uninstalled specified in akms.conf(5). See akms.conf(5) for more information.
  • --no-keep β€” The opposite of --keep. πŸ’€
  • -f, --force β€” Uninstall the module's kernel objects from /lib/modules/<kernelver>/kernel/extra/akms/ even if they are different from the ones stored in the state directory (/var/lib/akms). ⚠️ careful, bestie
  • -k <kernelver>, --kernel <kernelver> β€” Specify from which kernel version to uninstall the module (e.g. 5.10.53-0-lts). A special value "all" can be used to uninstall the module from all kernels where the module is installed.

If not specified, the module will be uninstalled from the installed kernel with the same flavour as the currently running kernel. 🍦

🌈 Unbuild Options

The following options are available for the unbuild action.

  • -f, --force β€” Unbuild the module (remove from the state directory) even if it's installed (without uninstalling). bold move 😭
  • -k <kernelver>, --kernel <kernelver> β€” Specify for which kernel version to unbuild the module (e.g. 5.10.53-0-lts). A special value "all" can be used to unbuild the module for all kernels.

If not specified, module built for the installed kernel with the same flavour as the currently running kernel will be unbuilt. 🍦

⭐ Status Options

The following options are available for the status action.

  • -k <kernelver>, --kernel <kernelver> β€” Filter modules by the specified kernel version (e.g. 5.10.53-0-lts).
  • -s <state>, --state <state> β€” Filter modules by their state. Refer to section MODULE STATE for more information.

πŸ‘‘ MODULE STATE πŸ‘‘

A specific module version for a specific kernel can be in one of the following states, bestie:

  1. (no state) β€” The given module version for the given kernel has not been built yet, there is no entry in the state directory. it's giving nonexistent πŸ™ˆ
  2. building β€” The module is currently being built. ⏳
  3. built β€” The module has been successfully built, but it is not installed in /lib/modules. so close πŸ₯Ί
  4. installed β€” The module is built and installed in /lib/modules. slay! πŸ’…
  5. failed β€” The module failed to be built. 😭 rip
  6. corrupted β€” The module has been installed into /lib/modules, but the kernel objects found in /lib/modules differ from the built objects or some are missing. πŸ’€ uh oh

The following diagram illustrates all possible transitions between the states supported by akms(8). keep your eyes on it:

                    build                (OK)            install
       (no state) ---------> [building] ------> [built] ---------> [installed] --------+
            ^                    ^      \        |   ^                :   ^            |
            |                    |       |       |   |                :   |            |
            |              build |       | (NOK) |   |                :   | install    |
            |                    |       v       |   |                v   |            |
            |                    `--- [failed]   |   |             [corrupted]         |
            |                            |       |   |                  |              |
            |                            |       |   | ^ (keep)         |              |
            +----------------------------+-------+ - +------------------+--------------+
                           unbuild                 < (no-keep)      uninstall

πŸŽ€ APK TRIGGERS πŸŽ€

Alpine's akms package installs a trigger script that monitors /usr/src/. each time you install or remove a package that creates or updates a directory in /usr/src, and that directory contains an AKMBUILD(5) file, the trigger runs "akms install /usr/src/<directory>". in other words: when you install a kernel module source package, it will be automatically built and installed for the currently installed kernel. auto-pilot fr πŸ›«

This can be disabled by setting disable_trigger in akms.conf(5) to "yes" or changing modules_srcdir ibid. to another directory.

To automatically rebuild available modules after a new kernel version is installed, AKMS uses the trigger-based mechanism provided by the kernel-hooks package. it provides the akms.hook script that is automatically symlinked into /etc/kernel-hooks.d. When a new kernel version is installed, this hook runs "akms install -k <new-kernel-ver> all" to build all modules found in modules_srcdir (/usr/src) for the new kernel. Analogically, when an old kernel version is uninstalled (i.e. with an upgrade), it runs "akms uninstall -k <old-kernel-ver> all" to uninstall all modules installed for the old kernel. πŸ”„

If you want to disable this hook, just remove the symlink in /etc/kernel-hooks.d. easy 🫢

πŸ—‚οΈ FILES πŸ—‚οΈ

Okay bestie, here’s the filesystem map β€” this is where akms(8) keeps its stuff and where it expects to find yours πŸ’–

  • /etc/akms.conf β€” the configuration file for akms(8), no cap.
  • /usr/src/<modname>-<modver>/AKMBUILD β€” metadata and instructions to build a dynamic kernel module. See AKMBUILD(5) ✨

The following tree illustrates all files and directories used or expected by akms(8). Literally the whole vibe, laid out πŸ‘‘

/
β”œβ”€ etc
β”‚   β”œβ”€ akms.conf ............... akms.conf(5)
β”‚   └─ kernel-hooks.d
β”‚       └─ <n>-akms.hook ---+ .. symlink to akms.hook
β”‚                           |
β”œβ”€ usr/share/kernel-hooks.d |
β”‚   └─ akms.hook <----------+ .. the kernel hook
β”‚
β”œβ”€ lib/modules
β”‚   β”œβ”€ <kernelver> ............. dynamic modules for the kernelver
β”‚   β”‚   └─ kernel/extra/akms/... files installed by akms (modules_dest_path)
β”‚   :   ...
β”‚   └─ <kernelver>
β”‚
β”œβ”€ tmp/akms .................... temp_dir in akms.conf(5)
β”‚   └─ <timestamp> ............. a temp dir created when building, removed afterwards
β”‚       └─ overlay/............. mount point for a disposable root overlay
β”‚
β”œβ”€ usr/src ..................... directory with sources (modules_srcdir in akms.conf(5))
β”‚   β”œβ”€ <modname>-<modver> ...... module's source directory
β”‚   β”‚   β”œβ”€ AKMBUILD ............ AKMBUILD(5)
β”‚   β”‚   └─ *.c, *.h, ...
β”‚   :   ...
β”‚   └─ <modname>-<modver>
β”‚
└─ var/lib/akms ................ the state directory tree
    β”œβ”€ <kernelver> ............. directory with modules for particular kernel version
    β”‚   β”œβ”€ <modname> ........... directory with versions of the module
    β”‚   β”‚   β”œβ”€ <modver> ........ module's state directory
    β”‚   β”‚   β”‚   β”œβ”€ build/ ...... module's build directory (in states building, failed)
    β”‚   β”‚   β”‚   β”œβ”€ modules/ .... built kernel objects
    β”‚   β”‚   β”‚   └─ state ....... file with the state string
    β”‚   β”‚   β”œβ”€ <modver> <---+
    β”‚   β”‚   :   ...         |
    β”‚   β”‚   β”œβ”€ <modver>     |
    β”‚   β”‚   └─ installed ---+ .. symlink to the installed version
    β”‚   :   ...
    β”‚   └─ <modname>
    :   ...
    └─ <kernelver>

πŸ’– AUTHORS πŸ’–

The author credit goes to Jakub Jirutka β€” periodt 🫢

πŸ› REPORTING BUGS πŸ›

Found a bug? Don’t suffer in silence, bestie 😭 Report bugs to the project’s issue tracker at https://github.com/jirutka/akms/issues.

πŸ‘€ SEE ALSO πŸ‘€

πŸ‘‘ AUTHOR πŸ‘‘

Again, iconic behavior: Jakub Jirutka πŸ’…βœ¨


And that’s the whole map, bestie β€” you absolutely ate this read-through πŸ—ΊοΈπŸ’– The footer situation is AKMS(8), dated 2025-01-05, and yes, it’s giving reference-page royalty πŸ‘‘πŸŒΈ

πŸ“¦ where this page comes from