Linux - KernelThis forum is for all discussion relating to the Linux kernel.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I need to make a small change and rebuild just one module in the Gutsy distribution.
How do I do this without building the kernel or the other modules?
I want to just manually replace the module in my /lib/module tree. How can I be sure it will be versioned consistantly so that the kernel won't complain at load time?
Ubuntu uses a Debian style make-kpkg for its builds.
Do you want to create an installable package from this module, or just replace the existing one? Rebuilding the modules separate from the kernel is as easy as "make modules" in the kernel build directory. From there you could either install them all, or just manually replace the one you rebuilt (though there is really no reason not to replace them all).
As long as the modules are built against the same source tree as the running kernel, they will install fine on the official Ubuntu binary kernel (I.E. make sure you get the kernel source package from the Ubuntu repositories, and not just try and download the vanilla kernel).
But, again, if you want to make an installable package out of these (create a new kernel module package to replace the current one, for example) then there will be more steps involved. Depending on what your needs are, you might not need to actually go that far.
However, I would like not to build all the kernel modules, just the one I want.
If the only changes are for the files in question that is what “make modules” is supposed to do (it compares the timestamps of the sources to the timestamps of the objects and rebuilds only if the sources are newer than the objects—in your case, you edit the sources for a specific module so it will be the only one rebuilt).
If the only changes are for the files in question that is what “make modules” is supposed to do (it compares the timestamps of the sources to the timestamps of the objects and rebuilds only if the sources are newer than the objects—in your case, you edit the sources for a specific module so it will be the only one rebuilt).
That assumes that I have already built the modules once. What I'm asking is can I build just one module without building all of them?
If I need to make the change each time there is a kernel update, I would prefer to just build the one module I need to change.
That assumes that I have already built the modules once. What I'm asking is can I build just one module without building all of them?
Ah… quite true. Another possibility is to obtain from your distribution the sourcetree and buildtree for your current kernel (if that’s possible).
In any case, you can always force the rebuild of a particular module with make as well (by passing the pathname to make). E.g., if I want to rebuild the rtc.ko module, I would type the following:
Code:
$ make drivers/char/rtc.ko
Note that this should be done in a preconfigured kernel source tree (and all dependencies of rtc.ko might also be built).
If you ever need quick help with the kernel make system, “make help” will explain most of the targets.
I am assuming Ubuntu is the same as Debian in the following:
If you look in the file "Makefile" you will find this:
Quote:
# Use make M=dir to specify directory of external module to build
# Old syntax make ... SUBDIRS=$PWD is still supported
# Setting the environment variable KBUILD_EXTMOD take precedence
A little further on, you find:
Quote:
# The following are the only valid targets when building external
# modules.
# make M=dir clean Delete all automatically generated files
# make M=dir modules Make all modules in specified dir
# make M=dir Same as 'make M=dir modules'
# make M=dir modules_install
# Install the modules built in the module directory
# Assumes install directory is already created
So, you can type "make M=dir" where dir is the subdirectory containing the module, such as:
Code:
make M=drivers/ata
This would make any changed (or not previously made) .ko files in drivers/ata.
You might want to consider adding your distro to your LQ options.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.