Blog post covering some of the setup for a hello.c example
In this repo you should be able to get running with:
git clone https://github.com/KlotzAndrew/kernel-modules.git
cd kernel-modules
vagrant up
vagrant ssh
cd src
This will drop you into a vagrant shell with file sync to your current directory
Skip if you already have Vagrant installed
apt install virtualbox
curl -SL --progress-bar https://releases.hashicorp.com/vagrant/2.2.14/vagrant_2.2.14_linux_amd64.zip --output /tmp/vagrant.zip
unzip -o /tmp/vagrant.zip -d /usr/local/bin
rm /tmp/vagrant.zip
# libarchive-tools not default in ubuntu 20.04
apt-get install libarchive-tools
vagrant --version
vagrant plugin install vagrant-vbguest
There is first time setup for installing your kernel headers
make setup
Compiling
make all
Running
sudo /sbin/insmod hello.ko
sudo /sbin/rmmod hello.ko
tail /var/log/kern.log