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 ?

  • 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 '12 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. – mathematician1975 Jul 16 '12 at 9:13
  • In this case it seems unlikely that your system has been compiles with modules support. – Marco Jul 16 '12 at 9:15
  • Given your questions, it looks like you should install a less closed distribution on your device. – Gilles Jul 17 '12 at 21:44
  • I think I may have to abandon Linux altogether as the OS on my device and use DOS – mathematician1975 Jul 18 '12 at 7:06

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?

  • Thanks for this. It sounds like I will have to abandon this then. – mathematician1975 Jul 18 '12 at 7:03

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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