mirror of https://github.com/tLDP/LDP
539 lines
16 KiB
Plaintext
539 lines
16 KiB
Plaintext
<!doctype article public "-//OASIS//DTD DocBook V3.1//EN">
|
|
<article id="Modules-HOWTO"><?dbhtml filename="Modules-HOWTO.html">
|
|
|
|
<artheader>
|
|
<title>Linux Kernel Modules Installation HOWTO</title>
|
|
|
|
<author>
|
|
<affiliation>
|
|
<address>
|
|
<email>rhw@bigfoot.com</email>
|
|
</address>
|
|
</affiliation>
|
|
</author>
|
|
|
|
<abstract>
|
|
<para>
|
|
Describes the installation of Linux kernel modules.
|
|
</para>
|
|
</abstract>
|
|
|
|
<revhistory>
|
|
<revision>
|
|
<revnumber>1.0</revnumber>
|
|
<date>Unknown date</date>
|
|
<authorinitials>rhw</authorinitials>
|
|
<revremark>Initial Release</revremark>
|
|
</revision>
|
|
</revhistory>
|
|
|
|
<legalnotice>
|
|
<para>
|
|
This document is covered by the terms of the GNU Free Documentation
|
|
Licence (GFDL), and all terms and limitations therein apply.
|
|
</para>
|
|
</legalnotice>
|
|
|
|
<keywordset>
|
|
<keyword>Linux</keyword>
|
|
<keyword>kernel</keyword>
|
|
<keyword>module</keyword>
|
|
</keywordset>
|
|
</artheader>
|
|
|
|
<sect1 label="1" id="purpose" >
|
|
<title id=purpose.title>Purpose of this Document</title>
|
|
|
|
<para>
|
|
My experience with Linux and modules has been that the existing
|
|
documents fail to provide a satisfactory explanation as to how to
|
|
successfully set up Linux with modules configured and working. The
|
|
procedure explained in this document has been successfully used several
|
|
times, both on my own system and over the Internet to give directions
|
|
to somebody trying to get some feature to work which requires a driver
|
|
supplied only in module form.
|
|
</para>
|
|
|
|
<para>
|
|
My own system runs from a RedHat 4.1 distribution of Linux, and it was
|
|
on this setup that I developed the procedure. I have since successfully
|
|
installed it on systems running from various Slackware distributions, and
|
|
on one system running from a Debian distribution, and the necessary
|
|
procedure to correctly configure modules under Linux in all three is
|
|
documented herein.
|
|
</para>
|
|
|
|
<warning>
|
|
<para>
|
|
I have recently used the same procedure with RedHat 4.2, but with
|
|
inconsistent results on apparently identical systems. I have not yet
|
|
determined what the problem is, so can make no guarantees at this stage
|
|
as to whether or not it will work on your system.
|
|
</para>
|
|
</warning>
|
|
|
|
<para>
|
|
This document is distributed under the terms of the GNU Free Documentation License.
|
|
You should have received a copy along with it. If not, it is available from
|
|
<ulink url="http://www.fsf.org/licenses/fdl.html">http://www.fsf.org/licenses/fdl.html</ulink>.
|
|
</para>
|
|
</sect1>
|
|
|
|
<sect1 label="2" id="require">
|
|
<title id=require.title>Pre-requisites</title>
|
|
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
Before the steps in this document can be applied, the reader must
|
|
have a working Linux installation in which one can get to the Linux prompt
|
|
as user <emphasis>root</emphasis> since the majority of the steps involved
|
|
can only be undertaken by the said user.
|
|
</para>
|
|
</listitem>
|
|
|
|
<listitem>
|
|
<para>
|
|
The existing kernel may be compiled either to use modules or not
|
|
to use modules, and can even display error messages during the boot-up
|
|
procedure as a result of modules being configured which aren't available
|
|
at the moment, providing the above condition is met.
|
|
</para>
|
|
</listitem>
|
|
|
|
<listitem>
|
|
<para>
|
|
The source tree for the current kernel is assumed to be found
|
|
rooted at <filename>/usr/src/linux</filename> and that is also
|
|
assumed to be the current directory throughout this document
|
|
at the start of any sequence of commands to be issued.
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
|
|
</sect1>
|
|
|
|
<sect1 label="3" id="speedup">
|
|
<title id=speedup.title>Compiler Speed-up</title>
|
|
|
|
<para>
|
|
If your machine has 16 or more Megabytes of RAM, there is a useful
|
|
speed-up that can be done, which is to permit the kernel to compile two or
|
|
modules in parallel. This will increase the load on the machine whilst the
|
|
kernel is being recompiled, but will reduce the time during which the
|
|
compilation will be taking place.
|
|
</para>
|
|
|
|
<para>
|
|
Before you can use this method, you need to check the amount of RAM
|
|
present in your machine, as if you set this too high, the compilation will
|
|
actually slow down. Experience has shown that the optimum value depends on
|
|
the amount of RAM in your system according to the following formula, at
|
|
least for systems with up to 32 Megabytes of RAM, although it may be a
|
|
little conservative for systems with larger amounts of RAM:
|
|
</para>
|
|
|
|
<para>
|
|
N = [RAM in Megabytes] / 8 + 1
|
|
</para>
|
|
|
|
<para>
|
|
For the benefit of those with a dislike of math, the values for the
|
|
common amounts of RAM are as follows:
|
|
</para>
|
|
|
|
<para>
|
|
|
|
<table frame="all">
|
|
<title>Sample Table</title>
|
|
|
|
<tgroup cols="2">
|
|
<colspec colname="column1">
|
|
<colspec colname="column2">
|
|
<thead>
|
|
<row>
|
|
<entry>RAM Size</entry>
|
|
<entry>Value to Use</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>16 Megs</entry>
|
|
<entry>3</entry>
|
|
</row>
|
|
<row>
|
|
<entry>24 Megs</entry>
|
|
<entry>4</entry>
|
|
</row>
|
|
<row>
|
|
<entry>32 Megs</entry>
|
|
<entry>5</entry>
|
|
</row>
|
|
<row>
|
|
<entry>40 Megs</entry>
|
|
<entry>6</entry>
|
|
</row>
|
|
<row>
|
|
<entry>48 Megs</entry>
|
|
<entry>7</entry>
|
|
</row>
|
|
<row>
|
|
<entry>56 Megs</entry>
|
|
<entry>8</entry>
|
|
</row>
|
|
<row>
|
|
<entry>64 Megs</entry>
|
|
<entry>9</entry>
|
|
</row>
|
|
<row>
|
|
<entry>80 Megs</entry>
|
|
<entry>11</entry>
|
|
</row>
|
|
<row>
|
|
<entry>96 Megs</entry>
|
|
<entry>13</entry>
|
|
</row>
|
|
<row>
|
|
<entry>112 Megs</entry>
|
|
<entry>15</entry>
|
|
</row>
|
|
<row>
|
|
<entry>128 Megs</entry>
|
|
<entry>17</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table>
|
|
</para>
|
|
|
|
<para>
|
|
When you have decided on the correct number, edit the file
|
|
<filename>/usr/src/linux/Makefile</filename> and find the line that currently reads:
|
|
</para>
|
|
|
|
<programlisting>
|
|
MAKE=make
|
|
</programlisting>
|
|
|
|
<para>
|
|
Replace it with one reading:
|
|
</para>
|
|
|
|
<programlisting>
|
|
MAKE=make -j N
|
|
</programlisting>
|
|
|
|
<para>
|
|
where <varname>N</varname> is the number determined above.
|
|
</para>
|
|
|
|
</sect1>
|
|
|
|
<sect1 label="4" id="kernel">
|
|
<title id=kernel.title>Recompiling the Kernel for Modules</title>
|
|
|
|
<para>
|
|
The kernel can be reconfigured to use modules for everything other than
|
|
the file system mounted as root (in most cases, this is the ext2 file
|
|
system).
|
|
</para>
|
|
|
|
<para>
|
|
However, there are certain items that appear to be difficult to set up
|
|
properly as modules, so I would recommend the following be compiled into
|
|
the kernel:
|
|
</para>
|
|
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
Ethernet hardware drivers.
|
|
</para>
|
|
</listitem>
|
|
|
|
<listitem>
|
|
<para>
|
|
SCSI CD-ROM drivers.
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
|
|
<para>
|
|
On the other hand, there are certain driver combinations that
|
|
<emphasis>ONLY</emphasis> work as modules, especially combinations
|
|
of two or more of the following group:
|
|
</para>
|
|
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
A Parallel Printer,
|
|
</para>
|
|
</listitem>
|
|
|
|
<listitem>
|
|
<para>
|
|
A Parallel Port drive, such as the <emphasis>IOMEGA</emphasis> ZipDrive or
|
|
JazzDrive, or the <emphasis>BackPack</emphasis> CD-ROM drive, and
|
|
</para>
|
|
</listitem>
|
|
|
|
<listitem>
|
|
<para>
|
|
The <emphasis>PLIP</emphasis> Daemon.
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
|
|
<para>
|
|
You will need to decide what you are compiling into the kernel, and
|
|
what as modules, but should take the above points into consideration. The
|
|
actual choices are made during the compilation, by the second of the
|
|
following sequence of instructions:
|
|
</para>
|
|
|
|
<programlisting>
|
|
cd /usr/src/linux
|
|
make menuconfig
|
|
make dep clean modules modules_install zImage
|
|
</programlisting>
|
|
|
|
<para>
|
|
Having done that, the module dependencies need to be mapped out. This
|
|
is done with the following command:
|
|
</para>
|
|
|
|
<programlisting>
|
|
depmod -a
|
|
</programlisting>
|
|
|
|
<para>
|
|
The new kernel now needs to be inserted in the boot chain. I am
|
|
assuming the reader is using <application>LILO</application> for this purpose, since this is the only
|
|
loader I have any experience with.
|
|
</para>
|
|
|
|
<para>
|
|
I recommend that one does NOT automatically insert the newly compiled
|
|
kernel as the default Linux kernel since if it should fail, it is then
|
|
extremely difficult to recover one's Linux setup without doing a complete
|
|
reinstallation, which is not to be recommended. For this reason, I have
|
|
the following entry in my <filename>/etc/lilo.conf</filename> file:
|
|
</para>
|
|
|
|
<programlisting>
|
|
image=/usr/src/linux/arch/i386/boot/zImage
|
|
label=new
|
|
alias=n
|
|
read-only
|
|
vga=ask
|
|
optional
|
|
</programlisting>
|
|
|
|
<para>
|
|
This entry says that there is an OPTIONAL boot option (which will be
|
|
ignored if the image in question does not exist) which boots the file
|
|
<filename>/boot/newlinux</filename> if selected, and allows one to select
|
|
the video mode it is to be booted in.
|
|
</para>
|
|
|
|
<para>
|
|
Assuming the existence of the above entry in <filename>/etc/lilo.conf</filename>
|
|
the revised kernel is already correctly located at the end of compilation, and
|
|
it can be installed via the following command:
|
|
</para>
|
|
|
|
<programlisting>
|
|
lilo
|
|
</programlisting>
|
|
|
|
<para>
|
|
Having done that, the reader needs to follow the further steps relevant
|
|
to their selected distribution, as follows:
|
|
</para>
|
|
|
|
<sect2 label="5.1" id="redhat">
|
|
<title id=redhat.title>Configuring Debian or RedHat for Modules</title>
|
|
|
|
<para>
|
|
Prior to carrying out the steps listed here, the steps listed in
|
|
<quote><link linkend="kernel" endterm="kernel.title"></link></quote>
|
|
are assumed to have been carried out.
|
|
</para>
|
|
|
|
<para>
|
|
The Debian and RedHat distributions have identical boot procedures, so
|
|
also have identical procedures for configuring modules into them.
|
|
</para>
|
|
|
|
<orderedlist>
|
|
<listitem>
|
|
<para>
|
|
Having logged in as root, use your favourite text editor to create
|
|
a new file called <filename>/etc/rc.d/init.d/modules.init</filename>
|
|
with the following contents therein:
|
|
</para>
|
|
|
|
<programlisting>
|
|
# Modules initialisation.
|
|
#
|
|
# Start up the module auto-loading daemon.
|
|
/sbin/kerneld
|
|
|
|
# Mount all currently unmounted auto-mounted partitions.
|
|
/sbin/mount -a
|
|
</programlisting>
|
|
</listitem>
|
|
|
|
<listitem>
|
|
<para>
|
|
Having created the above file, perform the following steps whilst
|
|
logged on as root:
|
|
</para>
|
|
|
|
<programlisting>
|
|
cd /etc/rc.d
|
|
chmod 755 init.d/*
|
|
cd rc3.d
|
|
ln -s ../init.d/modules.init 05modules.init
|
|
</programlisting>
|
|
</listitem>
|
|
</orderedlist>
|
|
|
|
<para>
|
|
The system can now be rebooted, and on doing so, it will be found that
|
|
modules are fully implemented
|
|
</para>
|
|
|
|
</sect2>
|
|
|
|
<sect2 label="5.2" id="slackware">
|
|
<title id=slackware.title>Configuring Slackware for Modules</title>
|
|
|
|
<para>
|
|
Prior to carrying out the steps listed here, the steps listed in
|
|
<quote><link linkend="kernel" endterm="kernel.title"></link></quote>
|
|
are assumed to have been carried out.
|
|
</para>
|
|
|
|
<para>
|
|
The file <filename>/etc/rc.d/rc.M</filename> needs to be edited as follows:
|
|
</para>
|
|
|
|
<orderedlist>
|
|
<listitem>
|
|
<para>
|
|
Around line 18, there is a section reading as follows:
|
|
</para>
|
|
|
|
<programlisting>
|
|
# Screen blanks after 15 minutes idle time.
|
|
/bin/setterm -blank 15
|
|
</programlisting>
|
|
|
|
<para>
|
|
Immediately after this, insert the following paragraph, with the usual
|
|
blank lines either side of it:
|
|
</para>
|
|
|
|
<programlisting>
|
|
# Load the kernel module auto-loader.
|
|
/sbin/kerneld
|
|
</programlisting>
|
|
</listitem>
|
|
|
|
<listitem>
|
|
<para>
|
|
About 12 lines further down is the following:
|
|
</para>
|
|
|
|
<programlisting>
|
|
# if there is no /etc/HOSTNAME, fall back on this default:
|
|
</programlisting>
|
|
|
|
<para>
|
|
Immediately prior to this, insert the following paragraph, again with the
|
|
usual blank lines either side of it:
|
|
</para>
|
|
|
|
<programlisting>
|
|
# Mount remaining unmounted auto-mount drives.
|
|
/sbin/mount -a
|
|
</programlisting>
|
|
</listitem>
|
|
</orderedlist>
|
|
|
|
<para>
|
|
When those changes have been made, save the file.
|
|
</para>
|
|
|
|
<para>
|
|
No further modifications are required for Slackware.
|
|
</para>
|
|
|
|
</sect2>
|
|
|
|
<sect2 label="5.3" id="otherdist">
|
|
<title id=otherdist.title>Configuring Other Distributions for Modules</title>
|
|
|
|
<para>
|
|
Prior to carrying out the steps listed here, the steps listed in
|
|
<quote><link linkend="kernel" endterm="kernel.title"></link></quote>
|
|
are assumed to have been carried out.
|
|
</para>
|
|
|
|
|
|
<para>
|
|
The precise procedure for other distributions has not been ascertained,
|
|
but is probably one of the above. To determine which one, display a
|
|
directory of the contents of the <filename>/etc/rc.d</filename> directory,
|
|
as follows:
|
|
</para>
|
|
|
|
<programlisting>
|
|
cd /etc/rc.d
|
|
ls -l *.d rc.*
|
|
</programlisting>
|
|
|
|
<para>
|
|
From this resulting display, you can select one of the following three
|
|
options:
|
|
</para>
|
|
|
|
<orderedlist>
|
|
<listitem>
|
|
<para>
|
|
If this list includes a directory named <filename>init.d</filename> and some
|
|
directories with names matching <filename>rc?.d</filename> where the
|
|
question mark is replaced by single digits, and does <emphasis>NOT</emphasis>
|
|
include a file with the name <filename>rc.M</filename>, that distribution can
|
|
be configured for modules by following the procedure listed under the title
|
|
<quote><link linkend="redhat" endterm="redhat.title"></link></quote>.
|
|
</para>
|
|
</listitem>
|
|
|
|
<listitem>
|
|
<para>
|
|
If this list does not include a directory named <filename>init.d</filename> but
|
|
includes a file named <filename>rc.M</filename> then that distribution can
|
|
be configured for modules by following the procedure listed under the title
|
|
<quote><link linkend="slackware" endterm="slackware.title"></link></quote>.
|
|
</para>
|
|
</listitem>
|
|
|
|
<listitem>
|
|
<para>
|
|
If this list matches neither of the above criteria, then the
|
|
distribution has a boot script not covered by this HowTo. In that case,
|
|
you are invited to contact the author of this document for advice.
|
|
</para>
|
|
</listitem>
|
|
|
|
</orderedlist>
|
|
|
|
</sect2>
|
|
|
|
</sect1>
|
|
|
|
</article>
|