How to load a kernel module at boot time on Linux

Last updated on February 24, 2012 by Dan Nanni

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, I assume that loop is the name of the kernel module that needs to be loaded upon boot.

Load a Kernel Module at Boot Time on Ubuntu or Debian

You can specify the module in /etc/modules.

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

Load a Kernel Module at Boot Time on CentOS, RHEL or Fedora

You can specify the module loading command in /etc/rc.modules.

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

Now the module loop will be loaded permanently across reboots.

Support Xmodulo

This website is made possible by minimal ads and your gracious donation via PayPal or credit card

Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.

Xmodulo © 2021 ‒ AboutWrite for UsFeed ‒ Powered by DigitalOcean