When I try to rmmod a module I get the error message "Error: Module in use" , lsmod | grep <module name>
shows the count.
Is there a way that would tell me which processes are using this particular kernel module/driver?
Asked
Active
Viewed 3.7k times
29

Vadim Kotov
- 8,084
- 8
- 48
- 62

Raj
- 379
- 2
- 5
- 14
-
possible duplicate of [Is there a way to figure out what is using a Linux kernel module?](http://stackoverflow.com/questions/448999/is-there-a-way-to-figure-out-what-is-using-a-linux-kernel-module) – J-16 SDiZ Jan 27 '12 at 06:27
2 Answers
11
lsof /dev/ might help you to find the dependent process.

Kiran Padwal
- 135
- 1
- 4
-
This worked for me. `lsof /dev/nvidia`, for example. I could see the processes and kill those, then `rmmod nvidia`. – crimson-egret Jun 10 '21 at 16:44
8
This was asked before, but there was no great answer, probably because there is no good way to accomplish to find what is using what.
The best suggestion is to dmesg
and look for any indication of what loaded the module.
You might also try using the --force
parameter to rmmod
in case your kernel was built with support for it.
-
3Note that using `rmmod --force` may leave the system in an undefined state, especially if the module is actually used. I would not recommend using that except as a last resort only. – Eugene Jan 28 '12 at 09:02
-
4In addition to `dmesg`, `lsof` ("list open files") command mentioned in the [answer](http://stackoverflow.com/a/449179/689077) to the mentioned question could still be helpful in some cases. Especially when dealing with filesystem modules and modules that have created character devices, etc. It may help find out which process has opened the files serviced by the module and keeps them open. – Eugene Jan 28 '12 at 09:06