Modprobe Command in Linux | Linuxize

[ad_1]

The Linux kernel is the core component of the Linux operating system. It manages the system’s resources and it is a bridge between your computer’s hardware and software.

The Linux kernel has a modular design. A kernel module, or often referred to as a driver, is a piece of code that extends the kernel’s functionality. 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 (device manager). However, sometimes you may need to fine-tune how the modules are loaded. For example, you may need to load a module with additional parameters or to prevent the automatic loading of a module.

You can manually load a module into the kernel using the modprobe command, or automatically at boot time using /etc/modules or /etc/modules-load.d/*.conf files.

In this article, we’ll explain how to use modprobe to add and remove modules from the Linux kernel. modprobe is part of kmod, a binary that implements multiple programs used to manage Linux Kernel modules.

Adding Kernel Modules #

The Kernel modules are stored in the /lib/modules/<kernel_version> directory. You find the version of the running kernel
, use the uname -r
command.

Only users with administrative privileged can manage Kernel modules.

To load a module, invoke the modprobe command followed by the module name:

modprobe module_name

The modprobe command will load the given module and any additional module dependencies. Only one module can be specified at the command line.

Use the lsmod
command to confirm that the module is loaded:

lsmod | grep module_name

To load a module with additional parameters, use the parameter=value syntax:

modprobe module_name parameter=value

The command accepts multiple parameter=value pairs separated by space.

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:

/etc/modules-load.d/module_name.conf

option module_name parameter=value

The settings specified in these files are read by udev, which loads the modules at system startup using modprobe.

Removing Kernel Modules #

To remove a module, invoke the modprobe command with the -r option followed by the module name:

modprobe -r module_name

modprobe will also remove the unused module dependencies.

modprobe -r module_name1 module_name2
You can also use the rmmod
command to unload a module from the Linux Kernel.

If you want 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:

/etc/modprobe.d/blacklist.conf

If you want to blacklist additional modules, specify the modules on a new line, or create a new .conf file.

Conclusion #

The modprobe command allows you to add and remove Linux kernel modules.

Feel free to leave a comment if you have any questions.

[ad_2]

Source link

Related Posts

Leave a Reply

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

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.