modulelinux-kernellinux-device-driver

Building kernel modules for different linux version


I am new to writing kernel modules, so facing few non-technical problems.

Since for creating kernel module for a specific kernel version ( say 3.0.0-10, 10 is patch number) requires same version kernel headers, so it looks straight to install kernel headers and start development over there. But kernel headers for patched kernel version are not available. As I have a guest kernel vmlinuz-3.0.0-10 running in machine and upon downloading kernel headers it says not found.

So intention of asking this is to know what are the preferences of kernel driver developers. Are there other alternatives ?

Is it possible to compile kernel module in one version and run in another version ( though it is going to give error, but are there any workaround for this ?)


Solution

  • So, building a new kernel is not a good option as it will require :

    So if you have kernel headers for running system then you dont need to download a source code for any kernel version, and while making module use

    make -C /lib/modules/kernel-headers-x.y.z/build M=`pwd` modules
    

    and your module will be ready.

    If there would be better answers, i will not hesitate to accept any of them.