1
0
mirror of https://github.com/krislamo/kernmod.git synced 2024-12-16 03:40:35 +00:00

Build and install module with DKMS

This commit is contained in:
Kris Lamoureux 2022-01-14 01:54:13 -05:00
parent 00e921ec10
commit d00996062e
Signed by: kris
GPG Key ID: 3EDA9C3441EDA925
3 changed files with 27 additions and 4 deletions

View File

@ -1,13 +1,28 @@
#!/bin/bash #!/bin/bash
VERSION="0.1"
# Install build prerequisites
export DEBIAN_FRONTEND=noninteractive export DEBIAN_FRONTEND=noninteractive
apt-get update apt-get update
apt-get install build-essential linux-headers-$(uname -r) -y apt-get install -y dkms build-essential linux-headers-$(uname -r)
# Place source and configuration files on the system
cd /vagrant cd /vagrant
make mkdir /usr/src/helloworld-$VERSION
modinfo helloworld.ko cp Makefile /usr/src/helloworld-$VERSION/Makefile
insmod helloworld.ko cp helloworld.c /usr/src/helloworld-$VERSION/helloworld.c
cp dkms.conf /usr/src/helloworld-$VERSION/dkms.conf
cp helloworld.conf /etc/modules-load.d/helloworld.conf
# Build and install kernel module with DKMS
dkms add -m helloworld -v $VERSION
dkms build -m helloworld -v $VERSION
dkms install -m helloworld -v $VERSION
# Load module and show details about it
modprobe helloworld
modinfo helloworld
cat /proc/modules | grep helloworld cat /proc/modules | grep helloworld
rmmod helloworld rmmod helloworld
cat /var/log/messages | grep helloworld cat /var/log/messages | grep helloworld

5
dkms.conf Normal file
View File

@ -0,0 +1,5 @@
PACKAGE_NAME="helloworld"
PACKAGE_VERSION="0.1"
BUILT_MODULE_NAME[0]="helloworld"
DEST_MODULE_LOCATION[0]="/kernel/drivers/helloworld/"
AUTOINSTALL="yes"

3
helloworld.conf Normal file
View File

@ -0,0 +1,3 @@
# A kernel module that should be loaded at boot time
# /etc/modules-load.d/helloworld.conf
helloworld