RH442中的内核模块部分包括加载,查询,参数配置,卸载
以教材的练习题为例
1、Load the sx8 module and confirm that it is loaded
modprobe sx8 #加载模块sx8 lsmod | grep sx8 #列出当前加载的模块,显示其中的sx8 sx8 14121 0 #结果显示中,第2列为模块大小,第3列是使用计数
2、Display information about sx8 module, including all possible parameters
[root@desktop7 ~]# modinfo sx8 filename: /lib/modules/2.6.32-220.el6.x86_64/kernel/drivers/block/sx8.ko version: 1.0 description: Promise SATA SX8 block driver license: GPL author: Jeff Garzik srcversion: 4772099AB984FE59198263E alias: pci:v0000105Ad00008002sv*sd*bc*sc*i* alias: pci:v0000105Ad00008000sv*sd*bc*sc*i* depends: vermagic: 2.6.32-220.el6.x86_64 SMP mod_unload modversions parm: max_queue:Maximum number of queued commands. (min==1, max==30, safe==1) (int)
3、Find the current value for the max_queue parameter. Can this be changed on-the-fly?
[root@server7 ~]# cat /sys/module/sx8/parameters/max_queue 1 [root@server7 ~]# ls -l /sys/module/sx8/parameters/max_queue -r--r--r--. 1 root root 4096 Jan 13 03:32 /sys/module/sx8/parameters/max_queue #从参数文件的权限可以看出,不允许直接配置该参数
4、Unload, then re-load the sx8 module, but this time setting the max_queue parameter to 4. Verify that the parameter is now set to 4.
,
[root@server7 ~]# rmmod sx8 #卸载内核模块(需要在模块未使用的情况下操作) [root@server7 ~]# modprobe sx8 max_queue=4 #重新加载,加载时指定参数max_queue [root@server7 ~]# cat /sys/module/sx8/parameters/max_queue 4 #查询确认max_queue参数已经修改为4
5、Configure your system so that the max_queue parameter will always be set to 4 whenever the sx8 module is loaded. Test your configuration by unloading then reloading the sx8 module without specifying parameter on the command-line.
[root@server7 ~]# vim /etc/modprobe.d/sx8.conf [root@server7 ~]# cat /etc/modprobe.d/sx8.conf #参数写入到配置文件 options sx8 max_queue=4 [root@server7 ~]# rmmod sx8 [root@server7 ~]# modprobe sx8 #重新加载内核模块 [root@server7 ~]# cat /sys/module/sx8/parameters/max_queue 4
转载于:https://blog.51cto.com/foolishfish/1384191