[CentOS] Compiling modules in kernel source but not included in distro.

Sun Aug 24 15:22:35 UTC 2014
Andrew Stringer <centos at rainsbrook.co.uk>

Hi, I've been trying to compile some kernel modules for centos 6.5, 
specifically fore_200e atm driver (although I also have hardware to try 
nicstar
and he ). This module is not included in the centos kernel or modules but 
is included in the stock kernel source.


Lots of articles on compiling or patching modules in general or compiling 
code not included in the kernel source, but not much on creating a module
in the source but not included in a distro.

After reading some of the centos wiki articles on why I don't need the 
kernel source, I tried just compiling the module source on it's own, but
when I tried to modprobe / insmod it, I get this error:-
insmod: error inserting 
'/lib/modules/2.6.32-431.20.5.el6.x86_64/extra/fore_200e.ko': -1 Invalid 
module format

Google suggests this is because I am trying to compile against the wrong 
headers but as far as I can see, there is only one kernel and kernel
headers on the system.

This is my os:-

Linux localhost.localdomain 2.6.32-431.20.5.el6.x86_64 #1 SMP Fri Jul 25 
08:34:44 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

It's a vm used just for compiling the code, so obviously there isn't some 
real PCI bus hardware present but this should not cause the above error.

As a different track, I tried to compile a new kernel and modules.
This is on a real machine, with a 32bit kernel,
2.6.32-431.20.5.el6.i686 #1 SMP, although the hardware is 64 bits. I 
thought to avoid any possible issues with either non-64 bit clean code or
trying to compile 32 bit code on a 64 bit machine initially, I installed a 
32 bit os.

With make menuconfig I could select the extra modules to compile. This 
seems to have worked ok, but the resulting kernel is
kernel-2.6.32-1.i386.rpm, the src package is kernel-2.6.32-1.src.rpm but 
the running kernel is 2.6.32-431.20.5

Trying to install it gives:-
[root at neptune ~]# rpm -ivh 
/home/andrew/rpmbuild/RPMS/i386/kernel-2.6.32-1.i386.rpm
Preparing...                ########################################### 
[100%]
         package kernel-2.6.32-71.el6.i686 (which is newer than 
kernel-2.6.32-1.i386) is already installed
         package kernel-2.6.32-431.20.5.el6.i686 (which is newer than 
kernel-2.6.32-1.i386) is already installed
[root at neptune ~]#

I'm not sure why the new kernel isn't a later number.

I downloaded the latest centos source so the major numbers match, but I'm 
not sure why the minor numbers are 2.6.32-1 not 2.6.32-431.20.5 and note
importantly, how to fix it.

I'm still not convinced that recompling the whole kernel just to get some 
new modules is the right way to go. My feeling is that my initial
approach is the right way to go.

Any clues on the best direction to proceed?

Regards,
Andrew.

-- 
Windows, for life without walls.
Linux, for life without Windows.