Linux – How to properly reload a kernel module

kernel-moduleslinuxthinkpad

Related Question

I can't reload a kernel module for trying new flags.
Example: thinkpad_acpi default is without fan_control=1. So if my computer runs really hot and the fans don't go to full speed it might sometimes be usable to just temporary load the module with fan_control and set the fan for a several minutes to the highest possible speed and change everything back to normal afterwords.
This isn't possible because it seems that some kernel modules depend to others and it seems that modern Linux kernels are checking that.
So what did I do so far:

  • Checking the dependencies
    • modinfo -F depends thinkpad_acpi
  • Try to unload these modules
    • rmmod or modprobe -r $dependencies
    • Some modules depend again to others, try to unload them too. Doesn't work, even if there are no 'dependencies' (or at least modinfo tells me that)
  • Google a lot for modprobe: FATAL: Module x is in use.
  • Reading tldp

Best Answer

If force unload is enabled in the kernel (zgrep FORCE_UNLOAD /proc/config.gz says =y), you can rmmod -f the problematic kernel module, to force unload it.

According to the patch that enables this, this is only for kernel developers and desperate people.

The best is probably to figure out why the module is in use, and by which process, but at least force unloading should make it possible to reload the module again.

Related Question