I'm trying to compile and insert a module into my kernel, but I keep getting this error:
insmod: error inserting 'hello.ko': -1 Invalid module format
I followed the steps described in this tutorial over here:http://www.cyberciti.biz/tips/compiling-linux-kernel-module.html. And everything seemed to make sense and worked. I got my sample module compiled BUT there was a warning that might be an important lead to why this thing is failing. The warning was this one:
WARNING: Symbol version dump /usr/src/linux-3.0.0/Module.symvers is missing; modules will have no dependencies and modversions.
I frankly don't know why the Module.symvers file is not there. The /usr/src/linux-3.0.0 directory and all its contents were created by me after I dowloaded the sources using this command:
apt-get source linux-image-$(uname -r)
That was in fact the only step of that tutorial that I didn't follow, because I could not find the exact sources for my kernel (3.0.0-32-generic) and thought the aptitude tool would sort that out to me.
And I'm running Ubuntu on a 64 bits machine by the way, here's the uname -a output:
Linux vega 3.0.0-32-generic #51-Ubuntu SMP Thu Mar 21 15:50:59 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
Any suggestions as to what to try next? any recommended reading?
PS1. After some more research I confirmed I'm running the 3.0.0-32-generic. update-grub returned:
Found linux image: /boot/vmlinuz-3.0.0-32-generic
But after issuing a sudo make oldconfig and checking the resulting .config file I get this interesting line:
CONFIG_VERSION_SIGNATURE="Ubuntu 3.0.0-32.51-generic 3.0.69"
Does that qualify as a missmatch?
PS2. dmesg outputs this:
[ 5.869900] ADDRCONF(NETDEV_UP): eth1: link is not ready
[ 6.144304] EXT4-fs (dm-1): re-mounted. Opts: errors=remount-ro
[ 6.368936] EXT4-fs (sda1): mounted filesystem with ordered data mode. Opts: (null)
[ 6.433919] vesafb: mode is 640x480x32, linelength=2560, pages=0
[ 6.433921] vesafb: scrolling: redraw
[ 6.433923] vesafb: Truecolor: size=8:8:8:8, shift=24:16:8:0
[ 6.435424] vesafb: framebuffer at 0xb0000000, mapped to 0xffffc90012800000, using 1216k, total 1216k
[ 6.435516] Console: switching to colour frame buffer device 80x30
[ 6.443104] EXT4-fs (dm-2): mounted filesystem with ordered data mode. Opts: (null)
[ 6.450198] fb0: VESA VGA frame buffer device
[ 8.884523] e1000e: eth1 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: Rx/Tx
[ 8.885845] ADDRCONF(NETDEV_CHANGE): eth1: link becomes ready
[ 12.611236] init: ssh main process (762) terminated with status 255
[ 12.624381] init: failsafe main process (752) killed by TERM signal
[ 12.634739] type=1400 audit(1373412287.107:8): apparmor="STATUS" operation="profile_load" name="/usr/sbin/tcpdump" pid=852 comm="apparmor_parser"
[ 12.634873] type=1400 audit(1373412287.107:9): apparmor="STATUS" operation="profile_replace" name="/sbin/dhclient" pid=851 comm="apparmor_parser"
[ 12.635180] type=1400 audit(1373412287.107:10): apparmor="STATUS" operation="profile_replace" name="/usr/lib/NetworkManager/nm-dhcp-client.action" pid=851 comm="apparmor_parser"
[ 12.635403] type=1400 audit(1373412287.107:11): apparmor="STATUS" operation="profile_replace" name="/usr/lib/connman/scripts/dhclient-script" pid=851 comm="apparmor_parser"
[ 19.390991] eth1: no IPv6 routers present
[ 576.758697] hello: no symbol version for module_layout
your current kernel version is 3.0.0-32-generic
go to cd /lib/modules/3.0.0-32-gereric/
directory and check whether build directory is present or not. If present then you can directly compile your module using below command
make -C /lib/modules/3.0.0-32-generic/build M=$(PWD) modules
if you want to compile your module with kernel downloaded by you then follow the procedure below:
cd /usr/src/linux-3.0.0/
make menuconfig
make -j5
make modules
sudo make modules_install
sudo make install
sudo reboot
then boot your system with linux-3.0.0 kernel, and compile your module using below command:
make -C /lib/modules/3.0.0/build M=$(PWD) modules
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With