Account Links: Cart | Register | Log In

Skip to content

Red Hat Knowledgebase
Red Hat Knowledgebase Search
Article translations:
Currently Being Moderated

应该如何修改/etc/modules.conf(RHEL3/2.1)或/etc/modprobe.conf(RHEL4)?

Article ID: 11466 - Created on: Jul 22, 2008 6:00 PM - Last Modified:  Jun 28, 2009 11:16 PM

[英文原文] How do I modify the /etc/modules.conf file?

 

解决方案:

 

只有在系统启动要加载新的设备驱动时才需要修改该文件,下面的内容提供了一个详细的示例如何修改该文件,使得系统在启动时自动加载网卡驱动和SCSI卡驱动。

 

修改/etc/modules.conf(RHEL3)或/etc/modprobe.conf(RHEL4)来加载网卡驱动模块:

 

下面是一个在使用Intel/Pro 1000网卡旧驱动e1000的例子

 



alias eth0 e1000
alias scsi_hostadapter aic7xxx
alias sound-slot-0 emu10k1
post-install sound-slot-0 /bin/aumix-minimal -f /etc/.aumixrc -L >/dev/null 2>&1 || :
pre-remove sound-slot-0 /bin/aumix-minimal -f /etc/.aumixrc -S >/dev/null 2>&1 || :
alias usb-controller usb-uhci

 

而新驱动的名字是e1000_5043k1,首先测试该驱动是否可以正常工作,在命令行模式下使用下面命令来测试:

 



rmmod 1000              //从内核中删除老模块
modprobe e1000_5043k1   //加入新模块到内核
lsmod |grep e1000       //确认新模块已经插入
ifconfig eth0 10.0.0.11 //然后给网卡配置IP
ping 10.0.0.254         //确认网卡工作正常

 

然后修改/etc/modules.conf(RHEL3)或/etc/modprobe.conf(RHEL4)如下:

 



alias eth0 e1000_5043k1
alias scsi_hostadapter aic7xxx
alias sound-slot-0 emu10k1
post-install sound-slot-0 /bin/aumix-minimal -f /etc/.aumixrc -L >/dev/null 2>&1 || :
pre-remove sound-slot-0 /bin/aumix-minimal -f /etc/.aumixrc -S >/dev/null 2>&1 || :
alias usb-controller usb-uhci

 

然后保存文件,这时候不需要重新编译initrd,下次系统启动怎会自动生效。

 

修改/etc/modules.conf(RHEL3)或/etc/modprobe.conf(RHEL4)来加载SCSI驱动模块:

 

下面是一个在使用LSI Logic Megaraid卡旧驱动megaraid的例子

 



alias parport_lowlevel parport_pc
alias eth0 e1000
alias scsi_hostadapter aic79xx
alias scsi_hostadapter1 megaraid
alias eth1 eepro100
alias usb-controller usb-ohci
alias scsi_hostadapter2 qla2300

 

而新驱动名字为megaraid_2002,修改/etc/modules.conf(RHEL3)或/etc/modprobe.conf(RHEL4)如下:

 



alias parport_lowlevel parport_pc
alias eth0 e1000
alias scsi_hostadapter aic79xx
alias scsi_hostadapter1 megaraid_2002
alias eth1 eepro100
alias usb-controller usb-ohci
alias scsi_hostadapter2 qla2300

 

修改文件以后,需要重新编译initrd文件,使得在启动时该模块被正确插入到模块中。

 



# cp /boot/initrd-(kernel-version).img /boot/initrd-(kernel-version).img.bak
# mkinitrd -f initrd-$(uname -r).img $(uname -r)

 

例如

 



cp /boot/initrd-2.4.21-27.0.2.ELsmp.img /boot/initrd-2.4.21-27.0.2.ELsmp.img.bak
mkinitrd -v -f /boot/initrd-2.4.21-27.0.2.ELsmp.img 2.4.21-27.0.2.ELsmp

 

这个例子对一个运行2.4.21-27.0.2smp内核的系统重建了initrd.img,根据自己系统的实际运行版本自行条成mkinitrd的参数(可以使用uname -r得到本机运行的内核版本号)。

 



   * mkinitrd的-v参数可以显示initrd.img中包括的所有模块。
   * mkinitrd的-f参数可以强制覆盖initrd.img中已有的同名模块。

 

操作完毕以后,需要重新启动内核使得该模块插入到系统中,然后使用下面命令来确认:

 



# lsmod
megaraid_2002          40128   7
scsi_mod              123884   4  [qla2300 megaraid_2002 aic79xx sd_mod]

 

Feedback from users like yourself is a critical factor in helping us make the Red Hat Knowledgebase as useful as possible.

More Like This

  • Retrieving data ...