Loadable kernel module is very useful for dynamically adding functionality to the running kernel. As the free of Linux, we can often update/install new kernel easily. For some distributions, every time we install a new kernel, we need to compile the loadable module at the same time. This is very boring and in sometimes it can do some harmness. This is the Dynamic Kernel Module Support (DKMS) can play a role. DKMS is a program/framework that enables generating Linux kernel modules whose sources generally reside outside the kernel source tree. And the DKMS modules will be automatically rebuilt when a new kernel is installed.
This article will just focus how to use the dkms but not include the internals of it.
Let’s use the x710 network card VF driver as an example.
Firstly, Let’s see the system self-contained i40evf driver.
Here it has a low version of driver. We mannually override it with a more newer version.
It works, now let’s update the dist, this also updates the kernel.
Look at the i40evf again, it rolls back to the lower version again. If we want to use the high version i40evf, we need to compile it again.
Firstly, we need move the source file into the /usr/src directory. For example
Notice here i40evf-3.4.2 directory is the src directory in i40evf-3.4.2.tar.gz.
In this directory we need create a file named dkms.conf. Following is the file content.
root@debian91:/usr/src/i40evf-3.4.2# cat dkms.conf PACKAGE_NAME="i40evf" PACKAGE_VERSION="3.4.2" CLEAN="make clean" BUILT_MODULE_NAME="i40evf" DEST_MODULE_LOCATION="/updates" AUTOINSTALL="yes"
Then install the dkms package.
apt-get install dkms
Don’t forget install the linux headers package to build the module.
Now the i40evf has been updated to 3.4.2.
Updates the dist and reboot.
Notice the md5 checksum, we can make sure the i40evf module has been automatically rebuilt.
Also we ‘dkms status’ can show the dkms module installed.
root@debian91:~# dkms status i40evf, 3.4.2, 4.9.0-3-amd64, x86_64: installed i40evf, 3.4.2, 4.9.0-6-amd64, x86_64: installed
blog comments powered by Disqus