Using dkms to patch kernel

dkmskernelpatch

I need to apply a kernel patch(https://lkml.org/lkml/2015/3/31/929) to get my touch-pad working properly. I am thinking that I should be using dkms, to do this. Most of the stuff I am reading is about getting dkms to create modules. Can it also be used to patch a kernel?

What I am expecting:

  • package-management-system decides to upgrade kernel.
  • dkms/package-management-system downloads kernel source.
  • dkms applies patch.
  • dkms compiles kernel.
  • dkms installs patched kernel.

All automatically, but a bit slower than installing a pre-compiled kernel.

Am I on the right track?
How do I do it? (can you point me to the correct page in the manual)


I am using Ubuntu 15.04

Linux kubuntu 3.19.0-15-generic #15-Ubuntu SMP Thu Apr 16 23:32:37 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

Best Answer

You are basically on the right track, but there's no need to compile a complete kernel, that would be overkill. Usually dkms is used to automatically build one or more kernel modules for newly booted kernels.

So you would need to create a dkms configuration only for the kernel module that you want to patch, and then place the kernel module sourcecode that should be patched under /usr/src/modulename-version together with the patch and the dkms configuration.

If you want to pursue this path, you should have a look at the dkms man page or maybe the *buntu-specific dkms documentation and look at some of the existing dkms packages and adapt for your situation.

But you don't need to reinvent the wheel, please check if this fix applies in your case: https://hardc0l2e.wordpress.com/2014/12/06/fix-for-elantech-touchpad-on-ubuntu-14-04/ which is also mentioned at https://askubuntu.com/questions/541188/how-can-i-get-two-finger-scrolling-working-on-my-trackpad and https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1166442 and via http://www.evilcodingmonkey.com/2014/01/23/ubuntu-activate-multi-touch-on-elantech/

Related Question