LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Building new kernel modules? (https://www.linuxquestions.org/questions/linux-software-2/building-new-kernel-modules-326943/)

raid517 05-25-2005 08:28 AM

Building new kernel modules?
 
Hi this is a long shot I guess... But anyway, I wonder, does anyone know if there is a way in Debian to compile modules from my kernel sources without compiling the entire kernel again? Say for example I bought a new network card and it needed specific drivers from the kernel which I had not compiled into my kernel on any previous kernel compile - isn't there any way just to compile that single driver from the kernel sources and load it, or must I compile everything from scratch again?

I hope I'm being clear about what I want. Basically I would like the ability to add new hardware without compiling my entire kernel again just to enable the driver for it. I would much rather just compile the driver itself.

I know compiling a kernel when it has been compiled at least once already is fairly fast, but there are various cirumstances where this is not helpful. I am experiencing one of those conditions right now - where recompiling the kernel would simply be impractical for what I hope to achieve.

Best regards,

GJ

niknah 05-26-2005 02:23 AM

I'm not sure about debian.

But in the kernel you can run
"make menuconfig" or "make xconfig"
you tick "M" for module that you want and compile it again.
Then run make modules modules_install
If it's just a driver you shouldn't need to reboot to load it up.

Recompiling little bits seems to go faster with 2.6 kernel than 2.4.

If you want to recompile without using the kernel compiling system, then that'll depend on what driver you're talking about and what kernel version.

jschiwal 05-26-2005 03:07 AM

I think that it depends whether the support for that type of module was already compiled in.
I would start with "make oldconfig" before "make xconfig" in the above instructions. This will use your last .config options before you make changes. It also validates your .config file.

If you are adding a sata drive and your kernel was compiled without sata support,
i.e.:# CONFIG_BLK_DEV_IDE_SATA is not set
in .config, then you would need to recompile the kernel with this option changed.

On the other hand if this is a module for an ide drive, then for the 2.6 kernel, you might be able to just
make modules && make modules_install

The nvidia installer does something like this to compile and install the nvidia.ko kernel module.

So to use your network device example. You are adding a device that uses the apricot network device driver. If the .config file says "CONFIG_APRICOT=m" then either a new driver isn't needed or you need only to install the source-code and run "make modules && make modules_install"

Also, there are howtos and README documents in the kernel source. Be sure the read through them. The source code the you are installing will probably have documentation with the source that will give you detailed instructions. There are also instructions on how to install drivers with the source code.

When I just looked in my /usr/src directory, there was a sub-directory "kernel-modules" present. Two kernel module source directories were inside. Each module's Makefile had a "make all" target to compile the module and "make install" target to install the module. Each module also had a README and INSTALL file.

This is the first of two methods for recompiling a kernel module given in the /usr/src/linux/SuSE-README file:
The first method involves the following steps:

(1) Install kernel-source.$ARCH.rpm.

(2) Change to the /usr/src/linux directory. Configure the kernel
(for example, ``make oldconfig'' or ``make cloneconfig'', see
HOW TO CONFIGURE THE KERNEL SOURCES).

(3) Create files required for compiling external modules:
``make modules_prepare''.

(4) Compile the module(s) by changing into the module source directory
and typing ``make -C /usr/src/linux M=$(pwd)''.

(5) Install the module(s) by typing
``make -C /usr/src/linux M=$(pwd) modules_install''.

If I hadn't read the README file in the kernel source, I would of missed the "make modules_prepare" step that my system requires.


All times are GMT -5. The time now is 09:57 AM.