The Linux kernel is managing the computer resources and work as the bridge between your computer’s hardware and software. It is the core component in the Linux operating system. The Linux kernel has a modular design and need to add and remove modules. In this article, we’ll explain how to use modprobe to add and remove modules from the Linux kernel.
Kernel modules are either compiled as loadable modules or built into the kernel. Loadable modules can be loaded and unloaded in the running kernel on request, without the need to reboot the system. Generally, the modules are loaded on demand by
udev. You can manually load a module into the kernel using the
modprobe command, or automatically at boot time using
Add Kernel Modules
The Kernel modules are located in the
/lib/modules/ directory. Find the version of running kernel using the
uname -r command.
Run the following
modprobe command followed by module name to load:
modprobe command will load the given module and any additional module dependencies. Only one module can be specified at the command line.
You can confirm module by using lsmod command:
lsmod | grep MODULE_NAME
To load a module with additional parameters, use the
modprobe MODULE_NAME parameter=value
You can pass the multiple
parameter=value pairs separated by space with
Generally, you would need to load the module during the system boot. You can do that by that by specifying the module and its parameters in a file inside the
/etc/modules-load.d directory. Files must end with
.conf and can have any name:
Commonly, it’s require to load the modules at the time of system boot. You can specify the module and its parameter in a file at
/etc/modules-load.d directory with name like
option MODULE_NAME parameter=value
udev (device manager) will read the settings and which loads the modules at system startup using
Remove Kernel Modules
It is very simple to remove the module. Run the
modprobe command with
-r option followed by the module name:
modprobe -r module_name
It will also remove the unused module dependencies.
You can also remove multiple modules in a single command by specifying multiple modules as arguments:
modprobe -r module_name1 module_name2
To prevent a Kernel module from loading at boot time, create a
.conf file with any name inside the
/etc/modprobe.d. The syntax is:
If you want to blacklist additional modules, specify the modules on a new line, or create a new
modprobe command is used to add and remove the Linux kernel modules on Linux systems.
If you have any questions or feedback, feel free leave a comment below.