What is a Linux Kernel Module?

Beaglebone black board






In this article, we explain what a linux kernel module is and why they are used with linux operating systems.

A linux kernel module is simply a module that represents some feature that can be added to a linux kernel.

This feature can be anything such as a security option, a device driver, a file system driver, networking support, etc.

Linux kernels (or linux operating systems) are complex software which can have various features, including security options, device drivers, file system drivers, etc.

A linux kernel module simply represents one of these features which can be added to the kernel.

Linux supports dynamic insertion and removal of code from the kernel while the system is up and running. This code what we add and remove at run time is called a kernel module.

Once the linux kernel module is loaded into the linux kernel, you can start using the new features and functionalities given by the linux module without having to restart the device.

Linux kernel modules dynamically extends the functionality of the kernel by introducing new features to the kernel, such as security, device drivers, file system drivers, system calls, etc.

This is referred to as the modular approach.

The reason why linux kernel modules are used often is because it makes the linux kernel image lighter in terms of memory usage. Linux kernel images allow your embedded linux system to have only minimal features and then the optional features such as device derivers and other features can be supplied on demand via module insertion.

If everything was included in the linux kernel image, it would have a large memory footprint and this causes the system to be more bogged down. Many times, the linux kernel module approach is able to lighten the linux kernel, and we just use additonal features as needed via module insertion.

It is important to know there are are 2 types of linux kernel modules, static and dynamic.

Static linux kernel modules are modules that are built in to the linux kernel. When you build a linux kernel, you can make the module statically linked to the kernel image (the module becomes a part of the final linux kernel image). This method increases the size of the final linux kenrel image. Since the module is built into the linux kernel image, you cannot unload the module. It occupies the memory permanently during run time.

Dynamic linux kernel modules are modules that are not built into the final kernel image. Rather, these modules are compiled and linked separately to produce .ko files. You can then dynamically load and unload these modules from the kernel using space space programs such as insmod, modprobe, and rmmod.

So when you're building the kernel, you can either link modules directly into the kernel o build them as modules that can be loaded into the kernel at some other time.

So if you are creating a linux kernel, you are go to the menu configuration table and select whether the particular any of various features should be built-in, excldued, or a module.

These are the options you have when you are building a linux kernel.

This is shown below.


Linux kernel menu configuration


If you read the top, you can see that pressing includes the feature, excludes the feature, and modularizes the feature.

So if you include the feature, it will be built-in to the final image of the kernel. This will increase the kernel image size.

If you exclude the feature, it won't be available with the linux kernel at all.

If you modularize the feature, it can be compiled and dynamically loaded to the linux kernel at some other point in time.

Again, linux kernel modules represents a modular approach to adding any of several features to a linux kernel (or linux operating system). This cincludes thing such as networking support, device drivers, various file system, security options.

Again, these are be built in to the kernel, completely excluded, or dynamically loaded to a kernel at some later time.



Related Resources





HTML Comment Box is loading comments...