Re: 'insmod error Invalid module format' upon an improper kernel source tree hierarchy?



On Sep 27, 8:31 am, Janaka <jana...@xxxxxxxxxxxx> wrote:
lovecreatesbea...@xxxxxxxxx wrote:

I fail again at catching the concept of Linux 'kernel source tree' and
compiling a 'hello world' module successfully. Can you please help me
again? Thank you for your time.

I'm running a debian-40r1 (kernel 2.6.18) and got a copy of kernel
source linux-2.6.22.6.tar.bz2 from kernel.org. The version numbers of
the running kernel and the kernel source aren't exact the same, and
I'm aware of the minor difference. Will this be a problem if I don't
boot with the newly compiled kernel of 2.6.22.6.

After built the kernel source and a `hello world' module, I really
encountered a problem of `error inserting 'hellomod.ko': -1 Invalid
module format' when executed insmod.

The followings are main steps of kernel source building:

1. untar kernel source linux-2.6.22.6.tar.bz2 in my home directory.
And nothing added at /usr/src/linux. Will this be a problem?

2. su root -c 'make defconfig'

3. su root -c 'make'

4. su root -c 'make modules_install install'

Now the object files of the kernel source are all generated, those
object files are what customized kernel module programming needed, so
I just stopped here.

Do the above steps build a kernel source tree hierarchy properly,
since I didn't do the following steps '5*'.

[
5* I didn't do 'make bzImage' and didn't add corresponding entries
for the newly built kernel in GRUB or LILO.
]

First of all it is highly recommended that you use your current kernel
configuration as the basis for your new kernel configuration, if you
have a running linux system that you are happy with. It still will
work (in most cases) if the kernel you are compiling is newer than the
one that you are running. Most Debian based distributions have the
kernel configuration file in the /boot directory (eg:
config-2.6.15-26-386). Using "menuconfig" (or any other graphical
config) you can load an old configuration as the basis and change the
kernel config as need be. Then save on exit. Now you have a
configuration that closely resemble your current running linux box.

Secondly If you are using a Debian based distribution (eg:
Ubuntu, ...) use the Debian kernel compile helper tool "make-kpkg" to
create a debian package, and install that package. That is the safest
method. There is a good tutorial inhttp://www.falkotimme.com/howtos/debian_kernel2.6_compile/

Thirdly kernel you are running must be the same version as your module
is compiled for.

Thank you.

Does this mean the kernel should be upgraded to the kernel used for
module programming?

But you also said the following : )
"...It still will
work (in most cases) if the kernel you are compiling is newer than
the
one that you are running. ..."

.



Relevant Pages

  • Re: pros/cons of installing from source
    ... Debian supply both optimised kernels and to a lesser degree ... Doing a full emerge of the kernel source (inside the ... really required and what is not for a package (this requires the most ... soon as it stopped compiling and installing. ...
    (Debian-User)
  • Re: Compiling a kernel
    ... (unless you're creating Debian packages). ... 2.4.* kernel to a 2.6.18 kernel. ... Before, I tried to have no modules, compiling needed modules into the ... I presume you have an Nvidia card with 3D acceleration. ...
    (Debian-User)
  • Re: module not found: how to configure the loading of modules?
    ... I have been succesful in compiling the driver needed for this ... card and I can connect to my AP. ... (for Debian?). ... I am running debian testing with a self-compiled kernel. ...
    (Debian-User)
  • Re: Re. CD writer
    ... I have Debian woody ... > including taking out all reference to ide from the ... goes crazy and it never goes beyond IRQ-madness, without ever the kernel ... > Custom Kernel Compiling in Debian 2.2 by Jeepsta) use ...
    (Debian-User)
  • Kernel compile blues
    ... I'm using debian woody. ... successful booting with the compiled kernel in debian (Have used sarge ... Past few days I have been sitting just compiling and re-compiling various ... Kernel panic: VFS: Unable to mount root fs on 03:06 ...
    (Debian-User)