| 146 | |
| 147 | |
| 148 | [=#modules] |
| 149 | == Loading kernel modules |
| 150 | Typical Linux systems have a hotplug manager such as {{{udev}}} running in the background that loads modules for detected devices. Without such as system you must do this manually. Once easy solution is to do this at boot time via an init script. |
| 151 | |
| 152 | Examples: |
| 153 | * Auto load modules for devices detected at boot as well as a non-device specific module such as 'batman-adv': |
| 154 | 1. make menuconfig and set BR2_ROOTFS_OVERLAY=files |
| 155 | 2. create an init script that loads modules for detected devices and modules listed in {{{/etc/modules}}}: |
| 156 | {{{#!bash |
| 157 | mkdir -p files/etc/init.d |
| 158 | cat << \EOF > files/etc/init.d/S30modules |
| 159 | #!/bin/sh |
| 160 | |
| 161 | case "$1" in |
| 162 | start) |
| 163 | printf "Loading modules:" |
| 164 | # load modules for detected devices |
| 165 | find /sys/ -name modalias -print0 | xargs -0 sort -u -z | xargs -0 modprobe -abq |
| 166 | |
| 167 | # load modules from /etc/modules |
| 168 | [ -r /etc/modules ] || exit 0 |
| 169 | while read module args; do |
| 170 | case "$module" in |
| 171 | ""|"#"*) continue ;; |
| 172 | esac |
| 173 | |
| 174 | # attempt to load modules |
| 175 | modprobe ${module} ${args} >/dev/null |
| 176 | done < /etc/modules |
| 177 | ;; |
| 178 | esac |
| 179 | EOF |
| 180 | chmod +x files/etc/init.d/S30modules |
| 181 | }}} |
| 182 | 3. create an {{{/etc/modules}}} file with extra modules and arguments you wish to load: |
| 183 | {{{#!bash |
| 184 | cat << \EOF > files/etc/modules |
| 185 | batman-adv |
| 186 | EOF |
| 187 | }}} |
| 188 | 3. build with 'make' |