本文共 2117 字,大约阅读时间需要 7 分钟。
在系统管理过程中,了解并管理系统中的内核模块是非常重要的操作之一。以下将详细介绍如何检查、加载、卸载模块,并配置模块参数。
使用lsmod
命令可以查看系统当前加载的所有模块。例如:
# lsmod
注意:如果需要查看特定模块(如st
模块),可以结合grep
命令筛选结果:
# lsmod | grep st
为了了解模块的具体信息,可以使用modinfo
命令。例如,查看st
模块的详细信息:
# modinfo -p st
输出结果会包括模块的文件路径、别名、许可证信息、描述、作者等内容。
使用modprobe
命令可以加载模块。例如:
# modprobe st
查看加载后的状态:
# lsmod | grep st
使用rmmod
命令可以卸载模块。例如:
# rmmod st
卸载完成后,重新查看模块列表:
# lsmod | grep st
使用cat
命令可以查看模块参数的默认值。例如:
# cat /sys/module/usb_storage/parameters/delay_use# cat /sys/module/sx8/parameters/max_queue
在/etc/modprobe.d/my.conf
文件中设置参数。例如:
options usb_storage delay_use=3options sx8 max_queue=15options st buffer_kbs=256
首先卸载所有相关模块:
# rmmod st# rmmod sx8# rmmod usb_storage
然后重新加载模块:
# modprobe st# modprobe sx8# modprobe usb_storage
确认参数修改是否生效:
# cat /sys/module/usb_storage/parameters/delay_use# cat /sys/module/sx8/parameters/max_queue
在/etc/rc.sysinit
文件中,系统会自动加载所有以.modules
结尾的文件。您可以在/etc/sysconfig/modules
目录下创建自定义文件:
# echo "modprobe st" >> /etc/sysconfig/modules/my.modules# echo "modprobe sx8" >> /etc/sysconfig/modules/my.modules# echo "modprobe usb_storage" >> /etc/sysconfig/modules/my.modules
并赋予文件执行权限:
# chmod a+x /etc/sysconfig/modules/my.modules
在/etc/modprobe.d/my.conf
文件中设置模块参数,系统启动时会自动读取并应用这些参数。
在/etc/modprobe.conf
文件中添加以下内容:
# vi /etc/modprobe.confinstall ipv6 /bin/true
这样可以禁用IPv6模块。
在/etc/sysconfig/network
文件中设置:
# vi /etc/sysconfig/networkNETWORKING_IPV6=noIPV6INIT=no
# service network restart
# rmmod ipv6
检查模块状态:
# lsmod | grep ipv6
检查网络接口:
# /sbin/ifconfig
在/etc/sysconfig/network
文件中设置:
# vi /etc/sysconfig/networkNETWORKING_IPV6=noIPV6INIT=no
在/etc/modprobe.d/ipv6off.conf
文件中添加:
alias net-pf-10 offoptions ipv6 disable=1
# service network restart
检查模块状态:
# lsmod | grep ipv6
检查网络接口:
# /sbin/ifconfig
通过以上操作,您可以轻松地管理模块、配置模块参数,并禁用不需要的模块。
转载地址:http://xeufk.baihongyu.com/