I have the following kernel installed:
[root@localhost ~]# uname -r
2.6.32-573.el6.x86_64
And the following kernel source:
linux-2.6.32-573.1.1.el6.x86_64
I am trying to compile a kernel module with that kernel source for my own kernel.
In the Makefile of the kernel source, I edited the EXTRAVERSION setting:
[root@localhost linux-2.6.32-573.1.1.el6.x86_64]# cat Makefile | grep "EXTRAVERSION ="
EXTRAVERSION = 2.6.32-573.el6.x86_64
And used the following command to compile the module:
[root@localhost linux-2.6.32-573.1.1.el6.x86_64]# make M=~/hw/
LD /root/hw/built-in.o
CC [M] /root/hw/hello_world.o
Building modules, stage 2.
MODPOST 1 modules
CC /root/hw/hello_world.mod.o
LD [M] /root/hw/hello_world.ko.unsigned
NO SIGN [M] /root/hw/hello_world.ko
But when I try to install it I recieve the following error:
[root@localhost linux-2.6.32-573.1.1.el6.x86_64]# insmod ~/hw/hello_world.ko
insmod: error inserting '/root/hw/hello_world.ko': -1 Invalid module format
And the output of modinfo is:
[root@localhost linux-2.6.32-573.1.1.el6.x86_64]# modinfo ~/hw/hello_world.ko
filename: /root/hw/hello_world.ko
license: GPL
srcversion: A8BB878B88F36D3A046026C
depends:
vermagic: 2.6.32-573.el6.x86_64 SMP mod_unload modversions
Can I compile the module for my current kernel without having to install its kernel sources?
Additional info:
OS: CentOS 6.7 minimal. Distribution binary.
Followed this guide: http://wiki.centos.org/HowTos/I_need_the_Kernel_Source
and downloaded the sources for linux-2.6.32-573.1.1.el6.x86_64 from here:
http://vault.centos.org/6.7/updates/Source/SPackages
I know that I could just download the source for my particular kernel, but in the end I actually want to build the module for a kernel version that I can't find the sources for (still 2.6.32), so that's why I want to do it this way.
modprobe
? That's smarter and more standard.