rmmod.html' target='_blank'>rmmod(remove module)
功能说明:删除模块。
语 法:rmmod [-as][模块名称...]
补充说明:执行rmmod指令,可删除不需要的模块。Linux操作系统的核心具有模块化的特性,应此在编译核心时,务须把全部的功能都放如核心。你可以将这些功能编译成一个个单独的模块,待有需要时再分别载入它们。
参 数:
-a 删除所有目前不需要的模块。
-s 把信息输出至syslog常驻服务,而非终端机界面。
与内核模块操作相关的命令还有:lsmod.html' target='_blank'>lsmod modinfo depmod rmmod inmod modprobe
范例1: 显示已安装的模块
root@linuxso.com:~# lsmod
Module Size Used by
cramfs 39042 1
nfsd 238935 11
lockd 64849 1 nfsd
nfs_acl 2245 1 nfsd
auth_rpcgss 33735 1 nfsd
sunrpc 193181 10 nfsd,lockd,nfs_acl,auth_rpcgss
export.html' target='_blank'>exportfs 3437 1 nfsd
xt_TCPMSS 2931 0
xt_tcpmss 1197 0
xt_tcpudp 2011 0
iptable_mangle 2771 0
ip_tables 9991 1 iptable_mangle
x_tables 14299 4
……省略部分结果
pppoe 8943 0
pppox 2074 1 pppoe
binfmt_misc 6587 1
snd_ens1371 18814 0
gameport 9089 1 snd_ens1371
snd_ac97_codec 100646 1 snd_ens1371
ac97_bus 1002 1 snd_ac97_codec
snd_pcm_oss 35308 0
范例2:卸载模块
root@linuxso.com:~# rmmod -v pppoe //卸载模块pppoe
Checking ppoe for persistent data
范例3: 安装模块
root@linuxso.com:~# insmod -v pppoe >1.log //安装模块
root@linuxso.com:~# tail -b 30 1.log //显示文件信息
扩展阅读:rmmod: chdir(/lib/modules): No such file or directory 解决方法 资料整理 www.linuxso.com
必须创建/lib/modules/2.6.30.4这样一个空目录,否则不能卸载ko模块.
# rmmod nls_cp936
rmmod: chdir(/lib/modules): No such file or directory
但是这样倒是可以卸载nls_cp936,不过会一直有这样一个提示:
rmmod: module 'nls_cp936' not found
1.创建/lib/modules/2.6.30空目录就.
2.使用如下源码生成rmmod命令,就可以没有任何提示的卸载ko模块了[luther.gliethttp]
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
int main(int argc, char *argv[])
{
const char *modname = argv[1];
int ret = -1;
int maxtry = 10;
while (maxtry-- > 0) {
ret = delete_module(modname, O_NONBLOCK | O_EXCL);//系统调用sys_delete_module
if (ret < 0 && errno == EAGAIN)
usleep(500000);
else
break;
}
if (ret != 0)
printf("Unable to unload driver module \"%s\": %s\n",
modname, strerror(errno));
}
3.把生成的命令复制到文件系统
# arm-linux-gcc -static -o rmmod rmmod.c
# arm-linux-strip -s rmmod
# cp rmmod /nfs/
cp /nfs/rmmod /sbin