Linux: How to load a kernel module automatically at boot time

by on September 14, 2006 · 18 comments· LAST UPDATED September 15, 2006


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:

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)

Tweet itFacebook itG+ itDownload PDF versionFound an error/typo on this page?

{ 18 comments… read them below or add one }

1 Balakumar September 8, 2009 at 9:55 am

Try this method to load module at boot time

#echo module_name >> /etc/rc.modules
#chmod +x /etc/rc.modules


2 Yacob Hassidim October 9, 2011 at 8:57 am

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?


3 Dave October 19, 2011 at 11:46 pm

/etc/modules is the file you’re looking for Yacob


4 Yacob Hassidim October 23, 2011 at 8:12 pm

Hello Dave,

Thank you.
I tried this file also but the modules are not loaded.
Do you have another idea?


5 SIFE November 3, 2011 at 10:04 pm

Try this:
echo “modprobe module_name” >> /etc/modprobe.d/modeprobe.conf


6 Steve November 18, 2011 at 11:36 am

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.


7 Bhargav Shah August 8, 2012 at 5:03 am

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.



8 redjupiter August 9, 2012 at 1:03 pm

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?



9 Bhargav Shah August 9, 2012 at 1:45 pm

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.


10 redjupiter August 9, 2012 at 2:11 pm

I figured that out.

add a line to /etc/modules for your module (without .ko)
copy the module file to /lib/modules/

sudo depmod -a
reboot and it worked for me on Ubuntu 12.04


11 redjupiter58 August 9, 2012 at 2:25 pm

error. copy the module file to /lib/modules/


12 Shantanu April 4, 2013 at 10:19 am

This solution worked for me too on 12.04 . Thanks redjupiter.


13 Bhargav Shah August 9, 2012 at 5:59 pm

Thanks redjupiter. It worked with ubuntu 11.04.


14 redjupiter August 10, 2012 at 9:04 am

Glad it worked. one correction for others:
copy the module file to /lib/modules/


15 Atul July 19, 2013 at 6:40 am

there is no /etc/modules…rather /etc/modprobe.conf is there…
please suggest


16 Steve July 23, 2013 at 10:16 am


quite often there is no need for a modprobe configuration file. As I said before (see previous remark from November, 2011), modprobe is not invoked by that configuration file. Its just that if you need to provide it with additional information, then that can be done from the configuration file. The name used for the configuration file has changed a bit between different versions, and sometimes it is given as a file in a directory, modprobe.d. On my workstation (built from scratch) there is no modprobe configuration file. Its not needed.

The critical thing usually is making the kernel aware of modules. To do this you have to put the module in the right place, and run depmod to update the module dependencies.

Perhaps if you explained what you were trying to do, then it would be possible to provide a more specific explanation.


17 mdk July 18, 2014 at 12:31 am

I would like to add that some systems have the modules file in /etc/sysconfig/modules


18 chirkoot March 27, 2015 at 3:20 pm

To load a module by filename (i.e. one that is not installed in /lib/modules/$(uname -r)/):
# insmod filename [args]

To unload a module:
# modprobe -r module_name

Or, alternatively:
# rmmod module_name

Check this link for more info on how to work with modules:


Leave a Comment

Tagged as:

Previous Faq:

Next Faq: