Autoload out-of-tree modules

Hi All,

I’m trying to build a hello world driver snap base on core22. I want load module at boot time. I can package the output hello.ko to snap but can’t move the hello.ko to /lib/modules/“kernel version”/extra. Does anyone have any suggestion or have any solution to install a module on ubuntu core22?


name: hello-world
base: core22
version: ‘0.1’
summary: Single-line elevator pitch for your amazing snap
description: |
This is my-snap’s description.

grade: stable
plugin: nil
source: src/
override-build: |

I fear you’ll have to use insmod with a path pointing to your module… (and use the kernel-module-control interface) to load it… /lib/modules is always read only since the kernel is a snap itself… the same goes for modules.dep and friends, so somethings like modprobe wouldn’t work…

Thanks for your reply. If I install a out-of-tree modules, I must use insmod to load it. I can’t autoload own module right?

exactly … you could ship a snap that contains a oneshot daemon shell script to load it on boot …

…aside from the loading this is indeed a tricky thing to do in general since the ubuntu kernels usually do at least have abi checks enabled (not to mention if you use TPM/ full disk encryption the modules are indeed signed), so you will have to constantly monitor kernel updates and make sure to recomopile/re-link your module against the current kernel version…