Product SiteDocumentation Site

23.4. Unloading a Module

You can unload a kernel module by running modprobe -r module_name as root. For example, assuming that the wacom module is already loaded into the kernel, you can unload it by running:
~]# modprobe -r wacom
However, this command will fail if a process is using:
See Section 23.1, “Listing Currently-Loaded Modules” for more information about using lsmod to obtain the names of the modules which are preventing you from unloading a certain module.
Example 23.4. Unloading a kernel module
For example, if you want to unload the firewire_ohci module, your terminal session might look similar to this:
~]# modinfo -F depends firewire_ohci
firewire-core
~]# modinfo -F depends firewire_core
crc-itu-t
~]# modinfo -F depends crc-itu-t

You have figured out the dependency tree (which does not branch in this example) for the loaded Firewire modules: firewire_ohci depends on firewire_core, which itself depends on crc-itu-t.
You can unload firewire_ohci using the modprobe -v -r module_name command, where -r is short for --remove and -v for --verbose:
~]# modprobe -r -v firewire_ohci
rmmod firewire_ohci
rmmod firewire_core
rmmod crc_itu_t
The output shows that modules are unloaded in the reverse order that they are loaded, given that no processes depend on any of the modules being unloaded.

Do not use rmmod directly!

Although the rmmod command can be used to unload kernel modules, it is recommended to use modprobe -r instead.