kernel module development sample
Go to file
2024-04-20 23:51:25 +02:00
.gitignore feature: simple module structur. This module taken simple int parameter 2024-04-20 23:44:46 +02:00
hello-1.c feature: split module in two file 2024-04-20 23:51:25 +02:00
hello-2.c feature: split module in two file 2024-04-20 23:51:25 +02:00
Makefile feature: split module in two file 2024-04-20 23:51:25 +02:00
README.md feature: simple module structur. This module taken simple int parameter 2024-04-20 23:44:46 +02:00

build my own linux kernel module

run a linux container

docker run --name linux --privileged -v /lib/modules:/lib/modules -v ./:/root/data -v /usr/src:/usr/src -it -d debian

setup into container the required dependencies

docker exec -it linux bash
apt update && apt install -y gcc make kmod procps git

cleaning

docker rm -f linux

show module information

modinfo hello.ko

search if module is loaded

lsmod | grep hello

(un)/load module

insmod hello.ko [myint=4]
rmmod hello.ko

load module and load is dependencies module

ln -s $(pwd)/hello.ko /lib/modules/$(uname -r)
depmod -a
modprobe hello
modprobe -r hello
rm /lib/modules/$(uname -r)/hello.ko 

show kernel logs

dmesg -w