kernel-module/README.md

56 lines
794 B
Markdown

# build my own linux kernel module
run a linux container
```shell
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
```shell
docker exec -it linux bash
apt update && apt install -y gcc make kmod procps git
```
cleaning
```shell
docker rm -f linux
```
show module information
```shell
modinfo hello.ko
```
search if module is loaded
```shell
lsmod | grep hello
```
(un)/load module
```shell
insmod hello.ko [myint=4]
rmmod hello.ko
```
load module and load is dependencies module
```shell
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
```shell
dmesg -w
```