Rmmod Command in Linux


Omer Cakmak

CheatSheet

The most basic component of Linux operating systems is the Linux kernel. It manages the system's resources and acts as an intermediary between the computer's hardware and software.
The Linux kernel is software with a modular design. Modules can be compiled/embedded as loadable modules. They can be dynamically installed and removed from the running kernel without the need to reboot the system.

In this article, we will provide information on how to use the rmmod command to remove modules from the Linux Kernel.

 

rmmod command Overview

The rmmod command is used to remove a module from the linux kernel. Most of the users still use modprobe with -r option instead of using rmmod.

To remove a module from the system, you need to know which module will be removed. And of course the module must be installed in the system. To remove a module from the system, you need to know which module will be removed. And of course the module must be installed in the system:

[foc@rocky9 ~]$ lsmod
Module                  Size  Used by
tls                   110592  0
nft_fib_inet           16384  1
ip_set                 61440  0
fuse                  172032  1
xfs                  1982464  2
libcrc32c              16384  4 nf_conntrack,nf_nat,nf_tables,xfs
sr_mod                 28672  0
cdrom                  81920  1 sr_mod
sg                     40960  0
crc32c_intel           24576  1
ahci                   40960  0
libahci                45056  1 ahci
libata                299008  2 libahci,ahci
ghash_clmulni_intel    16384  0
serio_raw              20480  0
virtio_blk             20480  3
virtio_net             65536  0
virtio_console         40960  0
...

You can use the following command to get information about the module you want to remove:

[foc@rocky9 ~]$ modinfo fuse
filename:       /lib/modules/5.14.0-70.22.1.el9_0.x86_64/kernel/fs/fuse/fuse.ko.xz
alias:          devname:fuse
alias:          char-major-10-229
alias:          fs-fuseblk
alias:          fs-fuse
license:        GPL
description:    Filesystem in Userspace
author:         Miklos Szeredi <miklos@szeredi.hu>
alias:          fs-fusectl
rhelversion:    9.0
srcversion:     C941195B228AD648313EEA7
...

 

How to remove module with rmmod?

The use of the RMMOD command is as follows:

rmmod [options] module_name1 module_name2...

Modules to be removed can be written in succession. You may be trying to Remove a module used:

[foc@rocky9 ~]$ sudo rmmod fuse
rmmod: ERROR: Module fuse is in use

However, if you are determined to remove the module from the system, add the -f parameter:

[foc@rocky9 ~]$ sudo rmmod -f fuse

Check the removed module:

[foc@rocky9 ~]$ lsmod | grep fuse

If you cannot see among the installed modules, the removal process is successful.

Another method to remove the module:

[foc@rocky9]$ sudo rmmod /lib/modules/5.14.0-70.22.1.el9_0.x86_64/kernel/fs/fuse/fuse.ko.xz

The directory where the module is installed is written after the rmmod command. In this way, the module is removed from the system.

 

Prevent Module From Loading Permanently

When a module is removed using rmmod command, the module is loaded in the system boot when the system is restarted.

To permanently disable the module from loading during boot, you can create a file under /etc/modprobe.d directory to permanently disable the installation of this core module, and this module is put into the blacklist. For example:

[foc@rocky9 ~]$ sudo vi /etc/modprobe.d/module_blacklist.conf
blacklist fuse

This module will no longer be loaded when the system starts again. When the system starts, you can control the module with the following command:

[foc@rocky9 ~]$ lsmod | grep fuse

 

Summary

In this article, we gave information about removing module with rmmod. For more details, you can get information from the rmmod manual page:

foc@fedora:/tmp$ man rmmod

rmmod

We talked about the lsmod and modinfo commands. Below we leave information about the commands you may need together with rmmod:

  • Depmod: Generate a list of kernel module dependencies and associated map files.
  • Insmod:  Insert a module into the Linux kernel.
  • Modprobe: Add and remove modules from the Linux kernel.

 

References

linux.die.net/ - rmmod
askubuntu.com - How to unload a kernel module

 

Views: 28

Omer Cakmak

He is highly skilled at managing Debian, Ubuntu, CentOS, Oracle Linux, and Red Hat servers. Proficient in bash scripting, Ansible, and AWX central server management, he handles server operations on OpenStack, KVM, Proxmox, and VMware. You can connect with him on LinkedIn or check his projects on GitHub page.

Can't find what you're searching for? Let us assist you.

Enter your query below, and we'll provide instant results tailored to your needs.

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can send mail to admin@golinuxcloud.com

Thank You for your support!!

Leave a Comment

GoLinuxCloud Logo


We try to offer easy-to-follow guides and tips on various topics such as Linux, Cloud Computing, Programming Languages, Ethical Hacking and much more.

Programming Languages

JavaScript

Python

Golang

Node.js

Java

Laravel