kernel module development sample
.gitignore | ||
hello.c | ||
Makefile | ||
README.md |
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