11

I would like to temporarily (until next boot) disable a kernel module.

How can I do this?

2

2 Answers 2

10

Use lsmod to find the name of a kernel module about that you are interested in temporarily disabling. After you've found the name, use this command to disable the module:

sudo modprobe -r <module_name>

However, this command will fail with an error message something like FATAL: Module <module_name> is in use if a process is using:

  • the <module_name>
  • a module about that <module_name> directly depends on
  • any module about that <module_name> - through the dependency tree - depends on indirectly.

You can use lsmod | grep <module_name> to obtain the names of the modules which are preventing you from temporarily disabling a certain module (these module names are listed in the last column).

More about:

2
  • 1
    This doesn't however, disable or 'remove' buildin modules, which will give an FATAL: Module g_serial is builtin. error.
    – Tim Visee
    Jun 16, 2015 at 13:12
  • Your answer doesn't explain how to remove modules that are in use? What needs to be done after running the lsmod command?
    – Raleigh L.
    Jan 12 at 21:38
4

It appears:

sudo modprobe -r moduleName

Achieves what I want. The module is removed and reloaded upon reboot.

2
  • 1
    however, the module is reloaded if Linux thinks it's needed. This may or may not be what you want. Jun 20, 2016 at 9:23
  • In my case it's not what I want. I want to add the module to the blocklist temporarily
    – xdevs23
    Jun 10, 2023 at 22:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .