To automatically load kernel modules in CentOS, you need to add a script in the/etc/sysconfig/modules/directory to load the required modules in this script.
Here is a script called 8021q.modules that I used to automatically load the 802.1Q module in my CentOS 5.3:
#! /bin/sh/sbin/modinfo-f filename 8021q >/dev/null 2>&1if [$?-eq 0]; Then
The above script first checks to see if the 8021q module file exists and, if present, calls the /sbin/modprobe command to load the module.
Put this file in the /etc/sysconfig/modules/directory and add executable permissions to it. This way, the 802.1Q module will be loaded automatically the next time the system is restarted.
Some articles on the web suggest adding the modprobe command in the/etc/rc.local file, which may not work properly in some cases. Because/etc/rc.local executes the program in the RC.D directory at startup,if a program in RC.D uses the module it needs to load, an error occurs.
In addition, some articles refer to modifying the/etc/modprobe.conf file, which is actually wrong. This file simply defines the aliases of some kernel modules, as well as some special loading and unloading commands. Modifying this file does not allow the module to be loaded automatically at startup.
Automatic loading of 802.1q modules in CentOS