depmod.depdeb格式文件怎么安装没有

新浪广告共享计划>
广告共享计划
简单实例讲解linux的module模块编译步骤
本文将直接了当的带你进入linux的模块编译。当然在介绍的过程当中,我也会添加一些必要的注释,以便初学者能够看懂。之所以要写这篇文章,主要是因为从书本上学的话,可能要花更长的时间才能学会整个过程,因为看书的话是一个学习过程,而我这篇文章更像是一个培训。所以实践性和总结性更强。通过本文你将会学到编译一个模块和模块makefile的基本知识。以及加载(卸载)模块,查看系统消息的一些知识;
声明:本文为初学者所写,如果你已经是一个linux模块编译高手,还请指正我文章中的错误和不足,谢谢
第一步:准备源代码
首先我们还是要来编写一个符合linux格式的模块文件,这样我们才能开始我们的模块编译。假设我们有一个源文件mymod.c。它的源码如下:
我们的源文件就准备的差不多了,这就是一个linux下的模块的基本结构。第9行是导出我们的符号变量nbr。这样在你加载这个模块的时候可以动态修改这个变量的值。稍后将演示。yuer_init()函数将在模块加载的时候运行,通过输出的结果可以看到我们的模块是否加载成功。
第二步:编写Makefile文件&&&&
首先还是来看看我们Makefile的源文件,然后我们再来解释;
modules.o&&&&&&&&&&&&&&&&&&&#要生成的模块名&&&&&
modules-objs:=&mymod.o&&&&&&&&#生成这个模块名所需要的目标文件
KDIR := /lib/modules/`uname -r`/build
PWD := $(shell pwd)
make -C $(KDIR) M=$(PWD) modules
rm -rf *.o .* .cmd *.ko *.mod.c .tmp_versions
现在我来说明一下这个Makefile。请记住是大写的Makefile而不是小写的makefile;
obj-m :这个变量是指定你要声称哪些模块模块的格式为 obj-m :=
&模块名&.o
modules-objs
:这个变量是说明声称模块modules需要的目标文件 格式要求&&
&模块名&-objs := &目标文件&
切记:模块的名字不能取与目标文件相同的名字。如在这里模块名不能取成 mymod;
:这是我们正在运行的操作系统内核编译目录。也就是编译模块需要的环境
:指定我们源文件的位置
:这是当前工作路径$(shell&&
)是make的一个内置函数。用来执行shell命令。
第三步:编译模块
现在我们已经准备好了我们所需要的源文件和相应的Makefile。我们现在就可以编译了。在终端进入源文件目录输入make
运行结果:
第四步:加载/卸载我们的模块
从上面的编译中我可以看到。已经有一个modules.ko生成了。这就是我们的模块了。现在我们就可以来加载了。
首先在终端输入:sudo
insmod modules.ko
现在我们来看看我们的模块加载成功没有呢?
在终端输入:dmesg
-12&&&这是查看内核输出信息的意思。tail
-12 显示最后12条;
显示结果如下:
看到了吧。我们的模块的初始化函数yuer_init();已经成功运行了。说明我们的模块已经加载成功;
现在我们再来卸载模块试试看。
在终端输入:sudo
rmmod modules
在终端输入:dmesg
可以从打印的信息中看到,我们的模块的退出函数已经被执行了。说明我们的模块已经被成功的卸载了。到目前位置我们就已经算是对模块的编译到编译运行算是有了一个整体上的认识了。对于以后深入的学习还是应该有点帮助的。下面我们将在看看于模块相关的一些简单的操作。
第五步:加载模块时传递参数
在终端输入:sudo
insmod module_name.ko nbr=4
在终端输入:dmesg
显示结果如下:
这样我们就可以看到在模块加载的时候动态设置了我们的一个变量。初始化函数中的循环只执行了4次。
可能你会问我怎么知道一个模块可以设置那些变量呢。当然,你可以先不设变量加载一次。然后可以在终端输入ls
/sys/module//parameters/来查看。在这里我们是这样输入的
在终端输入:ls
/sys/moedle/modules/parameters/
显示结果:
如果我们的模块加载成功了。最后我们还可以通过modinfo来查看我们的模块信息。如下
在终端输入:sudo
modinfo modules.ko
显示结果:
本文总结:&&&
本文的相关知识都好像有一点浅尝辙止的感觉。因为本篇文章主要是通过一条线式方式来讲解了模块编写的相关过程,其实在这个过程中还有很多可以发散的地方。例如:
在写到MODULE_AUTHOR("Yu Qiang")的时候,你应该想到还有
MODULE_DESCRIPTION(模块用途的简单描述);&&&&MODULE_VERSION(模块的版本字符串);
&&&&MODULE_ALIAS(模块的别名);
在写到module_param(nbr, int, S_IRUGO);的时候,你应该想到还有
EXPORT_SYMBOL(name); 可以导出模块的函数,这也是模块编写的最终目的
在用到insmod 和 modinfo的时候。你应该想到还有
&&&&depmod&&&&
分析可加载模块的依赖性,并生成modules.dep文件和映射文件
&&&&modprobe&&&Linux内核添加删除模块
已投稿到:
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。新手园地& & & 硬件问题Linux系统管理Linux网络问题Linux环境编程Linux桌面系统国产LinuxBSD& & & BSD文档中心AIX& & & 新手入门& & & AIX文档中心& & & 资源下载& & & Power高级应用& & & IBM存储AS400Solaris& & & Solaris文档中心HP-UX& & & HP文档中心SCO UNIX& & & SCO文档中心互操作专区IRIXTru64 UNIXMac OS X门户网站运维集群和高可用服务器应用监控和防护虚拟化技术架构设计行业应用和管理服务器及硬件技术& & & 服务器资源下载云计算& & & 云计算文档中心& & & 云计算业界& & & 云计算资源下载存储备份& & & 存储文档中心& & & 存储业界& & & 存储资源下载& & & Symantec技术交流区安全技术网络技术& & & 网络技术文档中心C/C++& & & GUI编程& & & Functional编程内核源码& & & 内核问题移动开发& & & 移动开发技术资料ShellPerlJava& & & Java文档中心PHP& & & php文档中心Python& & & Python文档中心RubyCPU与编译器嵌入式开发驱动开发Web开发VoIP开发技术MySQL& & & MySQL文档中心SybaseOraclePostgreSQLDB2Informix数据仓库与数据挖掘NoSQL技术IT业界新闻与评论IT职业生涯& & & 猎头招聘IT图书与评论& & & CU技术图书大系& & & Linux书友会二手交易下载共享Linux文档专区IT培训与认证& & & 培训交流& & & 认证培训清茶斋投资理财运动地带快乐数码摄影& & & 摄影器材& & & 摄影比赛专区IT爱车族旅游天下站务交流版主会议室博客SNS站务交流区CU活动专区& & & Power活动专区& & & 拍卖交流区频道交流区
UID空间积分0 积分630阅读权限20帖子精华可用积分632 信誉积分102 专家积分0 在线时间10 小时注册时间最后登录
丰衣足食, 积分 630, 距离下一级还需 370 积分
帖子主题精华可用积分632 信誉积分102 专家积分0 在线时间10 小时注册时间最后登录
论坛徽章:0
还是继续我的netfilter问题,我看modules.dep里面涉及了很多netfilter的模块,可是在对应的/lib/modules/2.4.XX/.../netfilter下并没有这些模块,这个是怎么回事呢?
我重新编译内核后,make modules_install 和make install看来并没有把netfilter下面所有.o文件拷到/lib/modules下面啊
那这些没有的模块是怎么关联的呢?
----------------
&&nbsp|&&nbsp&&nbsp|&&nbsp&&nbsp|&&nbsp&&nbsp|&&nbsp
人生的转折
UID1728743空间积分0 积分85674阅读权限100帖子精华可用积分85674 信誉积分1131 专家积分599 在线时间1210 小时注册时间最后登录
帖子主题精华可用积分85674 信誉积分1131 专家积分599 在线时间1210 小时注册时间最后登录
论坛徽章:0
depmod -a,贴一下结果
当我们在为生活而疲惫奔波的时候
生活却渐渐离我们远去
find our way, find our style
Platinum's BLog
UID空间积分0 积分630阅读权限20帖子精华可用积分632 信誉积分102 专家积分0 在线时间10 小时注册时间最后登录
丰衣足食, 积分 630, 距离下一级还需 370 积分
帖子主题精华可用积分632 信誉积分102 专家积分0 在线时间10 小时注册时间最后登录
论坛徽章:0
depmod: cannot read ELF header from /lib/modules/2.4.31/kernel/net/ipv4/netfilter/netfilter.o
depmod: *** Unresolved symbols in /lib/modules/2.4.31/kernel/net/ipv4/netfilter/ip_conntrack_core.o
depmod: *** Unresolved symbols in /lib/modules/2.4.31/kernel/net/ipv4/netfilter/ip_conntrack_standalone.o
----------------
人生的转折
UID1728743空间积分0 积分85674阅读权限100帖子精华可用积分85674 信誉积分1131 专家积分599 在线时间1210 小时注册时间最后登录
帖子主题精华可用积分85674 信誉积分1131 专家积分599 在线时间1210 小时注册时间最后登录
论坛徽章:0
把那三个错误的文件删掉,再贴一下 depmod -a
当我们在为生活而疲惫奔波的时候
生活却渐渐离我们远去
find our way, find our style
Platinum's BLog
UID空间积分0 积分630阅读权限20帖子精华可用积分632 信誉积分102 专家积分0 在线时间10 小时注册时间最后登录
丰衣足食, 积分 630, 距离下一级还需 370 积分
帖子主题精华可用积分632 信誉积分102 专家积分0 在线时间10 小时注册时间最后登录
论坛徽章:0
我在重新编译内核了。我去看了别人的机器,人家/lib下面的模块是全的.
这个问题so奇怪啊。。。。。。
我把我的步骤写一下吧:
下kernel src, 还有netfilter的
到源码目录下 make mrproper, make menuconfig
给netfilter打patch
make menuconfig, 选上新功能
make clean
make bzImage
make modules
make modules_install, 这时发现/lib/modules。。。/netfilter里面的模块不全,就把源码中netfilter下面的.o全部考过去
make install
ip_conntrack_core.o 和ip_conntrack_standalone.o是unsolved symbols
我insmod ip_conntrack_core.o以后,出来一大堆东西是unsolved symbols.
我把他们删除了以后,depmod -a 就没有输出信息了。
这两个模块是用做什么的啊?删除后netfilter是不是就不能用了阿?
[ 本帖最后由 shuxi_w 于
18:15 编辑 ]
----------------
人生的转折
UID1728743空间积分0 积分85674阅读权限100帖子精华可用积分85674 信誉积分1131 专家积分599 在线时间1210 小时注册时间最后登录
帖子主题精华可用积分85674 信誉积分1131 专家积分599 在线时间1210 小时注册时间最后登录
论坛徽章:0
make modules_install, 这时发现/lib/modules。。。/netfilter里面的模块不全,就把源码中netfilter下面的.o全部考过去
ip_conntrack_core.o 和ip_conntrack_standalone.o是unsolved symbols
我insmod ip_conntrack_core.o以后,出来一大堆东西是unsolved symbols.
这是必然的
建议搜索一下我的一篇关于给 netfilter 打补丁的贴子
当我们在为生活而疲惫奔波的时候
生活却渐渐离我们远去
find our way, find our style
Platinum's BLog
UID空间积分0 积分630阅读权限20帖子精华可用积分632 信誉积分102 专家积分0 在线时间10 小时注册时间最后登录
丰衣足食, 积分 630, 距离下一级还需 370 积分
帖子主题精华可用积分632 信誉积分102 专家积分0 在线时间10 小时注册时间最后登录
论坛徽章:0
啊...为什么是必然的呢?我还是想知道原因。
这两个.o文件是干什么的呢,如果删除了,岂不是不能用了。
[ 本帖最后由 shuxi_w 于
19:40 编辑 ]
----------------
UID空间积分0 积分630阅读权限20帖子精华可用积分632 信誉积分102 专家积分0 在线时间10 小时注册时间最后登录
丰衣足食, 积分 630, 距离下一级还需 370 积分
帖子主题精华可用积分632 信誉积分102 专家积分0 在线时间10 小时注册时间最后登录
论坛徽章:0
总结一下netfilter的makefile
export-objs = ip_conntrack_standalone.o ip_fw_compat.o ip_nat_standalone.o ip_tables.o arp_tables.o
ip_conntrack.o: ip_conntrack_standalone.o ip_conntrack_core.o ip_conntrack_proto_generic.o ip_conntrack_proto_tcp.o ip_conntrack_proto_udp.o ip_conntrack_proto_icmp.o
iptable_nat.o: ip_nat_standalone.o ip_nat_rule.o ip_nat_core.o ip_nat_helper.o ip_nat_proto_unknown.o ip_nat_proto_tcp.o ip_nat_proto_udp.o ip_nat_proto_icmp.o
内核模块把一些普通模块合在一起,所以就少了。
----------------
人生的转折
UID1728743空间积分0 积分85674阅读权限100帖子精华可用积分85674 信誉积分1131 专家积分599 在线时间1210 小时注册时间最后登录
帖子主题精华可用积分85674 信誉积分1131 专家积分599 在线时间1210 小时注册时间最后登录
论坛徽章:0
按照我的方法做一遍,一定可以的
你的问题出在部分模块不匹配,影响了 modules.dep
而 modprobe 或 insmod 或其他方法载入模块时需要 /lib/modules/`uname -r`/modules.dep
当我们在为生活而疲惫奔波的时候
生活却渐渐离我们远去
find our way, find our style
Platinum's BLog
UID空间积分0 积分630阅读权限20帖子精华可用积分632 信誉积分102 专家积分0 在线时间10 小时注册时间最后登录
丰衣足食, 积分 630, 距离下一级还需 370 积分
帖子主题精华可用积分632 信誉积分102 专家积分0 在线时间10 小时注册时间最后登录
论坛徽章:0
总结一下netfilter的makefile
export-objs = ip_conntrack_standalone.o ip_fw_compat.o ip_nat_standalone.o ip_tables.o arp_tables.o
ip_conntrack.o: ip_conntrack_standalone.o ip_conntrack_core.o ip_conntrack_proto_generic.o ip_conntrack_proto_tcp.o ip_conntrack_proto_udp.o ip_conntrack_proto_icmp.o
iptable_nat.o: ip_nat_standalone.o ip_nat_rule.o ip_nat_core.o ip_nat_helper.o ip_nat_proto_unknown.o ip_nat_proto_tcp.o ip_nat_proto_udp.o ip_nat_proto_icmp.o
内核模块把一些普通模块合在一起,所以就少了。
----------------1390人阅读
一、安装内核模块:
一般步骤:
(1) 在/usr/src/linux/下运行make menuconfig把需要编译成模块的项打上(M),保存并退出。
(2) 运行make modules,这一步将在/usr/src/linux/下生成*.o或*.ko文件。
(3) 运行make modeules_install来安装,这步会把生成的.o或ko文件拷贝到/lib/modules/`uname -r`/下。
如果你只要编译某一个或几个模块,就可以用下面这个快速的方法:
(1) 找到编译内核所需要的.config文件。
在/usr/src/linux/arch目录下有若干编译内核所用的配置。选择我们想要的配置,将它复制到/usr/src/linux目录下,改名为.config。
cp /usr/src/linux/arch/x86/xxconfig /usr/src/linux/.config
(2) 修改.config文件,去掉不用的模块,加上自己想要的模块。
打开.config,有许多XXXX=m的项,这些都是要被编译为模块的项,因为我们不希望编译这些模块,所以要把XXXX=m的项统统去掉。然后再加上我们想要的模块,例如将# CONFIG_NTFS_FS is notset 改为CONFIG_NTFS_FS=m 当然,可以用你熟悉各种工具来做这件事。
(3) 编译NTFS模块。
在/usr/src/linux目录下运行命令make modules来编译我们想要的模块。
(4) 安装模块。
编译后得到的.o文件在/usr/src/linux/目录下,手动将它复制到正确的目录下。
  例如cp /usr/src/linux/fs/ntfs/ntfs.o /lib/modules/2.2.16-22/fs/
&注意:千万不能运行命令make modules_install,否则将带来严重的后果,它会删除你系统中的所有模块,只安装刚刚编译的模块(ntfs.o)。
二:安装完成以后,我们就可以加载模块了:
和linux中加载模块有关的几个命令分别如下:
depmod,modprobe,lsmod
先来看看depmod命令:
depmod是一个用来产生modules.dep和map文件的程序。在modules.dep文件中空白行和以'#'开头的行将被忽略.depmod通过读取/lib/modules/version目录下的每一个模块来创建一个记录模块相依性的列表。这个列表就是/lib/modules/version目录下的modules.dep。depmod也会在/lib/modules/version目录下创建许多map文件,例如modules.dep,modules.isapnpmap,modules.pcimap,modules.alias这些文件将会被hotplug用到。
-a --all Probe all modules. This option is enabled by default if no
&&&&&&&&&&& file names are given in the command-line.
检查所有的模块,这个命令是默认的如果你没有指定模块名字的话。
-A --quick This option scans to see if any modules are newer than the
&&&&&&&&&&&&&&&& modules.dep file before any work is done%3
再来看看modprobe命令:
modprobe 命令是根据depmod -a的输出/lib/modules/version/modules.dep来加载全部的所需要模块。可以通过modprobe -l来显示可以当前可以加载的模块。modprobe 在挂载模块是不用指定模块文件的路径,也不用带文件的后缀.o 或.ko,而insmod 需要的是模块的所在目录的绝对路径,并且一定要带有模块文件名后缀的(modulefile.o
或modulesfile.ko )。 insmod比较重要的用途是用来测试模块的正确性,加载一般都是依靠modprobe。
用法:modprobe xxx.ko&&&&&&& #加载某个模块
modprobe -r xxx.ko&&&& #卸载某个模块
lsmod显示当前加载的所有 模块,相当于cat/proc/modules,假设你没有设定开机加载某个模块,比如ntfs,那么开机后执行lsmod,列表里不会有ntfs这个模块的,这时你再执行mount -t ntfs xxx后,执行lsmod后列表里就会有ntfs这个模块了。
还要注意的是lsmod显示的是模块名,而不是别名(alias)。
三、在内核中有一个“Automatic kernel module loading&功能被编译到了内核中。当用户尝试打开某类型的文件时,内核会根据需要尝试加载相应的模块。我们来看看驱动程序自动加载是怎么实现的:
&&&&& 每一个设备都有Verdon ID, Device ID, SubVendor ID等信息。而每一个设备驱动程序,必须说明自己能够为哪些Verdon ID, Deviece
& ID, SubVendor ID的设备提供服务。以PCI设备为例,它是通过一个pci_device_id的数据结构来实现这个功能的。例如:RTL8139的pci_device_id定义为:
static struct pci_device_id rtl8139_pci_tbl[] = {
&&&&& {0x10ec, 0x8139, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
&&&&& {0x10ec, 0x8138, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
&&&&& ......
在模块安装的时候,depmod会根据模块中的rtl8139_pci_tbl的信息,生成下面的信息,保存到/lib/modules/uname-r/modules.alias文件中,其内容如下:
alias pci:v000010ECdsv*sd*bc*sc*i* 8139too
alias pci:v000010ECdsv*sd*bc*sc*i* 8139too
另外在/lib/modules/uname-r/modules.dep文件中还保存这模块之间的依赖关系,其内容如下:
(这里省去了路径信息。)
8139too.ko:mii.ko
在内核启动过程中,总线驱动程序会会总线协议进行总线枚举(总线驱动程序总是集成在内核之中,不能够按模块方式加载,你可以通过make menuconfig进入Bus
options,这里面的各种总线,你只能够选择Y或N,而不能选择M.),并且为每一个设备建立一个设备对象。每一个总线对象有一个kset对象,每一
个设备对象嵌入了一个kobject对象,kobject连接在kset对象上,这样总线和总线之间,总线和设备设备之间就组织成一颗树状结构。当总线驱
动程序为扫描到的设备建立设备对象时,会初始化kobject对象,并把它连接到设备树中,同时会调用kobject_uevent()把这个(添加新设
备的)事件,以及相关信息(包括设备的VendorID,DeviceID等信息。)通过netlink发送到用户态中。在用户态的udevd检测到这个
事件,就可以根据这些信息,打开/lib/modules/uname-r
/modules.alias文件,根据
alias pci:v000010ECdsv*sd*bc*sc*i* 8139too
得知这个新扫描到的设备驱动模块为8139too。于是modprobe就知道要加载8139too这个模块了,同时modprobe根据
modules.dep文件发现,8139too依赖于mii.ko,如果mii.ko没有加载,modprobe就先加载mii.ko,接着再加载
8139too.ko。
在你的shell中,运行:
# ps aux | grep udevd
# kill -9 25063然后跟踪udevd,在shell中运行:
# strace -f /sbin/udevd --daemon
这时,我们看到udevd的输出如下:
munmap(0xb7f8c000, 4096)
select(7, [3 4 5 6], NULL, NULL, NULL
我们发现udevd在这里被阻塞在select()函数中。
select函数原型如下:
int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
第一个参数:nfds表示最大的文件描述符号,这里为7(明明是6 ?)。
第二个参数:readfds为读文件描述符集合,这里为3,4,5,6.
第三个参数:writefds为写文件描述符集合,这里为NULL。
第四个参数:exceptfds为异常文件描述符集合,这里为NULL。
第五个参数:timeout指定超时时间,这里为NULL。
select函数的作用是:如果readfds中的任何一个文件有数据可读,或者witefds中的任何一个文件可以写入,或者exceptfds中的任
何一个文件出现异常时,就返回。否则阻塞当前进程,直到上诉条件满足,或者因阻塞时间超过了timeout指定的时间,当前进程被唤醒,select返
回。 所以,在这里udevd等待3,4,5,6这几个文件有数据可读,才会被唤醒。现在,到shell中运行:
# ps aux | grep udevd
...... strace -o /tmp/udevd.debug -f /sbin/udevd --daemon
...... /sbin/udevd --daemon
udevd的进程id为27617,现在我们来看看select等待的几个文件:
# cd /proc/27615/fd
udevd的标准输入,标准输出,标准错误全部为/dev/null.
0 -& /dev/null
1 -& /dev/null
2 -& /dev/null
udevd在下面这几个文件上等待。
3 -& /inotify
4 -& socket:[331468]
5 -& socket:[331469]
6 -& pipe:[331470]
7 -& pipe:[331470]
由于不方便在运行中插入一块8139的网卡,因此现在我们以一个U盘来做试验,当你插入一个U盘后,你将会看到strace的输出,从它的输出可以看到
udevd在select返回后,调用了modprobe加载驱动模块,并调用了sys_mknod,在dev目录下建立了相应的节点。
execve(&/sbin/modprobe&, [&/sbin/modprobe&, &-Q&, &usb:v05ACpdc00dsc00dp00&...]
mknod(&/dev/sdb&, S_IFBLK|0660, makedev(8, 16)) = 0
这里modprobe的参数&usb:v05AC...&对应modules.alias中的某个模块。
可以通过udevmonitor来查看内核通过netlink发送给udevd的消息,在shell中运行:
# udevmonitor --env
然后再插入U盘,就会看到相关的发送给udevd的消息。
四、内核模块加载的配置:
有时候需要一次性加载许多模块,需要在一个地方统一配置modprobe的选项等,有一个比较重要的文件:/etc/modprobe.conf,在opensuse中,和它有关的还有modprobe.d/文件夹下的许多文件和modprobe.conf.local文件,在/etc/modprobe.conf里会include其它所说的文件,一般建议在modprobe.conf.local中修改自己的配置。/etc/modprobe.conf其实就是用于写入模块的加载命令或模块的别名的定义等。man
modprobe.conf:
alias my-mod really_long_modulename为模块定义一个便于使用的别名
options modulename option...在加载模块时添加选项
install modulename command...使用自己定义的命令去加载指定的模块,如install fred /sbin/ /sbin/modprobe
&&&&&&&&&&&&& --ignore-install fred& 每次加载fred模块的时候用的是“/sbin/ /sbin/modprobe
&&&&&&&&&&&&& --ignore-install fred”命令
remove modulename command...用自己定义的命令删除指定的模块。
include filename 引入其它文件
blacklist modulename 不再加载某个模块
五、内核模块开机自动挂载:
对于开机自动挂载模块,在redhat系统里,网上说在内核启动的过程中,init执行/etc/rc.d/rc.sysinit后,启动内核外挂模块时会读取/etc/modprobe.conf这个文件。在2.4的内核中,只要直接修改/etc/modprobe.conf加入installxxx即可。2.6内核则需修改/etc/rc.d/rc.sysinit文件。具体的过程可以看:http://blog.csdn.net/ioriqqe/archive//4772033.aspx
而在suse里,可以在root权限编辑/etc/sysconfig/kernel文件,添加需要启动的模块。
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:72889次
排名:千里之外
转载:25篇
(1)(1)(1)(1)(1)(1)(2)(1)(2)(4)(4)(4)(6)depmod - Linux Command - Unix Command
Share this page on:
Your suggestion is on its way!
An email with a link to:
was emailed to:
Thanks for
with others!
Most Emailed Articles
Linux / Unix Command: depmod
depmod - handle dependency descriptions for loadable kernel modules
[-aA] [-ehnqrsuvV]
[-C&configfile] [-F&kernelsyms] [-b basedirectory]
[forced_version]
depmod [-enqrsuv] [-F kernelsyms] module1.o module2.o ...
DESCRIPTION
utilities are intended
to make a Linux modular kernel manageable for all users,
administrators and distribution maintainers.
creates a &Makefile&-like dependency file, based on the symbols it finds
in the set of modules mentioned on the command line
or from the directories specified in the configuration file.
This dependency file is later used by
to automatically load the correct module or stack of modules.
The normal use of
is to include the line
/sbin/depmod -a
somewhere in the rc-files
/etc/rc.d,
so that the correct module dependencies will be available
immediately after booting the system.
Note that the option
is now optional.
For boot-up purposes, the option
might be more appropriate since that makes depmod silent about
unresolved symbols.
It is also possible to create the dependency file immediately
after compiling a new kernel.
If you do &depmod&-a&2.2.99&
when you have compiled kernel 2.2.99 and
its modules the first time, while still running e.g. 2.2.98, the file will
be created in the correct place.
In this case however,
the dependencies on the kernel will not be guaranteed to be correct.
See the options
-F,&-C&and&-b
above for more information on handling this.
While building the relationship between modules and the symbols
exported by other modules,
does not consider the GPL status of the modules nor of the exported
That is, depmod will not flag an error if a module without a
GPL compatible license refers to a GPL only symbol (EXPORT_SYMBOL_GPL
in the kernel).
However insmod will refuse to resolve GPL only symbols
for non-GPL modules so the actual load will fail.
Search for modules in all directories specified in the (optional)
configuration file
/etc/modules.conf.
-A, --quick
Compare file timestamps and, if necessary, act like
depmod -a.
This option only updates the dependency file if anything has changed.
-e, --errsyms
Show all the unresolved symbols for each module.
-h, --help
Display a summary of options and immediately exit.
-n, --show
Write the dependency file on stdout instead of in the /lib/modules tree.
-q, --quiet
Tell depmod to keep quiet and not to complain about missing symbols.
-r, --root
Some users compile modules under a non-root userid then install the
modules as root.
This process can leave the modules owned by the
non-root userid, even though the modules directory is owned by root.
If the non-root userid is compromised, an intruder can overwrite
existing modules owned by that userid and use this exposure to
bootstrap up to root access.
By default, modutils will reject attempts to use a module that is not
owned by root.
Specifying -r will suppress the error and allow root to
load modules that are not owned by root.
Use of -r is a major security exposure and is not recommended.
-s, --syslog
Write all error messages via the syslog daemon instead of stderr.
-u, --unresolved-error
depmod 2.4 does not set a return code when there are any unresolved
The next major release of modutils (2.5) will set a return
code for unresolved symbols.
Some distributions want a non-zero return
code in modutils 2.4 but that change might cause problems for users who
expect the old behaviour.
If you want a non-zero return code in depmod
2.4, specify -u.
depmod 2.5 will silently ignore the
-u flag and will always give a non-zero return code for unresolved
-v, --verbose
Show the name of each module as it is being processed.
-V, --version
Display the version of depmod.
The following options are useful for people managing distributions:
-b basedirectory, --basedir basedirectory
If the directory tree
/lib/modules
containing the sub-trees of modules is moved somewhere else in order to
handle modules for a different environment, the
option tells depmod where to find the moved image of the
/lib/modules
The file references in the depmod output file that is built,
modules.dep,
will not contain the
basedirectory
This means that when the file tree is moved back from
basedirectory/lib/modules
/lib/modules
in the final distribution, all references will be correct.
-C configfile, --config configfile
Use the file
configfile
instead of
/etc/modules.conf.
The environment variable
MODULECONF
can also be used to select a different
configuration file from the default
/etc/modules.conf
/etc/conf.modules
(deprecated)).
When environment variable
UNAME_MACHINE
is set, modutils will use its value instead of the machine field from
the uname() syscall.
This is mainly of use when you are compiling 64 bit modules in 32 bit
user space or vice versa, set
UNAME_MACHINE
to the type of the modules being built.
Current modutils does not support full cross build mode for modules, it
is limited to choosing between 32 and 64 bit versions of the host
architecture.
-F kernelsyms,--filesyms kernelsyms
When building dependency files for a different kernel than the currently
running kernel, it is important that
uses the correct set of kernel symbols to resolve the kernel references
in each module.
These symbols can either be a copy of
System.map
from the other kernel,
or a copy of the output from
/proc/ksyms.
If your kernel uses versioned symbols, it is best to
use a copy of the
/proc/ksyms
output, since that file contains the symbol versions of the kernel
However you can use a
System.map
even with versioned symbols.
CONFIGURATION
The behavior of
can be adjusted by the (optional) configuration file
/etc/modules.conf.
for a complete description.
Each time you compile a new kernel, the command &make modules_install&
will create a new directory, but won't change the default.
When you get a module unrelated to the kernel distribution
you should place it in one of the version-independent directories
/lib/modules.
This is the default strategy, which can be overridden in
/etc/modules.conf.
(5), (8), (8),
Important:
Use the man command (% man) to see how a command is used on your
particular computer.
Related Articles
Free Linux Newsletter!Sign UpYou can opt-out at any time. Please refer to our
for contact information.
Explore Linux
Must Reads
Most Popular
Free Linux Newsletter!Sign Up
By Category
linuxLinuxcomputeTechbcbaod526F6FliveGary Newelllinuxguide3TO004KpzNIP0/od/index.htmapproved/od
&. All rights reserved.

我要回帖

更多关于 debian安装deb文件 的文章

 

随机推荐