Sunday, April 10, 2011

Load kernel modules at boot time on Redhat/Centos Linux.

In Centos 5, /etc/rc.d/rc.sysinit looking for two locations to load modules
# Load other user-defined modules
for file in /etc/sysconfig/modules/*.modules ; do
[ -x $file ] && $file
done
# Load modules (for backward compatibility with VARs)
if [ -f /etc/rc.modules ]; then
/etc/rc.modules
fi
As you can see, you can put load module commands in /etc/sysconfig/modules/*.modules  or /etc/rc.modules.
Putting in /etc/rc.local might not work, because rc.local is executed very late.
#e.g loading dummy network module "dummy"
echo "modprobe dummy" >/etc/sysconfig/modules/my.modules
chmod +x /etc/sysconfig/modules/my.modules
Understanding /etc/modprobe.conf
/etc/modprobe.conf is the configration file for modprobe command, it DOESN'T  load module itself.
#Increase dummy interfaces to 3 when "modprobe dummy" is called
#it is equivalent to specify the option in command line  "modprobe dummy numdummies=3"
$cat /etc/modprobe.conf
options dummy numdummies=3
##"install" command tells modprobe to run your command instead of inserting the module in the kernel as normal
##it can be used to disable particular module
##disable ipv6 module by changing normal install to a dummy command /bin/true
install ipv6 /bin/true
###NODE: If modprobe is invoked with "--ignore-install" option, the customized install command will be ignored

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.