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)
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop













{ 14 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.
Hi all,
i am new buddy to Linux module programming.I am facing same problem in loading a module at boot time in Ubuntu 11.04. Can any one tell me the perfect steps to load the module at the boot time.
Thanks.
same problem here. I did change /etc/modules, but where do I put the module object itself so moprob can find it?
To put the question in another way, what are the default lcoation that modprobe look for modules?
thanks
i i tried to put the .KO file with the all drivers .KO file.But that doesn’t worked.
The other way to do this is configuring the Kconfig file and recompile the kernel.
But i am not getting proper documentation.
I figured that out.
add a line to /etc/modules for your module (without .ko)
copy the module file to /lib/modules/
do
sudo depmod -a
reboot and it worked for me on Ubuntu 12.04
error. copy the module file to /lib/modules/
This solution worked for me too on 12.04 . Thanks redjupiter.
Thanks redjupiter. It worked with ubuntu 11.04.
Glad it worked. one correction for others:
copy the module file to /lib/modules/