How to load a kernel module at boot time

Loadable kernel modules are a convenient way to modify the running kernel without rebuilding the kernel from scratch. You can also free up memory resources by unloading any unnecessary kernel module.

A kernel module can be loaded or unloaded on the fly by modprobe command. When loading a kernel module with modprobe, the command will also load any prerequisite module(s) automatically. Likewise, modprobe removes a kernel module along with any dependent module(s) that are no longer used.

Any kernel modules that are manually loaded by modprobe will not remain in the kernel after rebooting. If you would like to load a specific kernel module automatically upon reboot, you can follow this instruction. In this example, "loop" is the name of the kernel module that I would like to load permanently.

On Debian/Ubuntu systems:

$ sudo echo "loop" >> /etc/modules

CentOS/Redhat/Fedora systems:

$ sudo echo "modprobe loop" >> /etc/rc.modules
$ sudo chmod +x /etc/rc.modules

Now the module "loop" will be loaded persistently across reboots.

Subscribe to Xmodulo

Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.

The following two tabs change content below.
Dan Nanni is the founder and also a regular contributor of Xmodulo.com. He is a Linux/FOSS enthusiast who loves to get his hands dirty with his Linux box. He likes to procrastinate when he is supposed to be busy and productive. When he is otherwise free, he likes to watch movies and shop for the coolest gadgets.

Leave a comment

Your email address will not be published. Required fields are marked *

Current ye@r *