How to recompile just a single kernel module?

user1056635 picture user1056635 · Jan 5, 2012 · Viewed 44k times · Source

Usually kernel source are stored in /usr/src/linux-2.6.x/. To avoid to recompile the entire kernel if I modify a module's source, how can I recompile just that module?

Answer

Niklas B. picture Niklas B. · Jan 5, 2012

Switch to the root directory of your source tree and run the following command:

$ make modules SUBDIRS=drivers/the_module_directory

And to install the compiled module:

$ make modules_install SUBDIRS=drivers/the_module_directory

Note: As lunakid mentions, the latter command might not build the module first, so be careful.