# Auto load kernel module on boot

**URL:** <https://linux-tips.com/t/auto-load-kernel-module-on-boot/432>\
**Category:** Embedded\
**Created:** [November 28, 2016, 12:27pm UTC](https://linux-tips.com/t/auto-load-kernel-module-on-boot/432 "2016-11-28T12:27:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![saucompeng](https://linux-tips.com/user_avatar/linux-tips.com/saucompeng/32/176_2.png) [@saucompeng](https://linux-tips.com/u/saucompeng)\
**Post date:** [November 28, 2016, 12:27pm UTC](https://linux-tips.com/t/auto-load-kernel-module-on-boot/432/1 "2016-11-28T12:27:50Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![demirten](https://linux-tips.com/user_avatar/linux-tips.com/demirten/32/64_2.png) [@demirten](https://linux-tips.com/u/demirten)\
**Post date:** [November 29, 2016, 11:06pm UTC](https://linux-tips.com/t/auto-load-kernel-module-on-boot/432/2 "2016-11-29T23:06:03Z")

</div>

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](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**.

---

<div class="post-metadata">

**Author:** ![cirosantilli](https://linux-tips.com/user_avatar/linux-tips.com/cirosantilli/32/117_2.png) [@cirosantilli](https://linux-tips.com/u/cirosantilli)\
**Post date:** [November 11, 2017, 12:00pm UTC](https://linux-tips.com/t/auto-load-kernel-module-on-boot/432/3 "2017-11-11T12:00:42Z")

</div>

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](https://github.com/cirosantilli/linux-kernel-module-cheat/blob/0d7259fe81e8c41fa3c98789dd6500ac6a7f81e3/getting-started.md#automatic-startup-commands).
