Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I needed a newer version of a Kernel module in an quite old kernel.

How can I replace a single kernel module of the mainstream linux kernel and compile only this module?

share|improve this question
up vote 2 down vote accepted

One warning: There is no gurantee, that the new driver version is compatible with the old kernel. But it is worth a try.

  1. Find the newer driver in the kernel. There are two options: You can use the original kernel driver from the kernel git, for example in https://github.com/mirrors/linux/drivers. It is handy to select a tag to find the specific kernel version you need. Download the specific thedriver.h and thedriver.c files and put them into a new directory.

    The second option is to fetch Ubuntu's new kernel from http://packages.ubuntu.com or via apt-get source ...

  2. Install the packages build-essentials and the linux-kernel-headers

  3. Now we create a makefile for this single module as shown on cyberciti.biz, thedriver.o has to be replaced by the driver name. In the folder which contains the driver code, create a file Makefile with the following content:

    obj-m += thedriver.o
    
    all:
        make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
    
    clean:
        make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
    
  4. Now, in this directory, type make to compile the driver.

  5. If everything works well, a thedriver.ko file should have been created that can be placed into the folder /lib/modules/$kernelversion/kernel/drivers (do not forget to create a backup)

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .