Loadable Kernel Modules and Kerneld

Begin excerpt from kerneld mini-HOWTO

What is kerneld?

kerneld is a feature introduced in the 1.3 development kernels by Bjorn Ekwall. It allows kernel "modules" - i.e. device drivers, network drivers, filesystems - to be loaded automatically when they are needed, rather than having to do it manually with modprobe or insmod.

kerneld also has some other functions:

And for the more amusing aspects, although these are not (yet ?) integrated with the standard kernel:

kerneld consists of two separate entities:

Both pieces must be working for the kerneld support to function - it is not enough that only one or the other has been setup.


Why do I want to use it ?

There are some good reasons for using kerneld. The ones I will mention are mine - others may want to use it for other reasons.

End excerpt from kerneld mini-HOWTO


Links to necessary components

Documentation

Source Code


Installing Linux loadable modules and kerneld

  1. Build & install module utilities
         [root@bluenote modules]# tar xzf modules-2.0.0.tar.gz 
         [root@bluenote modules]# cd modules-2.0.0
         [root@bluenote modules-2.0.0]# make install
    

  2. Build & install Linux kernel with module support

  3. Build & install kernel modules
         [root@bluenote linux]# make modules
         [root@bluenote linux]# make modules_install
    
    Modules are installed in /lib/modules/`uname -r`

  4. Edit rc scripts. Add the following to /etc/rc.d/rc.S for Slackware or /etc/rc.d/rc.sysinit for Red Hat:
         # Start kerneld - this should happen very early in the
         # boot process, certainly BEFORE you run fsck on filesystems
         # that might need to have disk drivers autoloaded
         if [ -x /sbin/kerneld ]
         then
                 /sbin/kerneld
         fi
    
         .
         .
         .
    
         # Update kernel-module dependencies file
         # Your root-fs MUST be mounted read-write by now
         if [ -x /sbin/depmod ]
         then
                 /sbin/depmod -a
         fi
    

  5. Boot the new kernel

  6. Create an /etc/conf.modules file
         [root@bluenote /]# /sbin/modprobe -c | grep -v '^path' > /etc/conf.modules
    


    Loading/unloading modules manually

    Inserting modules
    insmod module_name
    modprobe module_name
    (modprobe is smarter about module dependencies)

    Remove modules
    rmmod module_name
    modprobe -r module_name
    (again modprobe is smarter about module dependencies)

    List loaded modules
    lsmod
    cat /proc/modules

    Example:
    [root@bluenote /]# lsmod
    Module:        #pages:  Used by:
    serial             7            1 (autoclean)
    binfmt_aout        1            2 (autoclean)
    [root@bluenote /]# modprobe msdos
    [root@bluenote /]# lsmod
    Module:        #pages:  Used by:
    msdos              2            0
    fat                6    [msdos] 0
    serial             7            1 (autoclean)
    binfmt_aout        1            2 (autoclean)
    [root@bluenote /]# rmmod msdos
    [root@bluenote /]# rmmod fat
    [root@bluenote /]# lsmod
    Module:        #pages:  Used by:
    serial             7            1 (autoclean)
    binfmt_aout        1            2 (autoclean)
    


    What kerneld does


    Configuring kerneld

    Options for the /etc/conf.modules file.

         keep
         parameter=value
         options module symbol=value ...
         alias module real_name
         pre-install module command ...
         install module command ...
         post-install module command ...
         pre-remove module command ...
         remove module command ...
         post-remove module command ...
    


    ifconfig messages

    Begin excerpt from kerneld mini-HOWTO

    Around kernel version 1.3.80, the networking code was changed to allow loading protocol families (e.g. IPX, AX.25 and AppleTalk) as modules. This caused the addition of a new kerneld request: net-pf-X, where X is a number identifying the protocol (see /usr/src/linux/include/linux/socket.h for the meaning of the various numbers).
    Unfortunately, ifconfig accidentally triggers these messages, so a lot of people get a couple of messages logged when the system boots and runs ifconfig to setup the loopback device. The messages are harmless, and you can disable them by adding the lines

            alias net-pf-3 off      # Forget AX.25
            alias net-pf-4 off      # Forget IPX
            alias net-pf-5 off      # Forget AppleTalk
    

    to /etc/conf.modules. Of course, if you do use IPX as a module, you should not add a line to disable IPX.

    End excerpt from kerneld mini-HOWTO


    Last Modified: 17 September 1996

    St. Louis Unix Users Group - Linux SIG