The following steps can be used to install and manage a kernel module with DKMS (to ensure that future kernel updates to the system also build the module).
For this example the ice
module will be managed with DKMS.
The DKMS package, build tools and kernel headers must be installed as well as what ever requirements there are for the module. For Debian based systems:
apt -y install linux-headers-amd64 build-essential dkms
Get the module source and extract it in /usr/src
.
cd /usr/src
wget -O ice-1.14.11.tar.gz "https://jaist.dl.sourceforge.net/project/e1000/ice%20stable/1.14.11/ice-1.14.11.tar.gz?viasf=1"
tar zxvf ice-1.14.11.tar.gz
Create a DKMS configuration file for the module. The following template can be used:
cat << 'EOF' > dkms.conf
PACKAGE_NAME=ice
PACKAGE_VERSION=1.14.11
BUILT_MODULE_NAME="$PACKAGE_NAME"
BUILT_MODULE_LOCATION=src/
MAKE="BUILD_KERNEL=${kernelver} make -j24 -C src/ KSRC=/lib/modules/${kernelver}/build KERNELDIR=/lib/modules/${kernelver}/build"
CLEAN="make -C src/ clean"
DEST_MODULE_LOCATION=/extra
AUTOINSTALL=yes
EOF
First add the module:
dkms add -m ice -v 1.14.11
The module can then be built:
dkms build -m ice -v 1.14.11
Finally install the newly built module:
dkms install -m ice -v 1.14.11
When/if you need to install module updates in future, follow the same steps in this guide. Once the new module has been added, built and installed, the old module can then be removed:
dkms remove -m ice -v 1.14.11
To view a list of installed modules and their kernel versions:
dkms status