Linux Kernel Modules

Lsmod

Show the status of modules in the Linux Kernel

Let's look at two modules

user@workstation:~$ lsmod | grep button
button                 16384  1 i915
user@workstation:~$ lsmod | grep pcspkr
pcspkr                 16384  0
user@workstation:~$

Challenge

Find out where button and pcspkr are under:

  • /lib/modules/

  • Kernel Configuration

  • Mainline

Hello World Module Source Code

Make a "helloworld" directory

user@workstation:~$ mkdir helloworld

Create helloworld.c file under our helloworld directory and add the C code below, this is a simple Hello World Kernel Module

Hello World Module Makefile

Create the Makefile under helloworld directory and add the code below

Hello World Module Compilation

Now compile your Hello World Module

Hello World Module Files

Last updated