1

I am working on linux kernel development, and was trying to make my own modules for testing purposes. However, for the latest kernel source codes, the linux-headers don't exist. It only exists for 4.9.0-7 .

I googled and found 1 method where we make the module against the kernel source tree that we want (eg. 4.18) make -C /home/prasad/linux-4.18/ M=$(PWD) which does generate the .ko for my module. However, when I load up my kernel and insmod it , it says

insmod: ERROR: could not insert module test.ko: Unknown symbol in module

So how exactly do I generate a .ko file from my host machine that can be inserted for the 4.18 kernel ?

PS: My doubt is not a duplicate as I cannot "install" the 4.18 kernel in my vm, Im trying to avoid doing that. My question is more specific to generating an insertable .ko module, and not finding any other way to insert it in 4.18.

  • 1
    Look at `dmesg` and see what the unknown symbol is. It's likely you have a called a function that does not exist in the module or your module uses symbols that are from another module that is not yet loaded. `depmod` and `modprobe` take care of finding the dependencies of a module and loading them first; `insmod` does not do this. – TrentP Nov 17 '18 at 03:11
  • You cannot insert a module which is compiled for 4.18 in a machine which runs 4.9 Kernel. – Parthiban Nov 17 '18 at 14:01

1 Answers1

0

You cant use a module built for 4.18 in a 4.9 kernel.

If the headers for the kernel version you are building for are not available via apt/yum/etc, you will need to download the source manually from: https://www.kernel.org/

In the makefile for your module, you will specify the path to the kernel source code that you have downloaded and extracted.

That should allow you to build the module for the desired kernel version.

charlesw
  • 572
  • 6
  • 25