<?xml version='1.0' encoding='utf-8'?>
<!-- -*- DocBook -*- -->
<chapter id="ch-modules">
<?dbhtml filename="ch-modules.html" ?>
<title>Managing the kernel modules</title>
<para>
Linux device drivers come in the form of kernel modules - object files which
may be loaded into the running kernel to extend its functionality.  The list of
currently loaded kernel modules can be obtained using the
<command>lsmod</command> command, modules may be loaded using
<command>modprobe</command>, and removed using <command>modprobe -r</command>.
The <command>depmod</command> command may be used to regenerate the list of
available modules (after installation of the new modules, for example), even
though it is pretty unlikely that you will ever need to invoke it by hand.
</para>
<para>
Normally, the devices are detected and necessary kernel modules are loaded by
<command>udev</command> during boot time.  Occasionally, one may need finer
control over the loading of kernel modules, for example to pass the additional
parameters to the module, force loading of some modules on startup, or prevent
certain module(s) from being loaded.
</para>
<para>
If some modules are not loaded automatically by <command>udev</command>, but
you would like them to be loaded during boot, it is possible to force it by
listing the names of the modules in <filename>/etc/modules</filename>.  This will
be scanned for the names of the modules (one name per line), which will then be
loaded using <command>modprobe</command>.  For example, a typical
<filename>/etc/modules</filename> might look like:
</para>
<literallayout class="monospaced">loop
sbp2
</literallayout>
<para>
To find out what parameters are accepted by a given module, you can use the
<command>modinfo</command> command, for example:
</para>
<screen>
<prompt>#</prompt> <userinput>modinfo loop</userinput>
<computeroutput>filename:       /lib/modules/3.2.0-2-686-pae/kernel/drivers/block/loop.ko
alias:          devname:loop-control
alias:          char-major-10-237
alias:          block-major-7-*
license:        GPL
depends:        
intree:         Y
vermagic:       3.2.0-2-686-pae SMP mod_unload modversions 686
parm:           max_loop:Maximum number of loop devices (int)
parm:           max_part:Maximum number of partitions per loop device (int)</computeroutput>
</screen>
<para>
To add custom arguments to the modules loaded by <command>udev</command> early
in the boot process, you need to create a custom configuration file for
<command>modprobe</command>, which <command>udev</command> uses to load the
modules.  For example, to pass an <literal>atapi_enabled=1</literal> argument
to the <literal>libata</literal> kernel module, create
<filename>/etc/modprobe.d/local.conf</filename> file with the following line:
</para>
<literallayout class="monospaced">options libata atapi_enabled=1
</literallayout>
<para>
You can use any name ending in <literal>.conf</literal> for the
configuration files in <filename>/etc/modprobe.d</filename> and put
multiple <literal>options</literal> lines in the same file.
</para>
<para>
Sometimes two different modules claim support for the same device, usually
because two slightly different versions of the device exist, requiring
different kernel modules to operate.  In such situation <command>udev</command>
loads both kernel modules, with unpredictable results.  To avoid this problem,
you can prevent any module (let's say, <literal>tulip</literal>) from loading
by creating a file containing the line:
</para>
<literallayout class="monospaced">blacklist tulip
</literallayout>
<para>
in <filename>/etc/modprobe.d</filename> directory.  See the
<command>modprobe</command> manual page (<command>man modprobe</command>) for
much more information on configuring and using modprobe.
</para>
</chapter>

