You need linux headers to be able to compile new module.
To make sure you have linux headers, see if the following path exists:
If the above directory is not present, you can install the headers using:
Once the headers are installed you are good to go.
Writing hello module
To start off, create the following file in any directory.
Create the following Makefile to compile your module.
After running make, you should see following:
Expanding further, each module needs to have an init and exit method.
Again, use inmod to install the command and you should see Hola Mundo! in dmesg. printk is important here; as kernel will print it to the syslog. Pretty useful in understanding other drivers.