<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule"
>
<channel>
	<title>G-Loaded Journal &#187; Modules</title>
	<atom:link href="http://www.g-loaded.eu/tag/modules/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.g-loaded.eu</link>
	<description>An open-source software and technology related journal</description>
	<lastBuildDate>Mon, 05 Dec 2011 19:55:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
		<item>
		<title>Build a single native kernel module</title>
		<link>http://www.g-loaded.eu/2005/12/20/build-a-single-native-kernel-module/</link>
		<comments>http://www.g-loaded.eu/2005/12/20/build-a-single-native-kernel-module/#comments</comments>
		<pubDate>Tue, 20 Dec 2005 02:00:31 +0000</pubDate>
		<dc:creator>George Notaras</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Compiling]]></category>
		<category><![CDATA[Kernel]]></category>
		<category><![CDATA[Modules]]></category>
		<category><![CDATA[Tips]]></category>
		<guid isPermaLink="false">http://www.g-loaded.eu/?p=125</guid>
		<description><![CDATA[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 [...]]]></description>
			<content:encoded><![CDATA[<p>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 <code>kernel-module-ntfs</code> SRPM package from the <a href="http://rpm.livna.org/" title="Link to the Livna.org Repository homepage">Livna</a> repository. This package adds support for the <code>ntfs</code> filesystem and contains a <code>spec</code> 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?<br />
<span id="more-125"></span><br />
After spending some time searching the internet for this info, the answer came from an <a href="http://www.linux-ntfs.org/content/view/126/62/">article</a>, titled &quot;<em>How To build your own NTFS RPMs</em>&quot; at the official linux ntfs driver <a href="http://www.linux-ntfs.org/">homepage</a>. Actually, the information I was looking for exists in a <a href="http://data.linux-ntfs.org/rpm/build-2.6">script</a> that is provided through this page.</p>
<h4>Prerequisites</h4>
<p>In order to build a module this way, you will need two things:</p>
<ol>
<li>The complete Fedora kernel sources, which are provided by the kernel SRPM.</li>
<li>Knowledge of the module&#8217;s configuration options.</li>
</ol>
<p>The &quot;<em>Qconf Graphical Kernel Configuration Tool</em>&quot; 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:</p>
<pre class="console"># make xconfig</pre>
<p>Furthermore, this article assumes that we want to keep the default kernel configuration.</p>
<p>I would also recommend that you read another <a href="http://www.g-loaded.eu/2005/12/14/the-complete-fedora-kernel-headers/">document</a> of mine, named &quot;<em>The Complete Fedora Kernel Headers</em>&quot; or the Fedora Core <a href="http://fedora.redhat.com/docs/release-notes/fc4/errata/">Release Notes</a>, which describe among other things how to get the fedora kernel sources.</p>
<h4>Gathering the needed information</h4>
<p>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.</p>
<p>Using the &quot;<em>Qconf Graphical Kernel Configuration Tool</em>&quot;, we see that this module&#8217;s configuration options&#8217; names are the following:</p>
<ol>
<li><code>CONFIG_NTFS_FS</code></li>
<li><code>CONFIG_NTFS_DEBUG</code></li>
<li><code>CONFIG_NTFS_RW</code></li>
</ol>
<p>Actually, the previously mentioned tool omits the &quot;<code>CONFIG_</code>&quot; part of the option&#8217;s name. You should keep this in mind.</p>
<p>The first of these options, determins if the kernel will have support for this feature or not. The possible values are &quot;<code>y</code>&quot;, &quot;<code>m</code>&quot; or &quot;<code>n</code>&quot;. As we want to create a module, the proper value for this is the &quot;<code>m</code>&quot;.</p>
<p>The other two options are actually specific to the module itself. The values they can take are &quot;<code>y</code>&quot; or &quot;<code>n</code>&quot;. You decide which of these you want enabled. For this example, I&#8217;ll set both of these to &quot;<code>n</code>&quot;.</p>
<h4>Building the module</h4>
<p>In order to build this module, we change to the root directory of our kernel sources and issue the following command:</p>
<pre class="console"># make CONFIG_NTFS_FS=m CONFIG_NTFS_DEBUG=n CONFIG_NTFS_RW=n M=fs/ntfs</pre>
<p>We pass the proper kernel configuration options to <code>make</code>, but also specify the relative path to the module&#8217;s <code>Makefile</code> and source code with the <code>M</code> option.</p>
<p>This way, we can build a native kernel module which is not enabled in the kernel configuration. The compiled module, <code>ntfs.ko</code> in this case, can be perfectly added to our system&#8217;s kernel modules either manually or by using an RPM file, but this is beyond this article.</p>
<p>In order to clean the module&#8217;s directory from the compilation&#8217;s products, we can issue the following command:</p>
<pre class="console"># make M=fs/ntfs clean</pre>
<h4>Further Reading</h4>
<p>I strongly suggest that you create RPM packages to add or remove software from your system, so I recommend the <a href="http://fedora.redhat.com/participate/developers-guide/ch-rpm-building.html">Chapter 4. Building RPM Packages</a> from the <a href="http://fedora.redhat.com/docs/developers-guide/">Fedora Core Developer&#8217;s Guide</a>.</p>
<div class="cc-block"><em><a href="http://www.g-loaded.eu/2005/12/20/build-a-single-native-kernel-module/">Build a single native kernel module</a></em>, unless otherwise expressly stated, is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License</a>. Terms and conditions beyond the scope of this license may be available at <a href="http://www.g-loaded.eu/about/disclaimer-and-license/">www.g-loaded.eu</a>.</div>
<h4>Related Articles</h4>
<ul><li><a href="http://www.g-loaded.eu/2006/09/09/kernel-2617-and-lirc_gpio-driver/" rel="bookmark">Kernel 2.6.17 and lirc_gpio driver</a></li>
<li><a href="http://www.g-loaded.eu/2005/12/14/the-complete-fedora-kernel-headers/" rel="bookmark">The Complete Fedora Kernel Headers</a></li>
<li><a href="http://www.g-loaded.eu/2011/03/02/rhel-kernel-source-released-with-patches-already-applied/" rel="bookmark">RHEL kernel source released with patches already applied</a></li>
<li><a href="http://www.g-loaded.eu/2005/12/15/get-my-kernel-headers-script/" rel="bookmark">Get my kernel headers script</a></li>
<li><a href="http://www.g-loaded.eu/2005/10/30/creative-pc-cam-750/" rel="bookmark">Creative PC-CAM Series webcams in linux</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.g-loaded.eu/2005/12/20/build-a-single-native-kernel-module/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
	</channel>
</rss>

