home *** CD-ROM | disk | FTP | other *** search
/ Freelog Special Edition 1: Linux / CD1.iso / doc / HOWTO / mini / Kerneld < prev    next >
Text File  |  1998-10-14  |  36KB  |  939 lines

  1.  
  2.                               KERNELD MINI-HOWTO
  3.                                        
  4.    
  5.    
  6.    Version 1.7, last updated: July 19, 1997 by Henrik Storner
  7.    (storner@osiris.ping.dk)
  8.      _________________________________________________________________
  9.    
  10. Introduction
  11.  
  12.    
  13.    
  14.    This document explains how you can use the kerneld function in the
  15.    Linux kernels. It describes
  16.      * what is kerneld
  17.      * why do I want to use it
  18.      * how to get the necessary pieces
  19.      * how to set them up
  20.      * how to tell kerneld about modules it doesn't know
  21.      * how to spy on kerneld (can be useful in setting it up).
  22.      * special kerneld uses
  23.      * Common problems and weirdness
  24.        
  25.    
  26.    
  27.    The latest released version of this document can be found at
  28.    http://eolicom.olicom.dk/~storner/kerneld-mini-HOWTO.html. Between
  29.    releases of the mini-HOWTO you can find updates on my unstructured
  30.    list of changes at http://eolicom.olicom.dk/~storner/kern.html
  31.    
  32. Credits
  33.  
  34.    
  35.    
  36.    If you see things in this document that are wrong, please send me a
  37.    note about it. The following people have contributed to this
  38.    mini-HOWTO at some point:
  39.      * Bjorn Ekwall <bj0rn@blox.se>
  40.      * Ben Galliart <bgallia@luc.edu>
  41.      * Cedric Tefft <cedric@earthling.net>
  42.      * Brian Miller <bmiller@netspace.net.au>
  43.      * James C. Tsiao <jtsiao@madoka.jpl.nasa.gov>
  44.        
  45.    
  46.    
  47.    I much appreciate the encouragement and suggestions sent to me by
  48.    readers of the mini-HOWTO.
  49.    
  50.    
  51.      _________________________________________________________________
  52.    
  53. What is kerneld ?
  54.  
  55.    
  56.    
  57.    kerneld is a feature introduced during the 1.3 development kernels by
  58.    Bjorn Ekwall. It is included with all of the 2.0 and 2.1 kernels. It
  59.    allows kernel "modules" - i.e. device drivers, network drivers,
  60.    filesystems - to be loaded automatically when they are needed, rather
  61.    than having to do it manually with modprobe or insmod.
  62.    
  63.    And for the more amusing aspects, although these are not (yet ?)
  64.    integrated with the standard kernel:
  65.      * It can be setup to run a user-program instead of the default
  66.        screen blanker, thus letting you use any program as a
  67.        screen-saver.
  68.      * Similar to the screen-blanker support, you can also change the
  69.        standard console "beep" into something completely different ...
  70.        
  71.    
  72.    
  73.    kerneld consists of two separate entities:
  74.      * Support in the Linux kernel for sending requests to a daemon that
  75.        a module is needed for a certain task.
  76.      * A user-level daemon that can figure out what modules must be
  77.        loaded to fulfill the request from the kernel.
  78.        
  79.    
  80.    
  81.    Both pieces must be working for the kerneld support to function - it
  82.    is not enough that only one or the other has been setup.
  83.    
  84.    
  85.      _________________________________________________________________
  86.    
  87. Why do I want to use it ?
  88.  
  89.    
  90.    
  91.    There are some good reasons for using kerneld. The ones I will mention
  92.    are mine - others may want to use it for other reasons.
  93.      * If you have to build kernels for several systems that only differ
  94.        slightly - different kind of network card, for instance - then you
  95.        can build a single kernel and some modules, instead of having to
  96.        build individual kernels for each system.
  97.      * Modules are easier for developers to test - you don't need to
  98.        reboot the system to load and unload the driver. (This applies to
  99.        all modules, not just kerneld-loaded ones).
  100.      * It cuts down on the kernel memory usage, meaning you have more
  101.        memory available for applications. Memory used by the kernel is
  102.        *never* swapped out, so if you have 100Kb worth of unused drivers
  103.        compiled into your kernel, they are simply wasting RAM.
  104.      * Some of the things I use - the ftape floppy-tape driver, for
  105.        instance, or iBCS - are only available as modules. But I don't
  106.        want to bother with loading and unloading them whenever I need
  107.        them.
  108.      * People making Linux distributions don't have to build 284
  109.        different boot images - each user loads the drivers he needs for
  110.        just his hardware. This is used e.g. by RedHat 4.0 in their
  111.        installation.
  112.        
  113.    
  114.    
  115.    Of course, there are also reasons why you may not want to use it - you
  116.    may prefer to have just one kernel image file with all of your drivers
  117.    built in. In that case, you are reading the wrong document.
  118.    
  119.    
  120.      _________________________________________________________________
  121.    
  122. Where can I pick up the necessary pieces ?
  123.  
  124.    
  125.    
  126.    The support in the Linux kernel was introduced with Linux 1.3.57. If
  127.    you have an earlier kernel version, you will need to upgrade if you
  128.    want the kerneld support. All of the major Linux ftp sites carry the
  129.    kernel sources - I recommend that you upgrade to the latest stable
  130.    kernel release, 2.0, now at patch-level 29:
  131.   ftp://sunsite.unc.edu/pub/Linux/kernel/v2.0/linux-2.0.29.tar.gz
  132.   ftp://tsx-11.mit.edu/pub/linux/sources/system/v2.0/linux-2.0.29.tar.gz
  133.   ftp://ftp.funet.fi/pub/Linux/PEOPLE/Linus/v2.0/linux-2.0.29.tar.gz
  134.  
  135.    
  136.    
  137.    The user-level daemon is included with the modules-1.2.8 package, and
  138.    with the newer modules-2.0 package. These are normally available from
  139.    the same place as the kernel sources, but the official locations
  140.    include:
  141.   ftp://sunsite.unc.edu/pub/Linux/kernel/v2.0/modules-2.0.0.tar.gz
  142.   ftp://tsx-11.mit.edu/pub/linux/sources/sbin/modules-2.0.0.tar.gz
  143.   ftp://ftp.funet.fi/pub/Linux/tools/modules-2.0.0.tar.gz
  144.  
  145.    
  146.    
  147.    NOTE: If you want to try module-loading with the latest 2.1
  148.    _development_ kernels, you should use the latest modutils-
  149.    (NOT modules-) package. But see below about the problems with modules
  150.    and 2.1 kernels.
  151.    
  152.    
  153.      _________________________________________________________________
  154.    
  155. How do I set it up ?
  156.  
  157.    
  158.    
  159.    First get the necessary parts: A suitable kernel and the latest
  160.    modules-utilities. Then you should install the modules-utilities.
  161.    Pretty simple - just unpack the sources and run _make install_. This
  162.    compiles and installs the following programs in /sbin: genksysm,
  163.    insmod, lsmod, modprobe, depmod, kerneld. I recommend that you add
  164.    some lines to your startup-scripts to do some necessary setup whenever
  165.    you boot Linux. Add the following lines to your /etc/rc.d/rc.S file
  166.    (if you are running Slackware), or to /etc/rc.d/rc.sysinit (if you are
  167.    running SysVinit, i.e. Debian, RedHat, Caldera):
  168.         # Start kerneld - this should happen very early in the
  169.         # boot process, certainly BEFORE you run fsck on filesystems
  170.         # that might need to have disk drivers autoloaded
  171.         if [ -x /sbin/kerneld ]
  172.         then
  173.                 /sbin/kerneld
  174.         fi
  175.  
  176.         # Your standard fsck commands go here
  177.         # And you mount command to mount the root fs read-write
  178.  
  179.         # Update kernel-module dependencies file
  180.         # Your root-fs MUST be mounted read-write by now
  181.         if [ -x /sbin/depmod ]
  182.         then
  183.                 /sbin/depmod -a
  184.         fi
  185.  
  186.    
  187.    
  188.    The first part starts kerneld itself.
  189.    
  190.    The second part calls 'depmod -a' at startup. The depmod program
  191.    builds a list of all available modules and analyzes their
  192.    inter-dependencies, so it knows if one module needs to have another
  193.    loaded before it will itself load.
  194.    
  195.    _NOTE_: Recent versions of kerneld as an option links with the GNU dbm
  196.    library, libgdbm. If you enable this when building the
  197.    module-utilities, _kerneld will not start if libgdbm is not available_
  198.    which may well be the case if you have /usr on a separate partition
  199.    and start kerneld before /usr is mounted. The recommended solution is
  200.    to move libgdbm from /usr/lib to /lib, or link kerneld statically.
  201.    
  202.    Next, unpack the kernel sources, configure and build a kernel to your
  203.    liking. If you have never done this before, you should definitely read
  204.    the README file at the top level of the Linux sources. When you run
  205.    _make config_ to configure the kernel, you should pay attention to
  206.    some questions that appear early on:
  207.   Enable loadable module support (CONFIG_MODULES) [Y/n/?] Y
  208.  
  209.    
  210.    
  211.    You need to select the loadable module support, or there will be no
  212.    modules for kerneld to load! Just say Yes.
  213.   Kernel daemon support (CONFIG_KERNELD) [Y/n/?] Y
  214.  
  215.    
  216.    
  217.    This, of course, is also necessary. Then, a lot of the things in the
  218.    kernel can be built as modules - you will see questions like
  219.   Normal floppy disk support (CONFIG_BLK_DEV_FD) [M/n/y/?]
  220.  
  221.    
  222.    
  223.    where you can answer with an 'M' for 'Module'. Generally, only the
  224.    drivers necessary for you to boot up your system - the harddisk
  225.    driver, the driver for the root filesystem - should be built into the
  226.    kernel; the rest can be built as modules.
  227.    
  228.    When you have gone through the 'make config', run 'make dep', 'make
  229.    clean', 'make zImage' or 'make zlilo', 'make modules' and 'make
  230.    modules_install'.
  231.    
  232.    Phew.
  233.    
  234.    The 'make zImage' puts the new kernel image in the file
  235.    arch/i386/boot/zImage. You will need to copy it where you keep your
  236.    boot-image, or install it in LILO afterwards.
  237.    
  238.    For more information about configuring, building and installing your
  239.    own kernel, check out the Kernel-HOWTO posted regularly to
  240.    comp.os.linux.answers, and available from sunsite.unc.edu in
  241.    /pub/Linux/docs/HOWTO .
  242.    
  243.    
  244.      _________________________________________________________________
  245.    
  246. Trying out kerneld
  247.  
  248.    
  249.    
  250.    Now reboot with the new kernel. When the system comes back up, you can
  251.    run a 'ps -ax', and you should see a line for kerneld:
  252.     PID TTY STAT  TIME COMMAND
  253.      59  ?  S     0:01 /sbin/kerneld
  254.  
  255.    
  256.    
  257.    One of the nice things with kerneld is that once you have the kernel
  258.    and the daemon installed, very little setup is needed. For a start,
  259.    try using one of the drivers that you built as a module - it is more
  260.    likely than not that it will work without further configuration. I
  261.    build the floppy driver as a module, so I could put a DOS floppy in
  262.    the drive and
  263.   osiris:~ $ mdir a:
  264.    Volume in drive A has no label
  265.    Volume Serial Number is 2E2B-1102
  266.    Directory for A:/
  267.  
  268.   binuti~1 gz       1942 02-14-1996  11:35a binutils-2.6.0.6-2.6.0.7.diff.gz
  269.   libc-5~1 gz      24747 02-14-1996  11:35a libc-5.3.4-5.3.5.diff.gz
  270.           2 file(s)        26689 bytes
  271.  
  272.    
  273.    
  274.    So the floppy driver works - it gets loaded automatically by kerneld
  275.    when I try to use the floppy disk.
  276.    
  277.    To see that the floppy module is indeed loaded, you can run
  278.    /sbin/lsmod which lists all currently loaded modules:
  279.   osiris:~ $ /sbin/lsmod
  280.   Module:        #pages:  Used by:
  281.   floppy            11    0 (autoclean)
  282.  
  283.    
  284.    
  285.    The "(autoclean)" means that the module will automatically be removed
  286.    by kerneld when it has not been used for more than one minute. So the
  287.    11 pages of memory (= 44kB, one page is 4 kB) will only be used while
  288.    I access the floppy drive - if I don't use the floppy for more than a
  289.    minute, they are freed. Quite nice, if you are short of memory for
  290.    your applications!
  291.    
  292.    
  293.      _________________________________________________________________
  294.    
  295. How does kerneld know what module to load ?
  296.  
  297.    
  298.    
  299.    Although kerneld comes with builtin knowledge about the most common
  300.    types of modules, there are situations where kerneld will not know how
  301.    to handle a request from the kernel. This is the case with things like
  302.    CD-ROM drivers or network drivers, where there are more than one
  303.    possible module that can be loaded.
  304.    
  305.    The requests that the kerneld daemon gets from the kernel is for one
  306.    of the following items:
  307.      * a block-device driver
  308.      * a character-device driver
  309.      * a binary format
  310.      * a tty line discipline
  311.      * a filesystem
  312.      * a network device
  313.      * a network service (e.g. rarp)
  314.      * a network protocol (e.g. IPX)
  315.        
  316.    
  317.    
  318.    kerneld determines what module should be loaded by scanning the
  319.    configuration file _/etc/conf.modules_ There are two kinds of entries
  320.    in this file: Paths (where the module-files are located), and aliases
  321.    (what module should be loaded). If you don't have this file already,
  322.    you could create it by running
  323.   /sbin/modprobe -c | grep -v '^path' >/etc/conf.modules
  324.  
  325.    
  326.    
  327.    If you want to add yet another "path" directive to the default paths,
  328.    you _must include all the "default" paths as well_, since a path
  329.    directive in /etc/conf.modules will _replace _all the ones that
  330.    modprobe knows by default!
  331.    
  332.    Normally you don't want to add any paths by your own, since the
  333.    built-in set should take care of all "normal" setups (and then
  334.    some...), I promise!
  335.    
  336.    On the other hand, if you just want to add an alias or an option
  337.    directive, your new entries in /etc/conf.modules will be _added_ to
  338.    the ones that modprobe already knows. If you should _redefine_ an
  339.    alias or an option, your new entries in /etc/conf.modules will
  340.    override the built-in ones.
  341.    
  342.   Block devices
  343.   
  344.    
  345.    
  346.    If you run '/sbin/modprobe -c', you will get a listing of the modules
  347.    that kerneld knows about, and what requests they correspond to. For
  348.    instance, the request that ends up loading the floppy driver is for
  349.    the block-device that has major number 2:
  350.   osiris:~ $ /sbin/modprobe -c | grep floppy
  351.   alias block-major-2 floppy
  352.  
  353.    
  354.    
  355.    Why block-major-2 ? Because the floppy devices /dev/fd* use major
  356.    device 2 and are block devices:
  357.   osiris:~ $ ls -l /dev/fd0 /dev/fd1
  358.   brw-rw-rw-   1 root     root       2,   0 Mar  3  1995 /dev/fd0
  359.   brw-r--r--   1 root     root       2,   1 Mar  3  1995 /dev/fd1
  360.  
  361.   Character devices
  362.   
  363.    
  364.    
  365.    Character devices are dealt with in a similar way. E.g. the ftape
  366.    floppy tape driver sits on major-device 27:
  367.   osiris:~ $ ls -lL /dev/ftape
  368.   crw-rw----   1 root     disk      27,   0 Jul 18  1994 /dev/ftape
  369.  
  370.    
  371.    
  372.    However, kerneld does not by default know about the ftape driver - it
  373.    is not listed in the output from '/sbin/modprobe -c'.
  374.    
  375.    So to setup kerneld to load the ftape driver, I must add a line to the
  376.    kerneld configuration file, /etc/conf.modules:
  377.   alias char-major-27 ftape
  378.  
  379.   Network devices
  380.   
  381.    
  382.    
  383.    You can also use the device name instead of the 'char-major-xxx' /
  384.    'block-major-yyy' setup. This is especially useful for network
  385.    drivers. E.g. a driver for an ne2000 netcard acting as eth0 would be
  386.    loaded with
  387.   alias eth0 ne
  388.  
  389.    
  390.    
  391.    If you need to pass some options to the driver - e.g. to tell the
  392.    module about what IRQ the netcard is using, you add an 'options' line:
  393.   options ne irq=5
  394.  
  395.    
  396.    
  397.    This will cause kerneld to load the NE2000 driver with the command
  398.   /sbin/modprobe ne irq=5
  399.  
  400.    
  401.    
  402.    Of course, the actual options available are specific to the module you
  403.    are loading.
  404.    
  405.   Binary formats
  406.   
  407.    
  408.    
  409.    Binary formats are handled in a similar way. Whenever you try to run a
  410.    program that the kernel does not know how to load, kerneld gets a
  411.    request for "binfmt-xxx", where xxx is a number determined from the
  412.    first few bytes of the executable. So, the kerneld configuration to
  413.    support loading the binfmt_aout module for ZMAGIC (a.out) executables
  414.    is
  415.   alias binfmt-267 binfmt_aout
  416.  
  417.    
  418.    
  419.    since the magic number (see /etc/magic) for ZMAGIC files is 267. (If
  420.    you check /etc/magic, you will see the number 0413, but /etc/magic
  421.    uses octal numbers where kerneld uses decimal, and octal 413 = decimal
  422.    267). There are actually three slightly different variants of a.out
  423.    executables (NMAGIC, QMAGIC and ZMAGIC), so for full support of the
  424.    binfmt_aout module we need
  425.   alias binfmt-264 binfmt_aout  # pure executable (NMAGIC)
  426.   alias binfmt-267 binfmt_aout  # demand-paged executable (ZMAGIC)
  427.   alias binfmt-204 binfmt_aout  # demand-paged executable (QMAGIC)
  428.  
  429.    
  430.    
  431.    a.out, Java and iBCS binary formats are recognized automatically by
  432.    kerneld, without any configuration.
  433.    
  434.   Line disciplines (slip, cslip and ppp)
  435.   
  436.    
  437.    
  438.    Line disciplines are requested with "tty-ldisc-x", with 'x' being
  439.    usually 1 (for SLIP) or 3 (for PPP). Both of these are known by
  440.    kerneld automatically.
  441.    
  442.    Speaking of ppp, if you want kerneld to load the bsd_comp data
  443.    compression module for ppp, then you must add the following two lines
  444.    to your /etc/conf.modules:
  445.   alias tty-ldisc-3 bsd_comp
  446.   alias ppp0 bsd_comp
  447.  
  448.   Network protocol families (IPX, AppleTalk, AX.25)
  449.   
  450.    
  451.    
  452.    Some network protocols can be loaded as modules as well. The kernel
  453.    asks kerneld for a protocol family (e.g. IPX) with a request for
  454.    "net-pf-X" where X is a number indicating what family is wanted. E.g.
  455.    net-pf-3 is AX.25, net-pf-4 is IPX and net-pf-5 is AppleTalk. (These
  456.    numbers are determined by the AF_AX25, AF_IPX etc. definitions in the
  457.    linux source file include/linux/socket.h). So to autoload the IPX
  458.    module, you would need an entr like this in /etc/conf.modules:
  459.   alias net-pf-4 ipx
  460.  
  461.    
  462.    
  463.    See also the section below on common problems for information about
  464.    how you can avoid some annoying boot-time messages related to
  465.    undefined protocol families.
  466.    
  467.   File systems
  468.   
  469.    
  470.    
  471.    kerneld requests for filesystems are simply the name of the filesystem
  472.    type. A common use of this would be to load the isofs module for
  473.    CD-ROM filesystems, i.e. filesystems of type "iso9660":
  474.   alias iso9660 isofs
  475.  
  476.    
  477.    
  478.    
  479.      _________________________________________________________________
  480.    
  481. Devices requiring special configuration
  482.  
  483.    
  484.    
  485.    Some devices require a bit on configuration beyond the normal aliasing
  486.    of e.g. a device to a module.
  487.      * Character devices on major number 10: The miscellaneous devices
  488.      * SCSI devices
  489.      * Devices that require special initialization
  490.        
  491.    
  492.    
  493.    
  494.   char-major-10 : Mice, watchdogs and randomness
  495.   
  496.    
  497.    
  498.    Hardware devices are usually identified through their major device
  499.    numbers, e.g. ftape is char-major-27. However, if you look through the
  500.    entries in /dev for char major 10, you will see that this is a bunch
  501.    of very different devices, including
  502.      * Mice of various sorts (bus mice, PS/2 mice)
  503.      * Watchdog devices
  504.      * The kernel 'random' device
  505.      * APM (Advanced Power Management) interface
  506.        
  507.    
  508.    
  509.    Obviously, these devices are controlled by several different modules,
  510.    not a single one. Therefore, the kerneld configuration for these
  511.    _misc. devices_ use the major number _and_ the minor number:
  512.         alias char-major-10-1 psaux     # For PS/2 mouse
  513.         alias char-major-10-130 wdt     # For WDT watchdog
  514.  
  515.    
  516.    
  517.    You need a kernel version 1.3.82 or later to use this; earlier
  518.    versions do not pass the minor number to kerneld, making it impossible
  519.    for kerneld to figure out which of the misc. device modules to load.
  520.    
  521.   Loading SCSI drivers: The scsi_hostadapter entry
  522.   
  523.    
  524.    
  525.    Drivers for SCSI devices consist of a driver for the SCSI host adapter
  526.    (e.g. an Adaptec 1542), and a driver for the type of SCSI device you
  527.    use, e.g. a hard disk, a CD-ROM or a tape-drive. All of these can be
  528.    loaded as modules. However, when you want to access e.g. the CD-ROM
  529.    drive that is connected to the Adaptec card, the kernel and kerneld
  530.    only knows that it needs to load the sr_mod module in order to support
  531.    SCSI CD-ROM's - it does not know what SCSI controller the CD-ROM is
  532.    connected to, and hence does not know what module to load to support
  533.    the SCSI controller.
  534.    
  535.    To resolve this, you can add an entry for the SCSI driver module to
  536.    your /etc/conf.modules that tells kerneld which of the many possible
  537.    SCSI controller modules it should load:
  538.         alias scd0 sr_mod               # sr_mod for SCSI CD-ROM's ...
  539.         alias scsi_hostadapter aha1542  # ... need the Adaptec driver
  540.  
  541.    
  542.    
  543.    This only works with kernel version 1.3.82 or later.
  544.    
  545.    This works if you have only one SCSI controller. If you have more than
  546.    one, things become a little more difficult.
  547.    
  548.    In general, you cannot have kerneld load a driver for a SCSI host
  549.    adapter, if a driver for another host adapter is already installed -
  550.    you must either build both drivers into your kernel (not as modules),
  551.    or load the modules manually.
  552.    
  553.    There _is_ a way that you can have kerneld load multiple SCSI drivers.
  554.    James Tsiao came up with this idea:
  555. _   You can easily have kerneld load the second scsi driver by setting up
  556.    the dependency in your modules.dep by hand.  You just need an entry like:
  557.  
  558.       /lib/modules/2.0.30/scsi/st.o: /lib/modules/2.0.30/scsi/aha1542.o
  559.  
  560.    To have kerneld load the aha1542.o before it loads st.o.  My machine
  561.    at home is set up almost exactly like the setup above, and it works
  562.    fine for all my secondary scsi devices, including tape, cd-rom, and
  563.    generic scsi devices.  The drawback is that 'depmod -a' can't
  564.    autodetect these dependencies, so the user needs to add them by hand,
  565.    and not run 'depmod -a' on boot up.  But once it is set up, kerneld
  566.    will autoload the aha1542.o just fine.
  567. _
  568.  
  569.    
  570.    
  571.    You should be aware, that this technique only works if you have
  572.    different kinds of SCSI devices on the two controllers - e.g. hard
  573.    disks on one controller, and cd-rom drives, tapes or generic SCSI
  574.    devices on another.
  575.    
  576.   When loading a module isn't enough: The 'post-install' entry
  577.   
  578.    
  579.    
  580.    Sometimes, just loading the module is not enough to get things
  581.    working. For instance, if you have your soundcard compiled as a
  582.    module, it is often convenient to set a certain volume level. Only
  583.    problem is, the setting vanishes the next time the module is loaded.
  584.    Here is a neat trick from Ben Galliart (bgallia@luc.edu):
  585. _   The final solution required installing the setmix-0.1 package
  586.    ( ftp://sunsite.unc.edu/pub/Linux/apps/sound/mixers/setmix-0.1.tar.gz )
  587.  
  588.    And then adding the following lines to my  /etc/conf.modules :
  589.        post-install sound /usr/local/bin/setmix -f /etc/volume.conf_
  590.  
  591.    
  592.    
  593.    What this does is that after the sound module is loaded, kerneld runs
  594.    the command indicated by the 'post-install sound' entry. So the sound
  595.    module gets configured with the command '/usr/local/bin/setmix -f
  596.    /etc/volume.conf'.
  597.    
  598.    This may be useful for other modules as well, e.g. the lp module can
  599.    be configured with the tunelp program by adding
  600.         post-install lp tunelp <options>
  601.  
  602.    
  603.    
  604.    For kerneld to recognize these options, you will need a version of
  605.    kerneld that is 1.3.69f or later.
  606.    
  607.    _NOTE_: An earlier version of this mini-HOWTO mentioned a "pre-remove"
  608.    option, that might be used to run a command just before kerneld
  609.    removed a module. However, this has never worked and its use is
  610.    therefore discouraged - most likely, this option will disappear in a
  611.    future kerneld release. The whole issue of module "settings" is
  612.    undergoing some change at the moment, and may look different on your
  613.    system by the time you read this.
  614.    
  615.    
  616.      _________________________________________________________________
  617.    
  618. Spying on kerneld
  619.  
  620.    
  621.    
  622.    If you have tried everything, and just cannot figure out what the
  623.    kernel is asking kerneld to do, there is a way of seeing the requests
  624.    that kerneld receives, and hence to figure out what should go into
  625.    /etc/conf.modules: The kdstat utility.
  626.    
  627.    This nifty little program comes with the modules-package, but it is
  628.    not compiled or installed by default. To build it:
  629.   cd /usr/src/modules-2.0.0/kerneld
  630.   make kdstat
  631.  
  632.    
  633.    
  634.    Then, to make kerneld display information about what it is doing, run
  635.   kdstat debug
  636.  
  637.    
  638.    
  639.    and kerneld will start spewing messages on the console about what it
  640.    is doing. If you then try and run the command that you want to use,
  641.    you will see the kerneld requests; these can be put into
  642.    /etc/conf.modules and aliased to the module needed to get the job
  643.    done.
  644.    
  645.    To turn off the debugging, run '/sbin/kdstat nodebug' .
  646.    
  647.    
  648.      _________________________________________________________________
  649.    
  650. Special kerneld uses
  651.  
  652.    
  653.    
  654.    I knew you would ask about how to setup the screensaver module ...
  655.    
  656.    The 'kerneld/GOODIES' directory in modules-package has a couple of
  657.    kernel patches for screensaver- and consolebeep-support in kerneld;
  658.    these are not yet part of the official kernel. So you will need to
  659.    install the kernel-patches and rebuild the kernel.
  660.    
  661.    To install a patch, you use the "patch" command:
  662.   cd /usr/src/linux
  663.   patch -s -p1 </usr/src/modules-2.0.0/kerneld/GOODIES/blanker_patch
  664.  
  665.    
  666.    
  667.    Then rebuild and install the new kernel.
  668.    
  669.    When the screensaver triggers, kerneld will run the command
  670.    "/sbin/screenblanker" - this may be a shell script that runs your
  671.    favourite screensaver.
  672.    
  673.    When the kernel wants to unblank the screen, it sends a SIGQUIT signal
  674.    to the process running /sbin/screenblanker. Your shell script or
  675.    screensaver should trap this, and terminate. Remember to restore the
  676.    screen to the original text mode!
  677.    
  678.    
  679.      _________________________________________________________________
  680.    
  681. Common problems and things that make you wonder
  682.  
  683.   Why do I get "Cannot locate module for net-pf-X" messages when I run ifconfig
  684.   
  685.    
  686.    
  687.    Around kernel version 1.3.80, the networking code was changed to allow
  688.    loading protocol families (e.g. IPX, AX.25 and AppleTalk) as modules.
  689.    This caused the addition of a new kerneld request: net-pf-X, where X
  690.    is a number identifying the protocol (see
  691.    /usr/src/linux/include/linux/socket.h for the meaning of the various
  692.    numbers).
  693.    Unfortunately, ifconfig accidentally triggers these messages, so a lot
  694.    of people get a couple of messages logged when the system boots and
  695.    runs ifconfig to setup the loopback device. The messages are harmless,
  696.    and you can disable them by adding the lines
  697.         alias net-pf-3 off      # Forget AX.25
  698.         alias net-pf-4 off      # Forget IPX
  699.         alias net-pf-5 off      # Forget AppleTalk
  700.  
  701.    
  702.    
  703.    to /etc/conf.modules. Of course, if you do use IPX as a module, you
  704.    should not add a line to disable IPX.
  705.    
  706.   After starting kerneld, my system slows to a crawl when I activate my
  707.   ppp-connection
  708.   
  709.    
  710.    
  711.    There have been a couple of reports of this. It seems to be an
  712.    unfortunate interaction between kerneld and the _tkPPP script_ that is
  713.    used on some systems to setup and monitor the PPP connection - the
  714.    script apparently runs loops while running ifconfig. This triggers
  715.    kerneld, to look for the net-pf-X modules (see above), keeping the
  716.    system load high and possibly pouring lots of "Cannot locate module
  717.    for net-pf-X" messages into the system log.  There is no known
  718.    workaround, other than not use tkPPP, or change it to use some other
  719.    way of monitoring the connection.
  720.    
  721.   kerneld does not load my SCSI driver!
  722.   
  723.    
  724.    
  725.    Add an entry for the SCSI hostadapter to your /etc/conf.modules. See
  726.    the description of the scsi_hostadapter entry above.
  727.    
  728.   modprobe complains about 'gcc2_compiled' being undefined
  729.   
  730.    
  731.    
  732.    This is a bug in the module-utilities, that show up only with binutils
  733.    2.6.0.9 and later, and it is also documented in the releasenote for
  734.    the binutils. So read that. Or fetch an upgrade to the
  735.    module-utilities that fix this, e.g. modules-2.0.0.
  736.    
  737.   My sound driver keeps forgetting its settings for volume etc
  738.   
  739.    
  740.    
  741.    The settings for a module are stored inside the module itself when it
  742.    is loaded. So when kerneld auto-unloads a module, any settings you
  743.    have made are forgotten, and the next time the module loads it reverts
  744.    to the default settings.
  745.    
  746.    You can tell kerneld to configure a module by running a program after
  747.    the module has been auto-loaded. See the section above on the
  748.    'post-install' entry.
  749.    
  750.   DOSEMU needs some modules - how can I get kerneld to load those ?
  751.   
  752.    
  753.    
  754.    You cannot. None of the dosemu versions - official or development
  755.    versions - support loading the dosemu modules through kerneld.
  756.    However, if you are running kernel 2.0.26 or later, you do not need
  757.    the special dosemu modules any longer - just upgrade dosemu to 0.66.1.
  758.    
  759.   Why do I get "Ouch, kerneld timed out, message failed" messages ?
  760.   
  761.    
  762.    
  763.    When the kernel sends a request off to to kerneld, it expects to
  764.    receive an acknowledgement back within one second. If kerneld does not
  765.    send this acknowledgement, this message is logged. The request is
  766.    retransmitted, and should get through eventually.
  767.    
  768.    This usually happens on systems with a very high load - since kerneld
  769.    is a user-mode proces, it is scheduled just like any other proces on
  770.    the system. At times of high load, it may not get to run in time to
  771.    send back the acknowledgement before the kernel times out.
  772.    
  773.    If this happens even when the load is light, try restarting kerneld.
  774.    (Kill the kerneld proces, and start it again with the command
  775.    /usr/sbin/kerneld. If the problem persists, you should mail a bug
  776.    report to linux-kernel@vger.rutgers.edu, but _please_ make sure that
  777.    your version of the kernel and kerneld is up-to-date before posting
  778.    about the problem.
  779.    
  780.   mount doesn't wait for kerneld to load the filesystem module
  781.   
  782.    
  783.    
  784.    There has been a number of reports that the mount(8) command does not
  785.    wait for kerneld to load the filesystem module. lsmod does show that
  786.    kerneld loads the module, and if you repeat the mount command
  787.    immediately it will succeed. This appears to be a bug in the
  788.    module-utilities version 1.3.69f that affects some Debian users - it
  789.    can be fixed by getting a later version of the module-utilities.
  790.    
  791.   kerneld fails to load the ncpfs module
  792.   
  793.    
  794.    
  795.    You need to compile the ncpfs utilities with -DHAVE_KERNELD. See the
  796.    ncpfs Makefile.
  797.    
  798.   kerneld fails to load the smbfs module
  799.   
  800.    
  801.    
  802.    You are using an older version of the smbmount utilities. Get the
  803.    latest version (0.10 or later) from
  804.    ftp://tsx-11.mit.edu/pub/linux/filesystems/smbfs/
  805.    
  806.   I built everything as modules, and now my system cannot boot
  807.   
  808.   kerneld fails to load the root filesystem module
  809.   
  810.    
  811.    
  812.    You cannot modularize _everything_: The kernel must have enough
  813.    drivers built in for it to be able to mount your root filesystem, and
  814.    run the necessary programs to start kerneld. So you cannot modularize
  815.      * the driver for the hard disk where your root filesystem lives
  816.      * the root filesystem driver itself
  817.      * the binary format loader for init, kerneld and other programs
  818.        
  819.    
  820.    
  821.    [Actually, this is not true. Late 1.3.x and all 2.x kernels support
  822.    the use of an initial ram-disk that is loaded by LILO or LOADLIN, and
  823.    it is possible to load modules from this "disk" very early in the boot
  824.    process. How to do it is described in the Documentation/initrd.txt
  825.    file that comes with the kernel source-files.]
  826.    
  827.   kerneld will not load at boot time - complains about libgdbm
  828.   
  829.    
  830.    
  831.    Newer versions of kerneld need the GNU dbm library, libgdbm.so, to
  832.    run. Most installations have this file in /usr/lib, but you are
  833.    probably starting kerneld before the /usr filesystem is mounted. One
  834.    symptom of this is that kerneld will not start during boot-up (from
  835.    your rc-scripts), but runs fine if you start it by hand after that
  836.    system is up. The solution is to either move the kerneld startup to
  837.    after your /usr is mounted, or move the gdbm library to your root
  838.    filesystem, e.g. to /lib.
  839.    
  840.   I get "Cannot load module xxx" but I just reconfigured my kernel without xxx
  841.   support!
  842.   
  843.    
  844.    
  845.    The Slackware installation (possibly others) builds a default
  846.    /etc/rc.d/rc.modules which does an explicit modprobe on a variety of
  847.    modules. Exactly which modules get modprobed depends on the original
  848.    kernel's configuration. You have probably reconfigured your kernel to
  849.    exclude one or more of the modules that is getting modprobed in
  850.    rc.modules, thus, the error message(s). Update your rc.modules by
  851.    commenting out any modules you no longer use, or remove the rc.modules
  852.    entirely and let kerneld load the modules when they are needed.
  853.    
  854.   I rebuilt my kernel and modules, and still get messages about unresolved
  855.   symbols when booting
  856.   
  857.    
  858.    
  859.    You probably reconfigured/rebuilt your kernel and excluded some
  860.    modules. You've got some old modules that you no longer use hanging
  861.    around in the /lib/modules directory. The easiest fix is to delete
  862.    your /lib/modules/x.y.z directory and do a 'make modules_install' from
  863.    the kernel source directory again. Note that this problem only occurs
  864.    when reconfiguring your kernel without changing versions. If you see
  865.    this error when moving to a newer kernel version you've got some other
  866.    problem.
  867.    
  868.   I installed Linux 2.1 and now I cannot load ANY module
  869.   
  870.    
  871.    
  872.    Linux 2.1 is the current development kernel. As such, it should be
  873.    expected that things break from time to time. One of the things that
  874.    has changed significantly is the way modules are handled, and where
  875.    the kernel and modules are loaded into memory. Also, Richard Henderson
  876.    is now in charge of the module kernel development.
  877.    
  878.    In brief, if you want to use modules with a 2.1 kernel, you must
  879.      * read the Documentation/Changes file and see what packages need
  880.        upgrading on your system
  881.      * use the latest modutils package, available from
  882.        ftp://ftp.redhat.com/pub/alphabits/ or the mirror site at
  883.        ftp://tsx-11.mit.edu/pub/linux/packages/alphabits/
  884.        
  885.    
  886.    
  887.    I would recommend using at least kernel 2.1.29, if you want to use
  888.    modules with a 2.1 kernel.
  889.    
  890.   What about dial-on-demand networking?
  891.   
  892.    
  893.    
  894.    kerneld originally had some support for establishing dial-up network
  895.    connections on demand; trying to send packets to a network without
  896.    being connected would cause kerneld to run the _/sbin/request_route_
  897.    script to setup a PPP or SLIP connection.
  898.    
  899.    This turned out to be a bad idea. Alan Cox of Linux networking fame
  900.    wrote on the linux-kernel mailing list, that
  901.  
  902. The request-route stuff is obsolete, broken and not required [...]
  903. Its also removed from 2.1.x trees.
  904.  
  905.    Instead of using the request-route script and kerneld, I whole
  906.    heartedly advise that you install Eric Schenk's diald package,
  907.    available from http://www.dna.lth.se/~erics/diald.html
  908.    
  909.    
  910.      _________________________________________________________________
  911.    
  912. Copyright message
  913.  
  914.    
  915.    
  916.    This document is Copyright (c) Henrik Storner, 1996, 1997.
  917.    
  918.    Unless otherwise stated, Linux HOWTO documents are copyrighted by
  919.    their respective authors. Linux HOWTO documents may be reproduced and
  920.    distributed in whole or in part, in any medium physical or electronic,
  921.    as long as this copyright notice is retained on all copies. Commercial
  922.    redistribution is allowed and encouraged; however, the author would
  923.    like to be notified of any such distributions.
  924.    
  925.    All translations, derivative works, or aggregate works incorporating
  926.    any Linux HOWTO documents must be covered under this copyright notice.
  927.    That is, you may not produce a derivative work from a HOWTO and impose
  928.    additional restrictions on its distribution. Exceptions to these rules
  929.    may be granted under certain conditions; please contact the Linux
  930.    HOWTO coordinator at the address given below.
  931.    
  932.    In short, we wish to promote dissemination of this information through
  933.    as many channels as possible. However, we do wish to retain copyright
  934.    on the HOWTO documents, and would like to be notified of any plans to
  935.    redistribute the HOWTOs.
  936.    
  937.    If you have questions, please contact Greg Hankins, the Linux HOWTO
  938.    coordinator, at gregh@sunsite.unc.edu via email.
  939.