How to autoload a kernel module in Gentoo Linux?

Fei Xue picture Fei Xue · May 24, 2012 · Viewed 21.9k times · Source

I want to autoload some kernel modules when it's started. I've read the manual book, but can't help. Now the modules that I want to autoload are vboxdrv vboxnetadp vboxpci vboxnetflt, The modules directory is /lib/modules/3.0.6-gentoo/, the config file directory is /etc/modules.autoload.d/kernel-3.0.6, in this file, the modules are all included. And Now after i reboot it, use lsmod, I can't see these modules loaded. What's the the problem?

thinkpad walle # ls -l /boot/
总用量 17068
lrwxrwxrwx 1 root root       1  1月 10 01:22 boot -> .
drwxr-xr-x 2 root root    4096  4月 27 10:55 grub
-rw-r--r-- 1 root root 5771120  3月 23 09:27 kernel-3.0.6
-rw-r--r-- 1 root root 5771120  4月 26 17:48 kernel-3.0.6-n5
-rw-r--r-- 1 root root 5876784  4月 27 10:55 kernel-3.0.6-n6
drwx------ 2 root root   16384  1月 17 15:47 lost+found

Now I use kernel-3.0.6-n6 as my boot kernel.

thinkpad walle # cat /etc/modules.autoload.d/kernel-3.0.6 
xt_mark
test_nx
scsi_wait_scan
wlagn
ext2
vboxdrv
vboxnetadp
vboxpci
vboxnetflt

Answer

mattst88 picture mattst88 · May 24, 2012

The autoloaded modules are specified in /etc/conf.d/modules according to http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=1&chap=7#doc_chap5

The /etc/init.d/modules script reads the /etc/conf.d/modules file and loads the modules. It should already be in the boot runlevel, but if it isn't, run rc-update add modules boot to have them loaded on boot.