Invalid Module format error in Linux kernel 2.6.28

Posted on 2009-07-04
Last Modified: 2012-05-07
I have compiled open source USB driver for Fedora 8, when I Insert  the driver module .ko file on
Fedora 9 using  insmod driver.ko  i get the error Invalid Module format error  ?
why is this coming when i am inserting/deploying on higher version i.e Fedora 9 and compiled driver.ko on Fedora 8 ?
1.) Do i need to compile the driver along with kernel source where ever driver.ko is deployed ?
2.) I there any way at least for the minor number version change the driver.ko will insert ?
3.) It is not a good solution in every machine driver source is compiled, infact some of the client  
    machines doesn't have compilers and kernel sources installed

Question by:tittu
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
  • 2
  • +1
LVL 12

Expert Comment

ID: 24777236
Both Fedora 8 and Fedora 9 are old releases, you should upgrade to Fedora 11.

You are saying you were compiling open source USB driver, but that doesn't make much sense. Why would you do so? Standard kernel packages support USB for a very long time.

If you want to compile a driver, you need to compile it for the exact version of kernel, it even must be the same flavour, because distribution specific patches might make your driver incompatible.
LVL 40

Expert Comment

ID: 24777313
As stated, a module needs to match the base kernel. You can try loading with -f flag, but I'm sure this won't work between kernels of Fedora 8 vs 9, I only ever use it between minor patch level differences.

See the Kernel Loadable Module howto:

Author Comment

ID: 24780032
The USB driver is a custom driver not a standard driver
It is working fine with FC8 when compiled and installed.
my question can i atleast insert this driver module even in FC8 without recompiling every time on the
deployment targets, in brief how windows drivers work like simple layman installation without compiling
compiling driver sources even for minor kernel version releases is a bad thing ?
some of the client machines even doesn't have compilers and kernel sources installed.
please give me a good solution for this instead of pointing links , i already tried all the links
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

LVL 40

Expert Comment

ID: 24781471
>>my question can i atleast insert this driver module even in FC8 without recompiling every time on the deployment targets,

Yes, using the -f flag as I said. Did you try that?

With major kernel versions you really should be distributing a module for each kernel. Note, it has nothing to do with FC8 vs FC9, sometimes the distribution versions use the same base kernel version.

LVL 34

Expert Comment

by:Duncan Roe
ID: 24789645
You absolutely have to compile it. It relies on addresses in the built kernel. The smallest thing can make these change.
You could integrate the driver source into the kernel source tree so it will "just build" as you generate a new kernel. You need to pick some folder where the source will go (e.g. /usr/src/linux/drivers/usb/serial) and edit the files Kconfig and Makefile there. Your driver will then be visible in "make xconfig" &c.
Once complied by whatever means, you can deploy it with that kernel to other machines without recompiling (i.e. the modules folder and the kernel image are a matched pair. If there is also an initrd, then it's part of a matched triplet).

Author Comment

ID: 25366436

I will try  

Author Comment

ID: 25371613
Sun VirtualBox is compiling the kernel and Integrating into the existing kernel how is it doing
LVL 34

Expert Comment

by:Duncan Roe
ID: 25376282
What commands are you using to start the build? When you say "Integrating into the existing kernel", what exactly do you mean? Has a new kernel been built? Can you boot into it? Is your new module present?

I guess I'm saying I need rather more specific feedback to be able to help you further.

Author Comment

ID: 25400284
when Sun Virtual Box is installed using an RPM, it is integrating virtual box module into the existing
kernel. and now the virtual box is working fine with the existing new kernel is not installed and infact
compiling without kernel sources installed in the system.
LVL 34

Expert Comment

by:Duncan Roe
ID: 25438126
(Back from overseas trip)
That's as may be. Perhaps the RPM had a precompiled version for your kernel. Maybe it used mod-versions. There are all kind of advanced techniques it might have used.
If you simply have source for your custom driver, none of these are available to you. You have to have kernel source and you have to be running the kernel you built from that source. It sounds like you had better include the virtual box module in that kernel.Ideally you should have the configuration file (.config) for your current kernel, otherwise you have to build absolutely everything as a module and have an initrd (which is what distributors do, but the build takes ages). Or you might get away with working back from  an lsmod to know what you actually need. Without an initrd, you need to ensure that your kernel has built in support for your boot media - that's what I always do.
It's a bit of an undertaking if you haven't done this sort of thing before, but once you get the hang of it the next one will be much easier.

Author Comment

ID: 25513939
I need some clarification , why do i need always kernel sources when ever iam going to install drivers or .ko files , windows OS is intelligent in this case.
LVL 34

Accepted Solution

Duncan Roe earned 500 total points
ID: 25520318
It is possible to make LKMs that are revision-tolerant to an extent, I think it needs the kernel to be built a special way too. (for other experts - I'm thinking of the system whereby you could build revision information into modules - I never used it myself).
However the Linux kernel evolves fairly rapidly so sometimes you just have to rebuild stuff.

Author Closing Comment

ID: 31599780
not complete solution

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
When trying to install php-fpm on CentOS 7 - GPG error 2 135
parallel rsync issues with Ubuntu 1 50
exchange, squid, proxy, linux 6 87
sed command 3 27
Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question