Can a driver be compiled alone instead of the whole linux kernel?

06
2014-04
  • user791953

    I made some changes to the serial driver on my linux machine. I've been trying to compile the module and reload it, but it throws some errors. Instead, if I recompile the whole kernel it works fine.

    Is it possible to make my changes to the serial driver, and compile only that module, and load it in?

    Thanks

  • Answers
    Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

    Related Question

    How to configure a Linux kernel based on the modules currently in use?
  • Carla

    I'm willing to build a minimal kernel with only the needed things for my machine; so I started by compiling the kernel from the ground up, using the default configuration and adding things that I know for sure I have (i.e.: Ethernet card, WiFi card, ...).

    But there are several other things not so easy to know about (i.e.: the watchdog timer) so I came across AutoKernConf which supposedly detects the hardware of the machine and generates a kernel configuration file with the settings for the found devices.

    The problem is it contained several settings repeated and even some which I don't have (I'm using a Dell laptop and one of the things it "found" was something of a Toshiba one).

    So I ended up building a kernel with the configuration that came out of the make allmodconfig command, which is a kernel with most of the things compiled as modules.

    Booting into that kernel and running lsmod I can see all of the kernel modules in use (the ones really needed) and I would like to know if there is a tool or some way for me to parse that list and convert it to the corresponding kernel configuration file.

    Or how to map each one with the appropriate options in the kernel so that I can manually set them.

    Thank you very much for your time.


  • Related Answers
  • Area 51

    If you're using Linux 2.6.32 and above, you may want to check out the "localmodconfig" make target. It does pretty much what you ask—it determines what modules you have running, and generates a .config making sure those modules are built. The "localyesconfig" target will compile those modules statically into the kernel rather than creating modules.

    More info available here: Easy local kernel configuration.