Installing and loading an out-of-tree kernel module


The resin team put together a great tool for building out-of-tree kernel modules. By following their example, I’ve been able to generate a compiled .ko file for my system from a .c file.

However, once it’s built, I’ve been unable to load it with modprobe. The example script executes insmod $mod_dir/my_module.ko to install the module. For me, this step succeeds and my_module appears when I execute lsmod, but subsequently trying to load it with modprobe my_module fails to find the module, outputting:

modprobe: FATAL: Module my_module not found.

I suspect this is related to an inability to access /lib/modules due to its ‘read-only filesystem’ permissions, which prevents me from running depmod -a or otherwise copying/linking my module to the appropriate directory before I call modprobe.

Is there a workaround that would allow me to properly install and load the module during startup of the container?


Hi @dysri!

Since modprobe by design loads from /lib/modules/$(uname -r) (which as you mentioned is read-only within the container), you will need to load your module and all dependencies individually with insmod $path_to_module (since insmod can work outside of the standard search path).