Auto load kernel module on boot


#1

Hi,

When I use Raspbian, if I want to any kernel module on boot, I write module name under /etc/modules. But when I use buildroot, no /etc/modules file. How can I load kernel modules on boot automatically ?


#2

Buildroot shouldn’t be compared with a full blown Linux distribution. You need to take care of preparing your filesystem manually.

/etc/modules is a configuration file, but without a startup script, it is useless.

You can prepare /etc/modules file content as Raspbian and create an init script for buildroot to parse this file and load the required modules.

It will be good to have an understanding about init systems in Linux generally. In the good old days of init systems, there was only sysv init. But now we have more options and buildroot already supports at least three of them:

  • busybox init
  • sysv init
  • systemd

You can read more about here:
https://buildroot.org/downloads/manual/manual.html#_init_system

As an example, if you’re using busybox init in buildroot, you can create a startup script like /etc/init.d/S01-modules and parse /etc/modules in here to load modules with modprobe or insmod.


#3

More precisely, in Buildroot + BusyBox, /etc/init.d/S99Modules is run from /etc/init.d/rcS:

for i in /etc/init.d/S??* ;do
    ...
            $i start

which in turn is called by the line:

::sysinit:/etc/init.d/rcS

in /etc/inittab, and that file is parsed ane run by the init process, which is the executable at /init or specified by the init= kernel command line parameter.

Here is a convenient setup to play around with it.