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
When Linux-2.1 first appeared, it changed something that broke the old insmod. This has been fixed, and the new modutils can handle them. It also works with the Linux-2.0, so it's worth upgrading this first. However, if you have an OLD CDROM, you should expect to fix it.
This package adds /sbin/kerneld, and support for modules. Un-tar it in /usr/src, and follow the instructions (make install).
The documentation says to add depmod -a to an rc file, so that it is run every time you boot, but this isn't necessary, and takes several seconds. You only need to run it once, just after installing a new kernel. It needs to have the proper kernel actually running, and it sets up the files that you need during rc.d (boot time), eg the rc.inet1 script may need the ne.o module to drive the NE2000 ethernet card. The easiest way is to reboot, run depmod -a and reboot. It creates /lib/modules/2.1.42/modules.dep
This comes with modutils 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. Once kerneld is running, it will automatically load (and unload) modules on-demand, ie when you use them. It needs /etc/modules.conf as a configuration file.
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!
If you use Debian, make sure that /etc/modules contains the word auto (and not much else).
/etc/conf.modules defines any aliases needed by the system, and options that the modules need to know such as device addresses, which 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, I'm not sure but I think it tickles the IO_PORT and the IRQ laughs.
alias eth0 ne options ne io=0x300
The 2 lines above is my /etc/conf.modules file (two thirds of it anyway). However Debian (in it's personable manner) tries to make it more complicated, by adding lots of path lines, that tell depmod -a, and kerneld where to look for files. This isn't necessary, and has been badly done. Edit the file, add the work "keep" to the top of the file (before any path line), and comment out all the other lines. Then you will be running on the defaults. (( note this may have changed, but you might be running an old debian ))
In particular, the duplication that happens, with the "current" link, causes depmod -a to report "unresolved symbols", and you end up with a zero size modules.dep file, and a non-working modules sub-system.
However, Debian is still young, and the developers are trying to make a system that doesn't need you to edit any configuration files. Until they succeed, you will have to navigate more files, and put the correct values into them. Simpler, but more complicated.
I did have problems with SCSI modules. The documentation
alias scsi_hostadapter aha1542 but that didn't work
(and took up hours of source browsing), however the syslog
error messages gave me a clue, and I currently have no problems with:
alias block-major-11 aha1542Note: after editing /etc/conf.modules, remember to tell kerneld to re-read the file, by sending it a HUP signal. Use ps to find the PID and say
kill -HUP 99where 99 is the correct PID. You have to be process's owner, or root to do that.
In my case, the IO_ADDR and IRQ's are automatically groped by the module, because my card is at standard addresses. See Issue-One.
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 a new kernel.
It creates the file /lib/modules/2.0.0/modules.dep, which you should not edit. If it is zero size, kerneld won't work. NOTE: Since you aren't using version 2.0.0, you can try clicking /lib/modules/current/modules.dep or /lib/modules/, or simply go to a login shell and look from there.
You should not need to use this command, but it
helps whilst getting the other configurations sorted.
A close alternative is
modprobe See above
for the man page URL.
It loads the named module, into a running kernel. Since kerneld didn't load the module, kerneld won't unload it. When you have the device working, get it to work with kerneld, and remove all insmod lines from your scripts.
Note the difference: if you specify the filename, you must specify the FULL filename, with the .o You would do that, if depmod -a failed, and insmod didn't have the modules.dep file to convert the alias. When removing, you don't specify the .o because the kernel knows the modules name! Confused? Keep trying!
modprobe is like insmod, but clever with
dependencies. Again you shouldn't need it, as
is the way to go, but it sometimes helps.
You can specify command line options to insmod, which may help when specifying device addresses or options not listed in /etc/conf.modules
lsmod, lists the modules currently loaded in the kernel. It outputs something like:
Module Size Used by lp 6424 0 (unused) ne 5456 1 (autoclean) 8390 5468 0 (autoclean) [ne]
It's how you know that the (old) mount command is
outputting the wrong diagnostic, when it tells you
that "iso9660 (isofs) is not a valid filesystem type".
You can also use try
which outputs the same, but without the header line.
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. Remember to omit the .o
/usr/src/linux/.config is the output from running make menuconfig, check that it includes:
CONFIG_MODULES=y CONFIG_MODVERSIONS=y CONFIG_KERNELD=y
Now that it works, you are saving kernel memory. A module that you don't use at all, doesn't get loaded, and if you only use the PPP module for half the time, it's only loaded when you need it.
The pedantic would point out that each module gets loaded onto a 4K page boundry, so that's costing you an average of 2K per module. I just pointed it out, does that make me ...
Modules makes it easier to reconfigure your system. If you change ethernet card to new type, you don't have to regenerate the entire kernel, just compile the new module, and load it.
When you first use a device, eg when /etc/rc.d/rc.inet1 first attempts to configure the eth0 card, it will get auto-loaded by kerneld.
When you connect using PPP, the ppp.o module gets loaded. A few minutes after disconnect, it gets auto un-loaded. There is some discussion about saving the "state" of a device, but most modules don't need it.
Oh dear, go through the list again.
Remember that modules are modular, and if the compilation blows up during a module, try configuring the driver as always in, or never in. Most modules have been tested in 100's of different circumstances, but occasionally compilation bugs creep in.
During system boot, /sbin/kerneld has to be started before any script uses a module. EG if the network card is configured by /etc/rc.d/rc.inet1 or /etc/init.d/network, but the (NE2000) ne.o module isn't loaded (because kerneld isn't there to load it for you), that script will fail. The answer is to ensure that the module gets loaded by kerneld when needed, and that kerneld is started before it is needed!
This may be made more confusing (with an older Debian), by the fact that /etc/init.d/network isn't called from /etc/rc2.d/ (where it should be), or from /etc/rc.boot/ (which arguably shouldn't exist), but directly from /etc/init.d/boot. In addition "network" is a terrible name for the file, it should be called "rc.eth0" or something, since there are several files necessary for the network.
In addition Debian doesn't start /sbin/kerneld from /etc/rc2.d/S12kerneld (where it arguably should), but from /etc/init.d/boot which calls /etc/init.d/modules, which reads /etc/modules (which should contain the word "auto").
It took me ages to track that through, frankly some
of these sub-systems are way too complex, and lack
direction, other than being similar to other systems
which are way too complex. If it gets any worse,
I think I'll write a cut-down version for
'Bare-Metal-Raven'. You would have to maintain it manually,
and re-configure it with an editor for _your_ system. Now that
mc contains a usable editor, (and you don't have to use
vi), that is increasingly accessible. It's still
more complicated than 'plug-in-and-go', but sometimes
the obvious is not that difficult, and probably faster.