Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

From the documentation of Linux kernel 3.2 (Documentation/kbuild/modules.txt)

=== 5. Module Installation

Modules which are included in the kernel are installed in the
directory:

    /lib/modules/$(KERNELRELEASE)/kernel/

And external modules are installed in:

    /lib/modules/$(KERNELRELEASE)/extra/

This implies that if I look into /lib/modules/$(KERNELRELEASE)/extra/ I can find all installed external kernel modules. However, I find that the official Nvidia display driver installs nvidia.ko into /lib/modules/$(KERNELRELEASE)/kernel/drivers/video/. This contradicts the above rule and suggests that the path is not a reliable indicator of included/external modules.

How to get a list of external kernel modules installed? If the distro matters, I'd like to know the answer for RHEL 6 and Ubuntu 10.04.

share|improve this question
add comment

1 Answer

For Debian/Ubuntu, something like

dpkg -S *.ko | grep /lib/modules | grep -v linux-image

should work. Disclaimer: I'm illiterate when it comes to pattern matching, so there are probably better ways of doing this. On my system, I get

nvidia-kernel-2.6.32-5-vserver-686-bigmem: /lib/modules/2.6.32-5-vserver-686-bigmem/nvidia/nvidia.ko
nvidia-kernel-2.6.26-2-vserver-686-bigmem: /lib/modules/2.6.26-2-vserver-686-bigmem/nvidia/nvidia.ko
nvidia-kernel-2.6.26-1-vserver-686-bigmem: /lib/modules/2.6.26-1-vserver-686-bigmem/nvidia/nvidia.ko

This does assume that all installed modules are known to the packaging system, but this is generally a good idea anyway. At least on Debian, installing kernel modules as binary packages is generally possible. This approach has the advantage that it tells you which package a kernel module belongs to. Similar approaches should work with other Linux distributions which use a package management system; i.e. most of them.

Since the location of third party modules is similar to those of the in-kernel modules, it is not easy to distinguish them. Querying the package manager makes things easier. However, in my currently running kernel, in the directory /lib/modules/2.6.32-5-vserver-686-bigmem, I notice that the nvidia modules are in a separate directory from the main kernel modules, namely /lib/modules/2.6.32-5-vserver-686-bigmem/nvidia vs /lib/modules/2.6.32-5-vserver-686-bigmem/kernel. I don't know if such a layout is Debian policy or not. The closest thing to Debian kernel policy I am aware of is The Debian Kernel Handbook, but I did not find anything relevant there. Of course, Ubuntu is not bound by Debian policy in any case.

share|improve this answer
    
Thanks! Your idea is to find *.ko that were installed with the package manager, but are not in the kernel package. On most systems, this probably gives an almost complete (if not complete) list of external kernel modules. Proprietary video card drivers are notable exceptions, but I can specifically look for them. –  netvope Jan 26 '12 at 17:18
    
BTW, I found that on Ubuntu 10.04, the only packages (in the official repository) that contain kernel modules are the linux-backports-modules and linux-image packages. I used this command to check: apt-file search --regexp '\.ko$' | egrep '^[^ ]+: /lib/modules' | cut -d: -f1 | uniq -c –  netvope Jan 26 '12 at 17:43
    
@netvope: Thanks for your comments. Actually, proprietary video card drivers are sometimes included in Debian/Ubuntu as well - see the nvidia module packages I list above. Ubuntu is much more enthusiastic about including them though. Also, there are many packages in both Ubuntu and Debian which dosn't have the structure you state. Are you sure you are searching all the repositories? –  Faheem Mitha Jan 26 '12 at 19:02
    
Looks like it's because those nvidia-* packages only build the modules when you install them. For example, nvidia-173 (description = "NVIDIA binary Xorg driver, kernel module and VDPAU library") contain a bunch of C sources and headers, but no *.ko files. Therefore, my previous comment based on apt-file results is incorrect. –  netvope Jan 27 '12 at 5:28
add comment

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.