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




lovecreatesbea...@xxxxxxxxx wrote:
Hello experts,

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 in
http://www.falkotimme.com/howtos/debian_kernel2.6_compile/

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

.



Relevant Pages

  • Re: insmod error Invalid module format upon an improper kernel source tree hierarchy?
    ... compiling a 'hello world' module successfully. ... the running kernel and the kernel source aren't exact the same, ... configuration as the basis for your new kernel configuration, ... Secondly If you are using a Debian based distribution (eg: ...
    (comp.os.linux.development.system)
  • SMALL HOW TO - Installing and compiling 2.6.11 on Suse 9.2
    ... My Suse 9.2 was quite disappointing in terms of performances. ... Note that 9.2 is originally shipped with kernel 2.6.8-24; ... configuration, ... This allows to avoid compiling lot of useless modules, ...
    (alt.os.linux.suse)
  • Re: FLAME____ Why is the kernel source not included
    ... just the kernel source implied very clearly that you either did *not* ... kernel SRPM included in the binary disks, ... binary disks to include the kernel SRPM, ... that "heartbeat" we know as the kernel source. ...
    (Fedora)
  • Re: Compiling kernel
    ... On Sun, 4 Apr 2004 at 8:04pm, Sebastiaan wrote: ... :> I've been looking at the documentation for compiling the kernel, ... :> configuration as a starting point and make the changes relative to that. ... but I recommend very highly compiling the kernel "the ...
    (Debian-User)
  • Re: Linux kernel does not work. Is there anything that can be done to fix it?
    ... I tried compiling a Linux kernel, since I needed to in order to use a ... Were you able to compile and boot a kernel from the unmodified ... The configuration used was just the one I had on my system in "/boot". ... Could the code change have screwed it up badly? ...
    (comp.os.linux.misc)