LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices

Reply
 
Search this Thread
Old 10-27-2007, 06:31 PM   #1
kmand
LQ Newbie
 
Registered: Jul 2005
Posts: 21

Rep: Reputation: 15
Rebuilding a single kernel module


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.
 
Old 10-28-2007, 11:32 AM   #2
MS3FGX
Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Rep: Reputation: 351Reputation: 351Reputation: 351Reputation: 351
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.
 
Old 10-28-2007, 11:59 AM   #3
kmand
LQ Newbie
 
Registered: Jul 2005
Posts: 21

Original Poster
Rep: Reputation: 15
I just want to build the single "ko" file, not the package. However, I would like not to build all the kernel modules, just the one I want.
 
Old 10-28-2007, 01:17 PM   #4
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 70
Quote:
Originally Posted by kmand View Post
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).
 
Old 10-28-2007, 01:25 PM   #5
kmand
LQ Newbie
 
Registered: Jul 2005
Posts: 21

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by osor View Post
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.
 
Old 10-28-2007, 01:34 PM   #6
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 70
Quote:
Originally Posted by kmand View Post
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.
 
1 members found this post helpful.
Old 08-18-2009, 06:06 PM   #7
pixelbeat
LQ Newbie
 
Registered: Aug 2004
Location: Ireland
Posts: 3

Rep: Reputation: 1
I've detailed this here: http://www.pixelbeat.org/docs/rebuil...el_module.html
 
1 members found this post helpful.
Old 08-18-2009, 06:33 PM   #8
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,238

Rep: Reputation: 121Reputation: 121
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.
 
2 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Add single Module to Kernel Suse 10.1 carl0ski Suse/Novell 1 11-18-2006 12:49 PM
compiling single kernel module only evil_empire Linux - Software 2 01-31-2006 12:44 AM
How do you rebuild a single kernel module? rollo Linux - General 3 01-29-2006 01:19 AM
rebuilding kernel jmarsh Linux - Software 2 04-04-2003 08:09 PM
compile a single kernel module wr3ck3d Linux - General 10 03-01-2003 12:00 PM


All times are GMT -5. The time now is 08:49 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration