Skip to content

Instantly share code, notes, and snippets.

@dm0-
Created July 18, 2016 21:00
Show Gist options
  • Save dm0-/99a81d98bf361fa23c4c080196dc6890 to your computer and use it in GitHub Desktop.
Save dm0-/99a81d98bf361fa23c4c080196dc6890 to your computer and use it in GitHub Desktop.
Add out-of-tree kernel modules to CoreOS

If the CoreOS developer image was used to build custom kernel modules for the same kernel version as in a CoreOS image, these modules can be added to the existing set with overlayfs. This example mount unit illustrates this if the modules are available under /mnt. Note that usual overlayfs requirements apply: namely that the working directory must be on the same root as the upper layer, and it needs to support extended attributes.

[Unit]
Description=Add custom kernel modules into the mix
ConditionPathExists=/mnt/%v

[Mount]
Type=overlay
What=overlay
Where=/lib/modules/%v
Options=lowerdir=/lib/modules/%v,upperdir=/mnt/%v,workdir=/mnt/wd

On the first boot, module dependency information should be generated for the union of the module directories. Tools like modprobe (and udev, which uses modprobe) rely on this dependency information for loading modules. It is optional if the additional modules will just be insmoded.

[Unit]
Description=Generate module dependency files
ConditionPathExists=!/mnt/%v/modules.dep

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/depmod %v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment