I was wondering how it would be possible to build a native kernel module, which is not enabled in the kernel configuration, and use it in order to add support for a certain feature to the system. This idea came to me while I was examining the
kernel-module-ntfs SRPM package from the Livna repository. This package adds support for the
ntfs filesystem and contains a
spec file and an archive with the linux ntfs driver source code. This is the same driver as the one that is included in the kernel sources. So, how could I build just this driver as a module directly from the kernel sources, without modifying the default kernel configuration?
After spending some time searching the internet for this info, the answer came from an article, titled "How To build your own NTFS RPMs" at the official linux ntfs driver homepage. Actually, the information I was looking for exists in a script that is provided through this page.
In order to build a module this way, you will need two things:
- The complete Fedora kernel sources, which are provided by the kernel SRPM.
- Knowledge of the module’s configuration options.
The "Qconf Graphical Kernel Configuration Tool" can be of great help in determining which are the configuration options for a certain module. You can launch this tool, by issuing the following command in the root directory of your kernel sources:
# make xconfig
Furthermore, this article assumes that we want to keep the default kernel configuration.
I would also recommend that you read another document of mine, named "The Complete Fedora Kernel Headers" or the Fedora Core Release Notes, which describe among other things how to get the fedora kernel sources.
Gathering the needed information
I will use the linux ntfs driver as an example. This is not enabled in the default Fedora kernel configuration, but we want to create this module, so that our system can recognize NTFS volumes.
Using the "Qconf Graphical Kernel Configuration Tool", we see that this module’s configuration options’ names are the following:
Actually, the previously mentioned tool omits the "
CONFIG_" part of the option’s name. You should keep this in mind.
The first of these options, determins if the kernel will have support for this feature or not. The possible values are "
m" or "
n". As we want to create a module, the proper value for this is the "
The other two options are actually specific to the module itself. The values they can take are "
y" or "
n". You decide which of these you want enabled. For this example, I’ll set both of these to "
Building the module
In order to build this module, we change to the root directory of our kernel sources and issue the following command:
# make CONFIG_NTFS_FS=m CONFIG_NTFS_DEBUG=n CONFIG_NTFS_RW=n M=fs/ntfs
We pass the proper kernel configuration options to
make, but also specify the relative path to the module’s
Makefile and source code with the
This way, we can build a native kernel module which is not enabled in the kernel configuration. The compiled module,
ntfs.ko in this case, can be perfectly added to our system’s kernel modules either manually or by using an RPM file, but this is beyond this article.
In order to clean the module’s directory from the compilation’s products, we can issue the following command:
# make M=fs/ntfs clean
Build a single native kernel module by George Notaras, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Copyright © 2005 - Some Rights Reserved