7

I have been provided with a vendor supplied minimal linux installation. From an answer to a previous question I discovered that it is possible to build a kernel with or without module support. I have a CANBUS device that I need to attach which comes with drivers in the form of .ko files. I would like to be able to install these with the provided install scripts, but firstly I need to know if my kernel was built with module support - is it possible for me to detect this from the command line??

When I run lsmod it returns nothing so I know that there are no .ko files there at the moment - but doest this mean that the kernel won't allow me to install a .ko file ?

6
  • You could run lsmod to see if there are any modules loaded, or check whether /lib/modules/`uname -r` exists or check /proc/modules...
    – hhaamu
    Jul 16, 2012 at 9:11
  • @hhaamu Thanks for the suggestion - I was adding a little extra to the question as you added this. There is no /lib/modules on my system. Jul 16, 2012 at 9:13
  • In this case it seems unlikely that your system has been compiles with modules support.
    – Marco
    Jul 16, 2012 at 9:15
  • Given your questions, it looks like you should install a less closed distribution on your device. Jul 17, 2012 at 21:44
  • I think I may have to abandon Linux altogether as the OS on my device and use DOS Jul 18, 2012 at 7:06

2 Answers 2

12

If you have a /proc filesystem, the file /proc/modules exists if and only if the kernel if compiled with module support. If the file exists but is empty, your kernel supports modules but none are loaded at the moment. If the file doesn't exist, your kernel cannot load any module.

It's technically possible to have loadable module support without /proc. You can check for the presence of the init_module and delete_module system calls in the kernel binary. This may not be easy if you only have a compressed binary (e.g. vmlinuz or uImage). See How do I uncompress vmlinuz to vmlinux? for vmlinuz. Once you've managed to decompress the bulk of the kernel, search for the string sys_init_module.

Note that if modules are supported, you'll need additional files to compile your own modules anyway: kernel headers. These are C header files (*.h), some of which are generated when the kernel is compiled (so you can't just take them from the kernel source). See What does a kernel source tree contain? Is this related to Linux kernel headers?

1
  • Thanks for this. It sounds like I will have to abandon this then. Jul 18, 2012 at 7:03
4

Most distributions store a text file with the kernel configuration somewhere. On a Debian system you'll find it in /boot/config-<kernel_version>.

Then you can simply run grep on that file:

grep CONFIG_MODULES /boot/config-<kernel_version>
3
  • Thanks for your answer. Unfortunately there is no /boot/config-*** on my installation. Jul 16, 2012 at 8:59
  • 1
    There's also /proc/config.gz if the kernel was configured with CONFIG_PROC_CONFIG
    – hhaamu
    Jul 16, 2012 at 9:21
  • @hhaamu I don't seem to have that either. Jul 16, 2012 at 13:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .