LPI Linux Certification in a Nutshell (5 page)

Read LPI Linux Certification in a Nutshell Online

Authors: Adam Haeder; Stephen Addison Schneiter; Bruno Gomes Pessanha; James Stanger

Tags: #Reference:Computers

BOOK: LPI Linux Certification in a Nutshell
3.91Mb size Format: txt, pdf, ePub
Name

modprobe

Syntax
modprobe [
options
]
module
[
symbol=value ...
]
Description

Like
insmod, modprobe
is used to
insert modules. In fact,
modprobe
is a wrapper
around
insmod
and
provides additional functionality. In addition to loading single
modules,
modprobe
has the
ability to load modules along with their prerequisites or all
modules stored in a specific directory. The
modprobe
command can also remove modules when
combined with the
-r
option.

A module is inserted with optional
symbol=value
parameters. If the module is
dependent upon other modules, they will be loaded first. The
modprobe
command determines prerequisite
relationships between modules by reading
modules.dep
at the top of the module directory
hierarchy (i.e.,
/lib/modules/2.2.5-15smp/modules.dep
).

You must be logged in as the superuser to insert
modules.

Frequently used options
-a

Load all modules. When used with the
-t
moduletype
,
all
is restricted to modules in the
moduletype
directory. This action
probes hardware by successive module-insertion attempts for a
single type of hardware, such as a network adapter (in which
case the
moduletype
would be
net
, representing
/lib/modules/
kernel-version
/
kernel/net
).
This may be necessary, for example, to probe for more than one
kind of network interface.

-c

Display a complete module configuration, including
defaults and directives found in
/etc/modules.conf
(or
/etc/conf.modules
on older systems). The
-c
option is not used with
any other options.

-l

List modules. When used with the
-t
moduletype
, list only modules in
directory
moduletype
. For example,
if
moduletype
is
net
, then modules in
/lib/modules/
kernel-version
/net
are displayed.

-r

Remove
module
, similar to
rmmod
. Multiple modules may be
specified.

-s

Direct output to syslog instead of
stdout
.

-t
moduletype

Attempt to load multiple modules found in the directory
moduletype
until a module succeeds
or all modules in
moduletype
are
exhausted. This action “probes” hardware by successive
module-insertion attempts for a single type of hardware, such
as a network adapter (in which case
moduletype
would be
net
, representing
/lib/modules/
kernel-version
/kernel/net
).

-v

Set verbose mode.

Example 1

Install the
msdos
filesystem module into
the running kernel:

#
modprobe msdos

Module
msdos
and its dependency,
fat
, will be loaded.
modprobe
determines that
fat
is needed by
msdos
when it looks through
modules.dep
. You can see
the dependency listing using
grep
:

#
grep /msdos.o: /lib/modules/2.2.5-15smp/modules.dep
/lib/modules/2.2.5-15smp/fs/msdos.o:
/lib/modules/2.2.5-15smp/fs/fat.o
Example 2

Remove
fat
and
msdos
modules from the running kernel, assuming
msdos
is not in use:

#
modprobe -r fat msdos
Example 3

Attempt to load available network modules until one
succeeds:

#
modprobe -t net
Example 4

Attempt to load all available network modules:

#
modprobe -at net
Example 5

List all modules available for use:

#
modprobe -l
/lib/modules/2.2.5-15smp/fs/vfat.o
/lib/modules/2.2.5-15smp/fs/umsdos.o
/lib/modules/2.2.5-15smp/fs/ufs.o
. . .
Example 6

List all modules in the
net
directory for
3Com network interfaces:

#
modprobe -lt net | grep 3c
/lib/modules/2.2.5-15smp/net/3c59x.o
/lib/modules/2.2.5-15smp/net/3c515.o
/lib/modules/2.2.5-15smp/net/3c509.o
/lib/modules/2.2.5-15smp/net/3c507.o
/lib/modules/2.2.5-15smp/net/3c505.o
/lib/modules/2.2.5-15smp/net/3c503.o
/lib/modules/2.2.5-15smp/net/3c501.o
Chapter 4. Change
Runlevels and Shut Down or Reboot System (Topics 101.2 and 101.3)

This Topic continues the subject of general knowledge of fundamental
PC architecture. It includes these Objectives:

Objective 2: Boot the System

Candidates should be able to guide the system through the
booting process. Weight: 3.

Objective 3: Change Runlevels and Shut Down or Reboot
System

Candidates should be able to manage the runlevel of the system.
This objective includes changing to single-user mode, shutdown, or
rebooting the system. Candidates should be able to alert users before
switching runlevel and properly terminate processes. This objective
also includes setting the default runlevel. Weight: 3.

Objective 2: Boot the System

It is the job of a boot loader, such as LILO or GRUB, to
launch the Linux kernel at boot time. In some cases, the boot loader has
to deliver information to the Linux kernel that may be required to
configure peripherals or control other behavior. This information is
called a
kernel parameter
.

Boot-time Kernel Parameters

By default, your system’s kernel parameters are set in
your boot loader’s configuration file (
/etc/lilo.conf
or
/boot/grub/menu.lst
, and
boot/grub/grub.conf
on Red Hat and some other
distributions). However, the Linux kernel also has the capability to
accept information at boot time from a kernel command-line interface.
You access the kernel command line through your installed boot loader.
When your system boots, you can interrupt the “default” boot process
when the boot loader displays and specify your desired kernel
parameters. The kernel parameters on the command line look similar to
giving arguments or options to a program during command-line
execution.

For an example, let’s say you wanted to boot with a root partition
other than your default,
/dev/hda1
.
Using LILO, you could enter the following at the
LILO
prompt:

LILO:
linux root=/dev/hda9

This command boots the kernel whose label is
linux
and overrides the default value of
/dev/hda1
to
/dev/hda9
for the
root filesystem.

On the Exam

There are far too many kernel parameters to list in this book.
Consequently, you must familiarize yourself with them in general terms
so that you can answer questions on their form. Remember that they are
specified to your boot loader as either a single item, such as
ro
, or
name=value
options such as
root=/dev/hda2
. Multiple parameters are
always separated by a space.

Introduction to Kernel Module Configuration

Modern Linux kernels are
modular
, in that modules of code
traditionally compiled into the kernel (say, a sound driver) are loaded
as needed. The modules are separate from the kernel and can be inserted
and removed by the superuser if necessary. Although parameters in the
boot loader’s configuration file and the kernel command line affect the
kernel, they do not control kernel modules.

To send parameters to a kernel module, they are inserted into the
file
/etc/modules.conf
as text (in the
past this configuration file was
/etc/conf.modules
). Common module options you may
find in your module configuration file are I/O address, interrupt, and
DMA channel settings for your sound device. This file will also probably
carry
PCMCIA driver information when installed on laptops.
Module configuration will probably be handled by your distribution’s
installation procedure but may require modifications if hardware is
added or changed later.
Example 4-1
shows a typical
/etc/modules.conf
file.

Example 4-1. A typical /etc/modules.conf file

alias parport_lowlevel parport_pc
alias eth0 8139too
alias sound-slot-0 via82cxxx_audio
post-install sound-slot-0 /bin/aumix-minimal \
-f /etc/.aumixrc -L >/dev/null 2>&1 || :
pre-remove sound-slot-0 /bin/aumix-minimal \
-f /etc/.aumixrc -S >/dev/null 2>&1 || :
alias usb-controller usb-uhci

On the Exam

Read questions that ask about kernel or module parameters
carefully. Kernel options can be passed on the kernel command line;
module options are specified in
modules.conf
.

In this example, note that an alias named
sound-slot-0
is created for the audio driver
via82cxxx_audio
. Most devices won’t
need any additional configuration, but systems with older ISA cards may
still need to pass options for I/O port, IRQ, and DMA channel settings.
In addition, some drivers may need options to specify nonstandard
settings. For example, an ISDN board used in North America will need to
specify NI1 signaling to the driver:

options hisax protocol=4 type=40
Kernel boot-time messages

As the Linux kernel boots, it gives detailed status of
its progress in the form of console messages. Modules that are loaded
also yield status messages. These messages contain important
information regarding the health and configuration of your hardware.
Generally, the kinds of messages you will see are:

  • Kernel identification

  • Memory and CPU information

  • Information on detected hardware, such as pointers (mice),
    serial ports, and disks

  • Partition information and checks

  • Network initialization

  • Kernel module output for modules that load at boot
    time

These messages are displayed on the system console at boot time
but often scroll off the screen too quickly to be read. The messages
are also logged to disk and can easily be viewed using the
dmesg
command, which displays
messages logged at the last system boot. For example, to view messages
from the last boot sequence, simply pipe the output of
dmesg
to
less
:

#
dmesg | less

It is also common to use
dmesg
to
dump boot messages to a file for later inspection or
archive, by simply redirecting the output:

#
dmesg > bootmsg.txt
Note

The kernel buffer used for log messages that
dmesg
displays is a fixed size, so it may lose
some (or all) of the boot-time messages as the kernel writes runtime
messages.

Reviewing system logs

In addition to kernel messages, many other boot-time messages
will be logged using the
syslog system. Such messages will be found in the system
logfiles such as
/var/log/messages
. For example,
dmesg
displays information on your network
adapter when it was initialized. However, the configuration and status
of that adapter is logged in
/var/log/messages
as
a result of the network startup. When examining and debugging boot
activity on your system, you need to review both kinds of information.
syslogd
, its configuration, and logfile
examination are covered in
Chapter 16
.

Other books

Justine by Marqués de Sade
Casino Moon by Peter Blauner
Darcy's Temptation by Regina Jeffers
Glory Road by Robert A Heinlein
Home Another Way by Christa Parrish
Winter's Secret by Lyn Cote
Military Daddy by Patricia Davids
Can't Stand the Heat? by Margaret Watson