- Howto: Linux Add or Remove a Linux Kernel Modules / Drivers
- Task: Add a Module (driver) Called foo
- Find out info about loaded module
- Task: List all loaded modules
- Task: Remove a module called foo
- How to Load and Unload Kernel Modules in Linux
- List All Loaded Kernel Modules in Linux
- How to Load and Unload (Remove) Kernel Modules in Linux
- How to Manage Kernel Modules Using modprobe Command
- If You Appreciate What We Do Here On TecMint, You Should Consider:
- Linux modprobe Command Examples to View, Install, Remove Modules
- 1. List Available Kernel Modules
- 2. List Currently Loaded Modules
- 3. Install New modules into Linux Kernel
- 4. Load New Modules with the Different Name to Avoid Conflicts
- 5. Remove the Currently Loaded Module
Howto: Linux Add or Remove a Linux Kernel Modules / Drivers
=> Under MS-Windows you use term device driver for modules.
=> Under Linux you use term modules for device drivers.
Tutorial details | |
---|---|
Difficulty level | Advanced |
Root privileges | Yes |
Requirements | modprobe/lsmod/modinfo utilities |
Est. reading time | N/A |
=> The Linux kernel has a modular design.
=> At boot time, only a minimal resident kernel is loaded into memory.
=> If you add new hardware you need to add driver i.e. modules.
- No ads and tracking
- In-depth guides for developers and sysadmins at Opensourceflare✨
- Join my Patreon to support independent content creators and start reading latest guides:
- How to set up Redis sentinel cluster on Ubuntu or Debian Linux
- How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
- How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
- A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
- How to protect Linux against rogue USB devices using USBGuard
Join Patreon ➔
=> The modprobe command intelligently adds or removes a module from the Linux kernel
=> Usually, all Linux kernel modules (drivers) are stored in the module directory located that /lib/modules/$(uname -r) directory. To see current modules, type:
$ ls /lib/modules/$(uname -r)
Output:
Use the following command to list all drivers for various devices:
$ ls /lib/modules/$(uname -r)/kernel/drivers/
Sample outputs:
Fig.01: Device drivers on my Linux based system
Task: Add a Module (driver) Called foo
Type the following command as root user:
# modprobe foo
In this example, I am loading a module called i8k, enter:
# modprobe -v i8k
Sample outputs:
Find out info about loaded module
You need to use the modinfo command to see information about a Linux Kernel module. The syntax is:
# modinfo -v
# modinfo i8k
Sample outputs:
Fig.02: Displaying information about a Linux Kernel module called i8k
Task: List all loaded modules
Use the lsmod command to show the status of modules in the Linux Kernel:
# lsmod
Sample outputs:
Task: Remove a module called foo
Pass the -r option to modprobe command to remove a module, type:
# modprobe -r foo
You can also use the rmmod command, which is simple program to remove a module from the Linux Kernel:
# rmmod foo
Recommended readings
- man pages – modinfo, lsmod, insmod, and modprobe
🐧 Get the latest tutorials on Linux, Open Source & DevOps via
Category | List of Unix and Linux commands |
---|---|
Documentation | help • mandb • man • pinfo |
Disk space analyzers | df • duf • ncdu • pydf |
File Management | cat • cp • less • mkdir • more • tree |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Linux Desktop Apps | Skype • Spotify • VLC 3 |
Modern utilities | bat • exa |
Network Utilities | NetHogs • dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • glances • gtop • jobs • killall • kill • pidof • pstree • pwdx • time • vtop |
Searching | ag • grep • whereis • which |
Shell builtins | compgen • echo • printf |
Text processing | cut • rev |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Comments on this entry are closed.
when the system is rebooted the module inside the kernel will not be present.But i want the modules to be seen permenently.what should i do.
Thanks alot for this, very helpful for teh newbz.
Thank’s first for the helpfull command , where can i get the new modules other then my OS,
how to build linux kernel module with new device driver module during build
Thanks a lot for the info…:) 🙂
Hi there…
I am trying to remove TCP IP from a linux kernel, and want to recompile the LINUX kernel. But being a novice with the administrations of the linux (UBUNTU 10.4), I know a little about it. Agter recompilation can I again design mu own TCPIP using the C language code?
Guys please help me out…waiting for the reply .
Regards…
Thanks for this very short but very clear information. That helps me to understand the concept (of add or remove module on Linux) very much.
One question remain: how do we check to know what modules are available to add on a existing system?
Thank you in advance!
One question remain: how do we check to know what modules are available to add on a existing system?
cd to /lib/modules/$(uname -r) directory and you can see the list of available modules (run as root):
The following will list all drives
To find out more info about a module called foo:
Hope this helps!
Hi
thanks for your comments, I am trying to write a printer driver for linux, what should I do?
Please help me on this task.
Does anyone knows step by step guide for how to install ip_conntrack support into kernel Linux linux 2.6.35.14-106.fc14.i686 #1 SMP Wed Nov 23 13:57:33 UTC 2011 i686 i686 i386 GNU/Linux
I am unable to remove the following modules after issuing the commands.
$ rmmod usbhid and
$rmmod hid..
After issuing the commands the modules are not shown in “lsmod” but as soon as a device is added they again get loaded.
thanks, very clear article.
Hello there. I have an old computer Celeron, 128MB RAM and 28MB of VGA. What I want to do is keep the drivers that are needed for my system. Like if I use the Realtek Chipset for Network Card why should the Atheros driver be present on the system? Is there any way to accomplish this task?
Regards.
I have a serious problem, my Linux does not have these comands:
apt-get
uname
modprobe
mknod
man
…etc… and also has not a lot of typical commands
And there is no /dev/loop*
And mount -o loop blablabla bleble say incorrect option, does not undertand loop.
Of course, all problem seem that Kernel has no loop device support.
How can i fix it?
Please have in mind Kernel is on ROM (a chip not writteable), it is not a flasheable chip, i can not modify it on any way, … read only memory chip!!
I wish if it could be possible to add loop device support at run time as a module…
But it does not have modprobe command… neither a lot of clasic Linux commands… so i got to fail.
Need some help, i am not an expert.
Step 1: try to create /dev/loop0 (it does not exists) with mknod but mknod command not found
Try to add such coomands with apt-get, wget, etc… all says such commands not exists
I am getting mad…
Please note it is an ARM processor based, and Kernel is on a ReadOnly chip not flashable.
Thanks in advance for any help… i am getting really mad…
If I were you, rather than finding Linux Kernel modulos to have “uname”, “modprobe”, “man” recovered (maybe you have played around some kernel rebuild and screwed up some basic binaries?), I will re-install the entire Linux OS from scratch. You can download CentOS (Red Hat) or SUSE, Fedora or whatever Linux to have all these basic utilities included.
trying to add slcan module to kernel 2.6.32-504.30.3.el6.i686 but having problems with the following response … question is how to get it added
FATAL: Module slcan not found.
Thank you so much…
i want to know how many mouldes in linus and brief explanation of them.i will glad if my question is been answered.
hi all,
iam unable to remove nvme module in primary drive(ssd) by using
following comment:
rmmod nvme
Источник
How to Load and Unload Kernel Modules in Linux
A kernel module is a program which can loaded into or unloaded from the kernel upon demand, without necessarily recompiling it (the kernel) or rebooting the system, and is intended to enhance the functionality of the kernel.
In general software terms, modules are more or less like plugins to a software such as WordPress. Plugins provide means to extend software functionality, without them, developers would have to build a single massive software with all functionalities integrated in a package. If new functionalities are needed, they would have to be added in new versions of a software.
Likewise without modules, the kernel would have to be built with all functionalities integrated directly into the kernel image. This would mean having bigger kernels, and system administrators would need to recompile the kernel every time a new functionality is needed.
A simple example of a module is a device driver – which enables the kernel to access a hardware component/device connected to the system.
List All Loaded Kernel Modules in Linux
In Linux, all modules end with the .ko extension, and they are normally loaded automatically as the hardware is detected at system boot. However a system administrator can manage the modules using certain commands.
To list all currently loaded modules in Linux, we can use the lsmod (list modules) command which reads the contents of /proc/modules like this.
How to Load and Unload (Remove) Kernel Modules in Linux
To load a kernel module, we can use the insmod (insert module) command. Here, we have to specify the full path of the module. The command below will insert the speedstep-lib.ko module.
To unload a kernel module, we use the rmmod (remove module) command. The following example will unload or remove the speedstep-lib.ko module.
How to Manage Kernel Modules Using modprobe Command
modprobe is an intelligent command for listing, inserting as well as removing modules from the kernel. It searches in the module directory /lib/modules/$(uname -r) for all the modules and related files, but excludes alternative configuration files in the /etc/modprobe.d directory.
Here, you don’t need the absolute path of a module; this is the advantage of using modprobe over the previous commands.
To insert a module, simply provide its name as follows.
To remove a module, use the -r flag like this.
Note: Under modprobe, automatic underscore conversion is performed, so there is no difference between _ and – while entering module names.
For more usage info and options, read through the modprobe man page.
Do not forget to check out:
That’s all for now! Do you have any useful ideas, that you wanted us to add to this guide or queries, use the feedback form below to drop them to us.
If You Appreciate What We Do Here On TecMint, You Should Consider:
TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
We are thankful for your never ending support.
Источник
Linux modprobe Command Examples to View, Install, Remove Modules
modprobe utility is used to add loadable modules to the Linux kernel. You can also view and remove modules using modprobe command.
Linux maintains /lib/modules/$(uname-r) directory for modules and its configuration files (except /etc/modprobe.conf and /etc/modprobe.d).
In Linux kernel 2.6, the .ko modules are used instead of .o files since that has additional information that the kernel uses to load the modules. The example in this article are done with using modprobe on Ubuntu.
1. List Available Kernel Modules
modprobe -l will display all available modules as shown below.
2. List Currently Loaded Modules
While the above modprobe command shows all available modules, lsmod command will display all modules that are currently loaded in the Linux kernel.
3. Install New modules into Linux Kernel
In order to insert a new module into the kernel, execute the modprobe command with the module name.
Following example loads vmhgfs module to Linux kernel on Ubuntu.
Once a module is loaded, verify it using lsmod command as shown below.
The module files are with .ko extension. If you like to know the full file location of a specific Linux kernel module, use modprobe command and do a grep of the module name as shown below.
Note: You can also use insmod for installing new modules into the Linux kernel.
4. Load New Modules with the Different Name to Avoid Conflicts
Consider, in some cases you are supposed to load a new module but with the same module name another module got already loaded for different purposes.
If for some strange reasons, the module name you are trying to load into the kernel is getting used (with the same name) by a different module, then you can load the new module using a different name.
To load a module with a different name, use the modprobe option -o as shown below.
5. Remove the Currently Loaded Module
If you’ve loaded a module to Linux kernel for some testing purpose, you might want to unload (remove) it from the kernel.
Use modprobe -r option to unload a module from the kernel as shown below.
Источник