Install and Verify the Kernel Module Packages

About This Task

Once you build the kernel module packages as described in Obtain Driver Source and Build the Kernel Module Packages, you can install them to test and verify operation.

Before You Begin

You must have successfully built the kernel driver module packages.

This procedure assumes you are in the parent directory of the cloned hello-world repository.

Procedure

  1. Install the kernel driver module packages.

    Note

    The hello-world-common package includes dependencies for the hello-world package. As a result, you must install it first.

    $ sudo dpkg -i hello-world-common_1.0-elxr8-1_amd64.deb
    $ sudo dpkg -i hello-world_1.0-elxr8-1_amd64.deb
    
  2. Update the kernel module dependencies to ensure the new module is included.

    $ sudo depmod -a
    
  3. Add the module to the running kernel.

    $ sudo modprobe hello-world
    
  4. Verify the module is running.

    $ sudo lsmod |grep hello
    
    hello_world 12288 0
    

    In this example, the output reflects the kernel module name and process ID.

    To view the message from the printk function for loading the module, run the following command:

    $ sudo dmesg |grep Hello
    
    [244743.059253] Hello world!
    
  5. Optionally remove the kernel driver module and uninstall the packages.

    $ sudo rmmod hello-world
    

    To view the message from the printk function for unloading the module, use the same dmesg command:

    $ sudo dmesg |grep Hello
    
    [244743.059253] Hello world!
    [246050.196856] Hello world exit!
    
  6. Optionally uninstall the kernel module packages.

    $ sudo dpkg -r hello-world hello-world-common
    

Results

In this tutorial, you have learned how to prepare, build, install, verify, and remove a kernel module in eLxr Server 26.04.

For more detailed information on working with the kernel, refer to the documentation at Debian Linux Kernel Handbook: Common kernel-related tasks.