Previous Next Table of Contents

4. Modules

You get to recompile all the modules with every new kernel release. It may be possible to keep them across versions, but it is cleaner to recompile every time. See /lib/modules/2.0.0/*

If you have a binary module, eg from a thrid party supplier, you want to compile the kernel with CONFIG_MODVERSIONS=y, so that the kernel will try to adjust for different versions.

It is possible to pre-load modules to a ram disk, that is how some distributions boot from CDROM, but you probably don't do it.

Modules get loaded after the kernel has booted, by commands (insmod), or automatically (kerneld). They must reside on a readable disk, and kerneld must have the correct map. To make this work you must have installed the correct modules package and configured it.

4.1 modules-1.3.69f

This package adds /sbin/kerneld, and support for modules. Don't worry about the 1.3.69f label (unless a more recent version is available), that was the time when the previous version became out of date. Linux-2.0 is a progression from 1.3. Version 1.3.57 is semi-usable, but a sign that your distribution isn't totally updated.

Un-tar it in /usr/src, and follow the instructions.

4.2 /sbin/kerneld

This comes with modules-1.3.69f. It cleverly detects when the kernel attempts to use a module that isn't loaded, and automatically loads it for you.

You will need to edit /etc/rc.S, or some other system startup file, so that /sbin/kerneld is started before the first module is needed. The documentation says to add depmod -a to an rc file, but this isn't necessary, and takes several seconds.

I start kerneld after the fsck stuff, before the mount -avt nonfs line. It doesn't need an ampersand, because the designer guessed that someone would forget!

4.3 /etc/conf.modules

This file defines any aliases needed by the system, and options that you used to pass on the LILO line. I have an ne2000 ethernet card, so mine contains the following two lines. If you have two cards, you would have something similar. Note that 'grope-ing' the IO_ADDR, is not always "safe", and it only takes a minute to get it right. The IRQ is still groped.

        alias eth0 ne
        options ne io=0x300

        # alias eth1 de620
        # options lp irq=7 
        # alias char-major-14 sound

4.4 depmod -a

You need to run this command ONCE, every time you install a new kernel version. It does get some information from the running kernel, so it is best to reboot with the new kernel, then run this command.

You can run it before rebooting, with the version number, eg depmod -a 2.0.0 Then it knows which directory to look in, and where to place it's output file. Just to be safe, run at again after rebooting.

It creates the file /lib/modules/2.0.0/modules.dep, which you should not edit.

4.5 insmod

You should not need to use this command, but it helps whilst getting the other configurations sorted. It loads the named module, into a running kernel. Since kerneld didn't load it, kerneld won't unload it. When you have it working, get it to work with kerneld, and remove all insmod lines from your scripts.

rmmod name removes a module from the kernel. Again you don't need it in scripts. It will only mess up other scripts that still need that module.

4.6 lsmod

lsmod, lists the modules currently loaded in the kernel. It's how you know that the mount command is outputting the wrong diagnostic, when it tells you that iso9660 (isofs) is not a valid filesystem type. You can also use cat /proc/modules.

4.7 linux/.config

This is the output from running make menuconfig, check that it includes:

        CONFIG_MODULES=y
        CONFIG_MODVERSIONS=y
        CONFIG_KERNELD=y

4.8 Still not working?

Oh dear, go through the list again.

Remember that modules are modular, and if the compilation blows up during a module, try configuring it always in, or never in. Most modules have been tested in 100's of different circumstances, but occasionally bugs creep in.


Previous Next Table of Contents