Spidey01 / linux-kernel-module-dkms-example

Example of building a simple Linux kernel module via DKMS.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

My example of doing a Linux Kernel Module (LKM) with Dynamic Kernel Module Support (DKMS).

    To build: make -C $path_to_linux_headers M=`pwd` modules
    To clean: make -C $path_to_linux_headers M=`pwd` clean

You can just insmod ./mymodule.ko after building and then rmmod
mymodule. Use dmesg | tail to check log and lsmod to check if is loaded.

DKMS can be done via Makefile, go read it or do it manually as per below.

To use DKMS do it like so:

	# ln -s `pwd` /usr/src/mymodule-1.0
	# dkms add -m mymodule -v 1.0
	# dkms install -m mymodule -v 1.0
	
To remove with DKMS:

	# dkms remove -m mymodule -v 1.0 --all

When installed with DKMS you can manually insert / remove the module  like this:

	# insmod /lib/modules/$(uname -r)/updates/dkms/mymodule.ko
	# modprobe mymodule

	# rmmod mymodule

And check dmesg / lsmod the same way as a raw build.

About

Example of building a simple Linux kernel module via DKMS.

License:GNU General Public License v2.0


Languages

Language:C 100.0%