Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

How do I find out which kernel module (as seen by typing lsmod) is servicing a particular device in /dev ?

In other words, say I have a device, /dev/mouse0 and I want to find out which kernel module is installed to service that device. How do I do that?

Another way to look at this is, some loaded kernel modules associate themselves with a device in /dev. How does one find out which device(s) a module is "attached" to?

share|improve this question
    
It's better to talk about kernel driver rather than kernel module, as a kernel driver can be built both built-in and as a module, but that doesn't affect which driver drives a device. –  Diego Nov 7 '13 at 11:55

2 Answers 2

up vote 8 down vote accepted

You can usually find this information by digging through /sys if you're on a 2.6 kernel.

e.g.

$ ls -la /dev/input/mouse1   
crw-r----- 1 root root 13, 33 2010-03-08 15:56 /dev/input/mouse1
$ ls -la /sys/class/input/mouse1/device/driver 
lrwxrwxrwx 1 root root 0 2010-05-12 23:33 /sys/class/input/mouse1/device/driver -> ../../../../../../bus/usb/drivers/usbhid

So the driver in this case is usbhid. There might be a better/neater way of doing this but I find digging in sysfs usually gets the job done.

share|improve this answer

not sure if this will help finding the module (though it should) but you can use lsof to see what is accessing the particular device file. lsof /dev/mouse0 for example, though you can do more with the commandline options to lsof

more examples of how to use lsof http://wikis.sun.com/pages/viewpage.action?pageId=49906332

share|improve this answer
1  
lsof won't show you the name of the module. lsof only shows which userspace programs have the device node open. –  James May 12 '10 at 22:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.