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.
Since /lib/modules
is read-only on CoreOS, a writable overlay must be mounted
over it to install additional modules. A mount unit lib-modules.mount
mounts
the overlay as part of local-fs.target
.
- 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.service
, which
calls auto-update-kmods.sh
when no custom modules are found for the currently
running kernel. Other unit dependencies should take this service into account.
- Source: auto-update-kmods.service
- Source: auto-update-kmods.sh
The auto-update-kmods.sh
script runs any user-provided scripts in the drop-in
directory auto-update-kmods.d
in lexical order. These scripts should contain
the download, compile, and install commands for the desired custom modules. An
example script, zfs.sh
, is provided as a reference.
- Source: zfs.sh