如何在 Gentoo Linux 中自动加载内核模块?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10730096/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to autoload a kernel module in Gentoo Linux?
提问by Fei Xue
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?
我想在启动时自动加载一些内核模块。我已经阅读了手册,但无能为力。现在我要自动加载vboxdrv
vboxnetadp
vboxpci
vboxnetflt
的模块是/lib/modules/3.0.6-gentoo/
,模块目录是,配置文件目录是/etc/modules.autoload.d/kernel-3.0.6
,在这个文件中,模块都包含在内。现在在我重新启动它后,使用lsmod
,我看不到这些模块已加载。有什么问题?
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.
现在我kernel-3.0.6-n6
用作我的引导内核。
thinkpad walle # cat /etc/modules.autoload.d/kernel-3.0.6
xt_mark
test_nx
scsi_wait_scan
wlagn
ext2
vboxdrv
vboxnetadp
vboxpci
vboxnetflt
采纳答案by Wataru
/etc/conf.d/modules is not used now. Systemd uses its own structure
现在不使用 /etc/conf.d/modules。Systemd 使用自己的结构
Put your module list file in /etc/modules-load.d/ man modules-load.d
将您的模块列表文件放在 /etc/modules-load.d/ man modules-load.d
Put your module option file in /etc/modprobe.d/ man modprobe.d
将您的模块选项文件放在 /etc/modprobe.d/man modprobe.d
回答by mattst88
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
自动加载的模块/etc/conf.d/modules
根据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.
该/etc/init.d/modules
脚本读取/etc/conf.d/modules
文件并加载模块。它应该已经在引导运行级别,但如果不是,请运行rc-update add modules boot
以在引导时加载它们。
回答by Tim Gabets
Well, editing /etc/conf.d/modules is not autoloading, because you need to edit this file after every kernel rebuild.
好吧,编辑 /etc/conf.d/modules 不是自动加载的,因为您需要在每次内核重建后编辑此文件。
The main idea about autoloading hardwarekernel modules is described here: http://doc.opensuse.org/documentation/html/openSUSE/opensuse-reference/cha.udev.htmland http://wiki.gentoo.org/wiki/Udev
这里描述了自动加载硬件内核模块的主要思想:http: //doc.opensuse.org/documentation/html/openSUSE/opensuse-reference/cha.udev.html和 http://wiki.gentoo.org/wiki/乌德夫
In few words: udev is managing your hardware, and every time when new hardware appears (kernel creates link in /dev), udev makes search for a proper kernel module, and loads it if found. All the device information is provided by sysfs.
简而言之:udev 正在管理您的硬件,每次出现新硬件时(内核在 /dev 中创建链接),udev 都会搜索合适的内核模块,如果找到就加载它。所有设备信息都由 sysfs 提供。