Loadable modules

This section discusses:

What are loadable modules

The Linux kernel can be extended to have more capabilities two basic ways: When you
configure and build your kernel, if you specify a kernel feature with a y then the software to support it will be part of your kernel (the features will be "compiled into" your kernel and always using up memory). If you specify the feature with an m then the feature will be a loadable module that can come and go as you wish (and will use memory only if the module is loaded). An n means the feature will not be enabled in the kernel.

Below shows a window from configuring the kernel via make xconfig and:

linux kernel modules configuration

Using loadable modules

The file /etc/modules.conf configures which loadable modules are automatically loaded. Here is a sample:
# The Ethernet interface on this machine is an eepro100:
alias eth0 eepro100

# Automatically look for a parallel port:
alias parport_lowlevel parport_pc

# If somebody tries to use a scsi device, the adaptor is an atp870u:
alias scsi_hostadapter atp870u

# If somebody uses the usb bus, it is a usb-uhci type:
alias usb-controller usb-uhci

# The sound interface uses the i810_audio device:
alias sound-slot-0 i810_audio
Changing /etc/modules.conf: Let's say your eepro100 Ethernet device breaks and you buy a new Ethernet card that uses the tulip driver. In this case, the relevant line in /etc/modules.conf file should be changed to:
alias eth0 tulip
In most cases, when you reboot with your new Ethernet card, Red Hat's configuration manager should automatically notice a new Ethernet card is installed, and change the /etc/modules.conf file for you.

To see a list of loadable kernel modules on your system with their status:

# lsmod
Module                  Size  Used by    Not tainted
i810_audio             26408   2 (autoclean)
ac97_codec             13768   0 (autoclean) [i810_audio]
soundcore               7108   2 (autoclean) [i810_audio]
scanner                10716   0 (unused)
mousedev                5688   0 (unused)
keybdev                 2944   0 (unused)
input                   6176   0 [mousedev keybdev]
hid                    11804   0 (unused)
usb-uhci               27436   0 (unused)
usbcore                81088   1 [scanner hid usb-uhci]
To see a list of the module files:
# modprobe --list
/lib/modules/2.4.20/kernel/drivers/block/floppy.o
/lib/modules/2.4.20/kernel/drivers/block/loop.o
/lib/modules/2.4.20/kernel/drivers/char/rtc.o
/lib/modules/2.4.20/kernel/drivers/input/input.o
/lib/modules/2.4.20/kernel/drivers/input/keybdev.o
/lib/modules/2.4.20/kernel/drivers/input/mousedev.o
/lib/modules/2.4.20/kernel/drivers/net/dummy.o
/lib/modules/2.4.20/kernel/drivers/scsi/atp870u.o
/lib/modules/2.4.20/kernel/drivers/scsi/scsi_mod.o
/lib/modules/2.4.20/kernel/drivers/scsi/st.o
/lib/modules/2.4.20/kernel/drivers/sound/ac97_codec.o
/lib/modules/2.4.20/kernel/drivers/sound/i810_audio.o
/lib/modules/2.4.20/kernel/drivers/sound/soundcore.o
/lib/modules/2.4.20/kernel/drivers/usb/dc2xx.o
/lib/modules/2.4.20/kernel/drivers/usb/hid.o
/lib/modules/2.4.20/kernel/drivers/usb/scanner.o
/lib/modules/2.4.20/kernel/drivers/usb/usb-uhci.o
/lib/modules/2.4.20/kernel/drivers/usb/usbcore.o
/lib/modules/2.4.20/kernel/fs/fat/fat.o
/lib/modules/2.4.20/kernel/fs/msdos/msdos.o
/lib/modules/2.4.20/kernel/fs/vfat/vfat.o
To load a module, and any modules that it needs, use modprobe:
modprobe st
To remove a loaded module, use rmmod:
rmmod st
To get information about a module, use modinfo:
# modinfo st
filename:    /lib/modules/2.4.20/kernel/drivers/scsi/st.o
description: "SCSI Tape Driver"
author:      "Kai Makisara"
license:     "GPL"
parm:        buffer_kbs int, description "Default driver buffer size (KB; 32)"
parm:        write_threshold_kbs int, description "Asynchronous write threshold (KB; 30)"
parm:        max_buffers int, description "Maximum number of buffer allocated at initialisation (4)"
parm:        max_sg_segs int, description "Maximum number of scatter/gather segments to use (32)"
parm:        blocking_open int, description "Block in open if not ready an no O_NONBLOCK (0)"

Where to get more information

Linux Quick Reference Home
Linux Migration Home