Auto-loading modules on system boot
Until now, we have written simple “out-of-tree” kernel modules that reside in their own private directories and have to be manually loaded up, typically via the insmod
or modprobe(8)
utilities. In most real-world projects and products, you will require your out-of-tree kernel module(s) to be auto-loaded at boot. This section covers how you can achieve this.
Consider we have a kernel module named foo.ko
. We assume we have access to its source code and Makefile. In order to have it auto-load on system boot, you need to first install the kernel module to a known location on the system. To do so, we expect that the Makefile for the module contains an install
target, typically:
install:
make -C $(KDIR) M=$(PWD) modules_install
This is not something new; we have been placing the install
target within the Makefile
s of our demo kernel modules. Further, as it writes into a root-owned directory, we can always modify the...