Is there a way to figure out what is using a Linux kernel module?

前端 未结 7 899
無奈伤痛
無奈伤痛 2020-12-12 12:40

If I load a kernel module and list the loaded modules with lsmod, I can get the \"use count\" of the module (number of other modules with a reference to the mod

7条回答
  •  生来不讨喜
    2020-12-12 12:54

    If you use rmmod WITHOUT the --force option, it will tell you what is using a module. Example:

    $ lsmod | grep firewire
    firewire_ohci          24695  0 
    firewire_core          50151  1 firewire_ohci
    crc_itu_t               1717  1 firewire_core
    
    $ sudo modprobe -r firewire-core
    FATAL: Module firewire_core is in use.
    
    $ sudo rmmod firewire_core
    ERROR: Module firewire_core is in use by firewire_ohci
    
    $ sudo modprobe -r firewire-ohci
    $ sudo modprobe -r firewire-core
    $ lsmod | grep firewire
    $
    

提交回复
热议问题