Sophie

Sophie

distrib > Mandriva > 2010.1 > x86_64 > by-pkgid > 965e33040dd61030a94f0eb89877aee8 > files > 3798

howto-html-en-20080722-2mdv2010.1.noarch.rpm

<HTML>
<HEAD>

<TITLE>
Linux Modules Installation mini-HowTo
</TITLE>

</HEAD>
<BODY>

<CENTER>

<H1>Linux Modules Installation mini-HowTo</H1>

<H2>Contents</H2>

</CENTER>

<UL>

<P><LI><A HREF="#Purpose">Purpose of this document</A>
<LI><A HREF="#Warning">WARNING</A>
<LI><A HREF="#Require">Pre-requisites</A>
<LI><A HREF="#Kernel">Recompiling the kernel for modules</A>
<LI><A HREF="#RedHat">Configuring Debian or RedHat for modules</A>
<LI><A HREF="#Slackware">Configuring Slackware for modules</A>
<LI><A HREF="#OtherDists">Configuring other distributions for modules</A>
<LI><A HREF="#Legalities">Copyright and other Legalities</A>

</UL>

<HR>

<A NAME="Purpose">
<H2>Purpose of this document</H2>

<P>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.

<P>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. 

<P><HR>

<A NAME="Warning">
<H2>WARNING</H2>

<P>I have recently used the same procedure with RedHat 4.2, but with
inconsistant 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. 

<P><HR>

<A NAME="Require">
<H2>Pre-requisites</H2>

<UL>

<P><LI>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 <B>root</B> since the majority of the steps involved can only be
undertaken by the said user.

<P><LI>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.

<P><LI>The source tree for the current kernel is assumed to be found
rooted at <B>/usr/src/linux</B> and that is also assumed to be the current
directory throughout this document at the start of any sequence of
commands to be issued. 

</UL>

<P><HR>

<A NAME="SpeedUp">
<H2>Compiler Speed-up</H2>

<P>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. 

<P>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: 

<P><CENTER>
N = [RAM in Megabytes] / 8 + 1
</CENTER>

<P>For the benefit of those with a dislike of maths, the values for the
common amounts of RAM are as follows: 

<P><CENTER>

<TABLE BORDER=2 WIDTH=50%>

<TR>
<TH WIDTH=50%>RAM size</TH>
<TH WIDTH=50%>Value to use</TH>
</TR>

<TR>
<TD ALIGN=CENTER>16 Megs</TD>
<TD ALIGN=CENTER>3</TD>
</TR>

<TR>
<TD ALIGN=CENTER>24 Megs</TD>
<TD ALIGN=CENTER>4</TD>
</TR>

<TR>
<TD ALIGN=CENTER>32 Megs</TD>
<TD ALIGN=CENTER>5</TD>
</TR>

<TR>
<TD ALIGN=CENTER>40 Megs</TD>
<TD ALIGN=CENTER>6</TD>
</TR>

<TR>
<TD ALIGN=CENTER>48 Megs</TD>
<TD ALIGN=CENTER>7</TD>
</TR>

<TR>
<TD ALIGN=CENTER>56 Megs</TD>
<TD ALIGN=CENTER>8</TD>
</TR>

<TR>
<TD ALIGN=CENTER>64 Megs</TD>
<TD ALIGN=CENTER>9</TD>
</TR>

<TR>
<TD ALIGN=CENTER>80 Megs</TD>
<TD ALIGN=CENTER>11</TD>
</TR>

<TR>
<TD ALIGN=CENTER>96 Megs</TD>
<TD ALIGN=CENTER>13</TD>
</TR>

<TR>
<TD ALIGN=CENTER>112 Megs</TD>
<TD ALIGN=CENTER>15</TD>
</TR>

<TR>
<TD ALIGN=CENTER>128 Megs</TD>
<TD ALIGN=CENTER>17</TD>
</TR>

</TABLE>

</CENTER>

<P>When you have decided on the correct number, edit the file
<B>/usr/src/linux/Makefile</B> and find the line that currently reads:

<P><PRE>
   MAKE=make
</PRE>

<P>Replace it with one reading:

<P><PRE>
   MAKE=make -j <B>N</B>
</PRE>

where <B>N</B> is the number determined above.

<P><HR>

<A NAME="Kernel">
<H2>Recompiling the kernel for modules</H2>

<P>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). 

<P>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: 

<UL>

<P><LI>Ethernet hardware drivers.

<P><LI>SCSI CD-ROM drivers.

</UL>

<P>On the other hand, there are certain driver combinations that
<B>ONLY</B> work as modules, especially combinations of two or more of the
following group: 

<UL>

<P><LI>A Parallel Printer,

<P><LI>A Parallel Port drive, such as the <B>IOMEGA</B> ZipDrive or
JazzDrive, or the <B>BackPack</B> CD-ROM drive, and

<P><LI>The <B>PLIP</B> Daemon.

</UL>

<P>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: 

<P><PRE>
   cd /usr/src/linux
   make menuconfig
   make dep clean modules modules_install zImage
</PRE>

<P>Having done that, the module dependencies need to be mapped out. This
is done with the following command: 

<P><PRE>
   depmod -a
</PRE>

<P>The new kernel now needs to be inserted in the boot chain. I am
assuming the reader is using LILO for this purpose, since this is the only
loader I have any experience with. 

<P>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 <B>/etc/lilo.conf</B> file:

<P><PRE>
   image=/usr/src/linux/arch/i386/boot/zImage
      label=new
      alias=n
      read-only
      vga=ask
      optional
</PRE>

<P>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
<B>/boot/newlinux</B> if selected, and allows one to select the video mode
it is to be booted in.

<P>Assuming the existence of the above entry in <B>/etc/lilo.conf</B> the
revised kernel is already correctly located at the end of compilation, and
it can be installed via the following command: 

<P><PRE>
   lilo
</PRE>

<P>Having done that, the reader needs to follow the further steps relevant
to their selected distribution, as follows: 

<UL>

<LI><A HREF="#RedHat">Configuring Debian or RedHat for modules</A>
<LI><A HREF="#Slackware">Configuring Slackware for modules</A>
<LI><A HREF="#OtherDists">Configuring other distributions for modules</A>

</UL>

<P><HR>

<A NAME="RedHat">
<H2>Configuring Debian or RedHat for Modules</H2>

<P>Prior to carrying out the steps listed here, the steps listed in
<A HREF="#Kernel">Recompiling the kernel for modules</A> are assumed to
have been carried out.

<P>The Debian and RedHat distributions have identical boot procedures, so
also have identical procedures for configuring modules into them.

<OL>

<P><LI>Having logged in as root, use your favourite text editor to create
a new file called <B>/etc/rc.d/init.d/modules.init</B> with the following
contents therein: 

<P><PRE>
   # Modules initialisation.
   #
   # Start up the module auto-loading daemon.
   /sbin/kerneld

   # Mount all currently unmounted auto-mounted partitions.
   /sbin/mount -a
</PRE>

<P><LI>Having created the above file, perform the following steps whilst
logged on as root:

<P><PRE>
   cd /etc/rc.d
   chmod 755 init.d/*
   cd rc3.d
   ln -s ../init.d/modules.init 05modules.init
</PRE>

</OL>

<P>The system can now be rebooted, and on doing so, it will be found that
modules are fully implemented

<P><HR>

<A NAME="Slackware">
<H2>Configuring Slackware for Modules</H2>

<P>Prior to carrying out the steps listed here, the steps listed in
<A HREF="#Kernel">Recompiling the kernel for modules</A> are assumed to
have been carried out.

<OL>

<P><LI>The file <B>/etc/rc.d/rc.M</B> needs to be edited as follows:

<OL>

<P><LI>Around line 18, there is a section reading as follows:

<P><PRE>
   # Screen blanks after 15 minutes idle time.
   /bin/setterm -blank 15
</PRE>

<P>Immediately after this, insert the following paragraph, with the usual
blank lines either side of it: 

<P><PRE>
   # Load the kernel module auto-loader.
   /sbin/kerneld
</PRE>

<P><LI>About 12 lines further down is the following:

<P><PRE>
   # if there is no /etc/HOSTNAME, fall back on this default:
</PRE>

Immediately prior to this, insert the following paragraph, again with the
usual blank lines either side of it: 

<P><PRE>
   # Mount remaining unmounted auto-mount drives.
   /sbin/mount -a
</PRE>

</OL>

<P>When those changes have been made, save the file.

</OL>

<P>No further modifications are required for Slackware.

<P><HR>

<A NAME="OtherDists">
<H2>Configuring other distributions for Modules</H2>

<P>Prior to carrying out the steps listed here, the steps listed in
<A HREF="#Kernel">Recompiling the kernel for modules</A> are assumed to
have been carried out.

<P>The precice 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 <B>/etc/rc.d</B> directory, as follows:

<P><PRE>
   cd /etc/rc.d
   ls -l *.d rc.*
</PRE>

<P>From this resulting display, you can select one of the following three
options: 

<OL>

<P><LI>If this list includes a directory named <B>init.d</B> and some
directories with names matching <B>rc?.d</B> where the question mark is
replaced by single digits, and does <B>NOT</B> include a file with the
name <B>rc.M</B>, that distribution can be configured for modules by
following the procedure listed above for the <A HREF="#RedHat">Debian and
RedHat Distributions</A>.

<P><LI>If this list does not include a directory named <B>init.d</B> but
includes a file named <B>rc.M</B> then that distribution can be configured
for modules by following the procedure listed above for the <A
HREF="#Slackware">Slackware distribution</A>. 

<P><LI>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.

</OL>

<P><HR>

<A NAME="Legalities">
<H2>Copyright and other Legalities</H2>

<P>This document is covered by the terms of the <B>GNU General Public
Licence (GPL)</B>, and all terms and limitations therein apply.

<P>The author may be contacted by email at
<A HREF="MailTo:rhw@bigfoot.com">rhw@bigfoot.com</A>.

</BODY>
</HTML>