Automatically update custom kernel modules on CoreOS
The purpose of this document is to provide notes and example code for compiling and installing custom kernel modules on CoreOS whenever a new kernel version is detected. (That includes the first boot.) A sample Ignition configuration for automating this is attached, as well as the plain files that will be written by Ignition for readability.
- Source: auto-update-kmods.ignition
Note that the writable location used by these files is
/opt/modules. If this
is not an acceptable path, it can be replaced globally in the Ignition file.
There are three main components to this setup.
/lib/modules is read-only on CoreOS, a writable overlay must be mounted
over it to install additional modules. A mount unit
the overlay as part of
- Source: lib-modules.mount
Each CoreOS version includes a container of development tools for that specific
release. This container is downloaded for running the scripts that perform the
actual module compilation. It is started by
auto-update-kmods.sh when no custom modules are found for the currently
running kernel. Other unit dependencies should take this service into account.
auto-update-kmods.sh script runs any user-provided scripts in the drop-in
auto-update-kmods.d in lexical order. These scripts should contain
the download, compile, and install commands for the desired custom modules. An
zfs.sh, is provided as a reference.
- Source: zfs.sh