[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Building kernel modules for stock kernels is a hell of a job!



Hello,

After having worked with Debian testing for about 2 years, I'm getting fed up with the seemingly unnecessarily complicated way of building kernel modules for the stock kernels.

I'm talking about packages like lm-sensors-source, the nvidia kernel modules (haven't done that in a year though, I switched video cards), and the experimental Debian packages that provide CVS versions of the DRM module by Michel Daenzer (for my ATI card).

Currently, I'm having the following stock kernel installed:
kernel-image-2.4.21-4-k7, meaning my kernel modules are in /lib/modules/2.4.21-4-k7.

The procedure I'm going through is as follows (being root all the time)

1) install the kernel source for the kernel, e.g. kernel-source-2.4.21

2) go to /usr/src and tar xjvf kernel-source-2.4.21.tar.bz2

3) do the usual ln -s kernel-source-2.4.21 linux

4) to avoid having to configure the kernel again, copy the configuration: cp /boot/config-2.4.21-4-k7 /usr/src/linux/.config

5) apt-get install [modulename-source] (sometimes -src), e.g. lm-sensors-source.

6) this should give [modulename].tar.gz in /usr/src; extract it: tar xzvf [modulename].tar.gz
now, the source is in /usr/src/modules/[modulename]

7) and now, I always do the following (in bash): export APPEND_TO_VERSION -4-k7 if this is omitted, the kernel modules will be installed in the wrong directory, in this case in /lib/modules/2.4.21/, which doesn't even exist (it is created though).

8) go to /usr/src/linux and type: make-kpkg modules_image
this will build the sources and should result in a Debian package in /usr/src, named something like this:
[module-name]-2.4.21-4-k7_[version_of_module_source_package]+10.00.Custom_i386.deb
If you didn't use the export in step 7, you'll see that the name is like this:
[module-name]-2.4.21_[version_of_module_source_package]+10.00.Custom_i386.deb
Probably you can also get this version number correctly by using a --append-to-version command line option in the make-kpkg command line

9) install the just built package(s) with dpkg -i [package_name]
now the kernel modules should be in the right dir in /lib/modules and modprobe (or modconf) can find them.

That's it.

Notes:
- If you have just installed a new kernel-image package (i.e. a new stock kernel), you need to do everything from the start *after* booting this new kernel - In my experience, if you forget the export of step 7, you have to wipe your whole kernel source tree and start at step 2. I know I'm supposed to do a make-kpgk modules clean, but that didn't do the trick; I still got errors like "The changelog says we are creating 2.4.21-4-k7, but I thought the version is 2.4.21" or something similar (I didn't actually copy paste this from a real situation, it might have been the other way round). - If you have more modules to build, repeat steps 5, 6, 8 and 9 for all the source packages.
- all of the above really works, so I must be doing something right.


QUESTIONS:

A) Why isn't this procedure documented properly somewhere? Especially the APPEND_TO_VERSION was something that took me very long to figure out. It also wasn't mentioned in the installation instructions in the NVIDIA packages at the time I installed them. This caused a lot of mental suffering for me. (Which brings us to another thing: WHY oh WHY, isn't the procedure to get and install the NVIDIA drivers more automated!?)

B) Is there a faster or easier way to this?
If not, why not? There's a lot of trivial stuff there that could easily be automated, I think.
If so, (again:) why isn't it properly documented somewhere!??
See also this: http://lists.debian.org/debian-devel/2002/debian-devel-200203/msg01794.html and http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=189513

People, stock kernels are very comfortable, but building modules for them is not! Please tell me what I did wrong, or make the procedure a lot easier! (The latter especially applies to the maintainers of that NVIDIA package...)

Luckily, David Z. Maze has the lm-sensors as binary package in unstable nowadays... :) (Although not yet for 2.4.21...)

THANKS in advance.

Best regards,

A quite frustrated Manuel Bilderbeek :-)



Reply to: