The Linux kernel is a core component of the Linux operating system. It manages system resources, and is a bridge between your computer hardware and software.
The Linux kernel has a modular design. The kernel module, or often referred to as a driver, is a piece of code that extends kernel functionality. Modules are compiled as modules that can be loaded or built into the kernel. Modules that can be loaded can be loaded and unloaded in the currently running kernel on request, without the need to reboot the system.
In general, the module is loaded upon request by Udev (device manager). However, sometimes you might need to adjust how the module is loaded. For example, you might need to load modules with additional parameters or to prevent modules from automatically loading.
You can manually load modules into the kernel using the modprobe command, or automatically at boot time using / etc / modules or /etc/modules-load.d/*.conf file.
In this article, we will explain how to use modules to add and remove modules from the Linux kernel. modprobe is part of kmod, a binary that implements many programs that are used to manage Linux Kernel modules.
Add a Kernel Module
Kernel modules are stored in the / lib / modules / <kernel_version> directory. You find the kernel version running, use the uname -r command.
Only users with administrative rights can manage the Kernel module.
To load a module, activate the modprobe command followed by the module name:
The modprobe command will load the given module and any additional module dependencies. Only one module can be specified on the command line.
Use the lsmod command to confirm that the module is loaded:
lsmod | grep module_name
To load modules with additional parameters, use the syntax parameter = value syntax :
modprobe module_name parameter=value
The command accepts several parameters = value pairs separated by spaces.
In general, you need to load the module during system boot. You can do this by specifying the module and its parameters in a file in the /etc/modules-load.d directory. The file must end with .conf and can have any name:
option module_name parameter=value
The settings specified in these files are read by Udev, which loads the module at system startup using Modprobe.
Remove the Kernel Module
To delete a module, activate the modprobe command with the -r option followed by the module name:
modprobe -r module_name
modprobe will also remove module dependencies that are not used.
When called with -r, the command accepts several modules as arguments:
modprobe -r module_name1 module_name2
If you want to prevent the Kernel module from loading at boot, create a .conf file with any name in /etc/modprobe.d. The syntax is:
If you want to blacklist additional modules, specify modules on a new line, or create a new .conf file.
The modprobe command allows you to add and remove Linux kernel modules.
Feel free to leave a comment if you have questions.