Product SiteDocumentation Site

22.6. Persistent Module Loading

As shown in Example 22.1, “Listing information about a kernel module with lsmod”, many kernel modules are loaded automatically at boot time. You can specify additional modules to be loaded by creating a new <file_name>.modules file in the /etc/sysconfig/modules/ directory, where <file_name> is any descriptive name of your choice. Your <file_name>.modules files are treated by the system startup scripts as shell scripts, and as such should begin with an interpreter directive (also called a bang line) as their first line:
Example 22.4. First line of a file_name.modules file
#!/bin/sh

Additionally, the <file_name>.modules file should be executable. You can make it executable by running:
modules]# chmod +x <file_name>.modules
For example, the following bluez-uinput.modules script loads the uinput module:
Example 22.5. /etc/sysconfig/modules/bluez-uinput.modules
#!/bin/sh

if [ ! -c /dev/input/uinput ] ; then
        exec /sbin/modprobe uinput >/dev/null 2>&1
fi
The if-conditional statement on the third line ensures that the /dev/input/uinput file does not already exist (the ! symbol negates the condition), and, if that is the case, loads the uinput module by calling exec /sbin/modprobe uinput. Note that the uinput module creates the /dev/input/uinput file, so testing to see if that file exists serves as verification of whether the uinput module is loaded into the kernel.
The following >/dev/null 2>&1 clause at the end of that line simply redirects any output to /dev/null so that the modprobe command remains quiet.