Q. How do I Load a Linux kernel module automatically at boot time so that my hardware is automatically recognized during system boot sequence?
A. Linux kernel follows modular kernel design. Loadable Kernel Modules (LKM) are object files that contain code to extend the running kernel, or so-called base kernel. LKM's are typically used to add support for new hardware, filesystems etc.
Loading a kernel module is an essential task. File /etc/modules.conf (or /etc/modules - see a note below for more info) is configuration file for loading kernel modules.
The configuration file consists of a set of lines. All empty lines, and all text on a line after a '#', will be ignored.
This file is used - if new hardware is added after installation and the hardware requires a kernel module, the system must be configured to load the proper kernel module for the new hardware.
For example, if a system included an IDE CD-ROM, the module configuration file contains the following 3 lines:
# vi /etc/modules.conf
Append following lines:
ide-cd
ide-core
cdrom
Save and close the file. Reboot the system.
NOTE: If you are using Debian Linux or Ubuntu Linux use file /etc/modules file instead of /etc/modules.conf (which works on Red Hat/Fedora core/Cent OS etc)
Featured Articles:
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- My 10 UNIX Command Line Mistakes
- Linux: 20 Iptables Examples For New SysAdmins

- 25 PHP Security Best Practices For Sys Admins
- The Novice Guide To Buying A Linux Laptop
- 10 Greatest Open Source Software Of 2009
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- Top 20 OpenSSH Server Best Security Practices
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Linux Video Editor Software
Facebook it - Tweet it - Print it -

{ 6 comments… read them below or add one }
Try this method to load module at boot time
#echo module_name >> /etc/rc.modules
#chmod +x /etc/rc.modules
Hello,
I use Ubuntu 11.4 (Linux 2.6.38)
I tried both the files modules.conf and rc.modules.
Unfortunately the modules is not loaded.
Do you have any idea?
Thanks,
Yacob.
/etc/modules is the file you’re looking for Yacob
Hello Dave,
Thank you.
I tried this file also but the modules are not loaded.
Do you have another idea?
Thanks,
Yacob.
Try this:
echo “modprobe module_name” >> /etc/modprobe.d/modeprobe.conf
My understanding is that modprobe.conf and modules.conf are only configuration files. They do not invoke modprobe. All they do is provide modprobe with information about what it should do when it is invoked.
Scripts that are run immediately after the boot (in the start up sequence) are called rc scripts. Many systems have a script called rc.local. This script is arranged in such a way (normally with symlinks) that it is executed as the last script in the start up sequence. This is a good place to put additional commands that are required and which have not been invoked already. The normal location of this script is /etc/rc.d/rc.local.
Therefore if the modprobe command is added to that script it will be executed at the end, and before a login shell prompt is provided. Determine the location of modprobe. If, for example, it is /sbin/modprobe, then the end of the rc.local file should look something like this:
# Put your required modprobe command here:
/sbin/modprobe name-of-module
Note that if the module in question requires options, then a place to put these is in /etc/modprobe.conf, because when modprobe runs it will read that configuration file and pick up any required options from there.