Linux Kerneld Mini HOWTO: Henrik Storner
Linux Kerneld Mini HOWTO: Henrik Storner
Linux Kerneld Mini HOWTO: Henrik Storner
Henrik Storner
[email protected]
Copyright 2000 by Linux Documentation Project
Revision History
Revision v2.0
22 May 2000
conversion from HTML to DocBook SGML.
Table of Contents
1. About the kerneld miniHOWTO................................................................................................................1
1.1. Credits...............................................................................................................................................1
2. What is kerneld?.............................................................................................................................................2
2.1. Why do I want to use it ?..................................................................................................................2
2.2. Where can I pick up the necessary pieces ?.....................................................................................2
3. How do I set it up?..........................................................................................................................................4
3.1. Trying out kerneld.............................................................................................................................5
4. How does kerneld know what module to load?...........................................................................................7
4.1. Block devices....................................................................................................................................7
4.2. Character devices..............................................................................................................................8
4.3. Network devices................................................................................................................................8
4.4. Binary formats..................................................................................................................................8
4.5. Line disciplines (slip, cslip and ppp)................................................................................................9
4.6. Network protocol families (IPX, AppleTalk, AX.25).....................................................................9
4.7. File systems.......................................................................................................................................9
5. Devices requiring special configuration.....................................................................................................10
5.1. charmajor10 : Mice, watchdogs and randomness......................................................................10
5.2. Loading SCSI drivers: The scsi_hostadapter entry........................................................................10
5.3. When loading a module isn't enough: The postinstall entry........................................................11
Notes.........................................................................................................................................13
6. Spying on kerneld.........................................................................................................................................14
7. Special kerneld uses......................................................................................................................................15
8. Common problems and things that make you wonder..............................................................................18
1.1. Credits
This document is based on an original HTML version 1.7 dated July 19, 1997 by Henrik Storner
<[email protected]> and was revised and translated to DocBook DTD by Gary Lawrence
Murphy <[email protected]> May 20, 2000.
The following people have contributed to this miniHOWTO at some point:
Bjorn Ekwall [email protected]
Ben Galliart [email protected]
Cedric Tefft [email protected]
Brian Miller [email protected]
James C. Tsiao [email protected]
If you find errors in this document, please send email to <[email protected]>. Your
comments, encouragement and suggestions are welcome and appreciated, and help ensure this guide remains
current and accurate.
2. What is kerneld?
The kerneld feature was introduced during the 1.3 development kernels by Bjorn Ekwall. It allows kernel
modules such as device drivers, network drivers and filesystems to be loaded automatically when they are
needed, rather than having to do it manually with modprobe or insmod.
And for the more amusing aspects, although these are not (yet ?) integrated with the standard kernel:
It can be setup to run a userprogram instead of the default screen blanker, thus letting you use any
program as a screensaver.
Similar to the screenblanker support, you can also change the standard console beep into something
completely different.
kerneld consists of two components:
Support in the Linux kernel for sending requests to a daemon requesting a module for a certain task.
A userspace daemon that can figure out what modules must be loaded to fulfill the request from the
kernel.
Both components must be working for the kerneld support to function; it is not enough that only one or the
other has been setup.
2. What is kerneld?
These commands may already be installed in your SysV init scripts. The first part starts kerneld itself. The
second calls depmod a at startup to build a list of all available modules and analyzes their
interdependencies. The depmod map then tells kerneld if one module needs to have another loaded before it
will itself load.
Note: Recent versions of kerneld have an option to link with the GNU gdbm library,
libgdbm. If you enable this when building the module utilities, kerneld will not start if
libgdbm is not available which may well be the case if you have /usr on a separate
partition and start kerneld before /usr is mounted. The recommended solution is to move
/usr/lib/libgdbm to /lib, or to link kerneld statically.
Next, unpack the kernel sources, configure and build a kernel to your liking. If you have never done this
before, you should definitely read the README file at the top level of the Linux sources. When you run
make xconfig to configure the kernel, you should pay attention to some questions that appear early on:
Enable loadable module support (CONFIG_MODULES) [Y/n/?] Y
You need to select the loadable module support, or there will be no modules for kerneld to load! Just say Yes.
Kernel daemon support (CONFIG_KERNELD) [Y/n/?] Y
This, of course, is also necessary. Then, a lot of the things in the kernel can be built as modules you will see
questions like
Normal floppy disk support (CONFIG_BLK_DEV_FD) [M/n/y/?]
TIME COMMAND
0:01 /sbin/kerneld
One of the nice things with kerneld is that once you have the kernel and the daemon installed, very little setup
is needed. For a start, try using one of the drivers that you built as a module; it is more likely than not that it
will work without further configuration. If I build the floppy driver as a module, I could put a DOS floppy in
the drive and type
osiris:~ $ mdir a:
Volume in drive A has no label
Volume Serial Number is 2E2B1102
Directory for A:/
binuti~1 gz
1942 02141996 11:35a binutils2.6.0.62.6.0.7.diff.gz
libc5~1 gz
24747 02141996 11:35a libc5.3.45.3.5.diff.gz
2 file(s)
26689 bytes
The floppy driver works! It gets loaded automatically by kerneld when I try to use the floppy disk.
To see that the floppy module is indeed loaded, you can run /sbin/lsmod to list all currently loaded modules:
Used by:
0 (autoclean)
The "(autoclean)" means that the module will automatically be removed by kerneld when it has not been used
for more than one minute. So the 11 pages of memory (= 44kB, one page is 4 kB) will only be used while I
access the floppy drive if I don't use the floppy for more than a minute, they are freed. Quite nice, if you are
short of memory for your applications!
If you want to add yet another path directive to the default paths, you must include all the default paths as
well, since a path directive in /etc/conf.modules will replaceall the ones that modprobe knows by
default!
Normally you don't want to add any paths by your own, since the builtin set should take care of all normal
setups (and then some...), I promise!
On the other hand, if you just want to add an alias or an option directive, your new entries in
/etc/conf.modules will be added to the ones that modprobe already knows. If you should redefine an
alias or an option, your new entries in /etc/conf.modules will override the builtin ones.
Why blockmajor2 ? Because the floppy devices /dev/fd* use major device 2 and are block devices:
osiris:~ $ ls l /dev/fd0 /dev/fd1
brwrwrw
1 root
root
2,
brwrr
1 root
root
2,
0 Mar
1 Mar
3
3
1995 /dev/fd0
1995 /dev/fd1
27,
0 Jul 18
1994 /dev/ftape
However, kerneld does not by default know about the ftape driver it is not listed in the output from
/sbin/modprobe c. So to setup kerneld to load the ftape driver, I must add a line to the kerneld
configuration file, /etc/conf.modules:
alias charmajor27 ftape
If you need to pass some options to the driver, for example to tell the module about what IRQ the netcard is
using, you must add an "options" line:
options ne irq=5
This will cause kerneld to load the NE2000 driver with the command
/sbin/modprobe ne irq=5
Of course, the actual options available are specific to the module you are loading.
Since the magic number for ZMAGIC files is 267, if you check /etc/magic, you will see the number
0413; keep in mind that /etc/magic uses octal numbers where kerneld uses decimal, and octal 413 =
decimal 267. There are actually three slightly different variants of a.out executables (NMAGIC, QMAGIC
and ZMAGIC), so for full support of the binfmt_aout module we need
4.2. Character devices
a.out, Java and iBCS binary formats are recognized automatically by kerneld, without any configuration.
See Common Problems for information about how you can avoid some annoying boottime messages related
to undefined protocol families.
You need a kernel version 1.3.82 or later to use this; earlier versions do not pass the minor number to kerneld,
making it impossible for kerneld to figure out which of the misc. device modules to load.
10
You can easily have kerneld load the second scsi driver by setting up the dependency in your
modules.dep by hand. You just need an entry like:
/lib/modules/2.0.30/scsi/st.o: /lib/modules/2.0.30/scsi/aha1542.o
To have kerneld load the aha1542.o before it loads st.o. My machine at home is set up
almost exactly like the setup above, and it works fine for all my secondary scsi devices,
including tape, cdrom, and generic scsi devices. The drawback is that depmod a can't
autodetect these dependencies, so the user needs to add them by hand, and not run depmod
a on boot up. But once it is set up, kerneld will autoload the aha1542.o just fine.
You should be aware, that this technique only works if you have different kinds of SCSI devices on the two
controllers, for example, hard disks on one controller, and cdrom drives, tapes or generic SCSI devices on
another.
The final solution required installing the setmix package and then adding the following line
to my /etc/conf.modules:
postinstall sound /usr/local/bin/setmix f /etc/volume.conf
What this does is that after the sound module is loaded, kerneld runs the command indicated by the
postinstall sound entry. So the sound module gets configured with the command
/usr/local/bin/setmix f /etc/volume.conf.
This may be useful for other modules as well, for example the lp module can be configured with the
tunelp program by adding
postinstall lp tunelp options
For kerneld to recognize these options, you will need a version of kerneld that is 1.3.69f or later.
Note: An earlier version of this miniHOWTO mentioned a preremove option, that might
5.3. When loading a module isn't enough: The postinstall entry
11
12
6. Spying on kerneld
If you have tried everything, and just cannot figure out what the kernel is asking kerneld to do, there is a way
of seeing the requests that kerneld receives, and hence to figure out what should go into
/etc/conf.modules: The kdstat utility.
This nifty little program comes with the modulespackage, but it is not compiled or installed by default. To
build it, go to the directory where you have the kerneld sources and type make kdstat. Then, to make kerneld
display information about what it is doing, run kdstat debug and kerneld will start spewing messages on the
console about what it is doing. If you then try and run the command that you want to use, you will see the
kerneld requests; these can be put into /etc/conf.modules and aliased to the module needed to get the
job done.
To turn off the debugging, run /sbin/kdstat nodebug.
6. Spying on kerneld
13
14
# Forget AX.25
# Forget IPX
# 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.
8.2. After starting kerneld, my system slows to a crawl when I activate my pppconnection
There have been a couple of reports of this. It seems to be an unfortunate interaction between kerneld and the
tkPPP script that is used on some systems to setup and monitor the PPP connection. The script apparently
runs loops while running ifconfig. This triggers kerneld, to look for the netpfX modules (see above),
keeping the system load high and possibly pouring lots of Cannot locate module for netpfX messages
into the system log. There is no known workaround, other than not use tkPPP, or change it to use some other
way of monitoring the connection.
8.3. kerneld does not load my SCSI driver!
Add an entry for the SCSI hostadapter to your /etc/conf.modules. See the description of the
scsi_hostadapter entry above.
8. Common problems and things that make you wonder
15
16
17
The requestroute stuff is obsolete, broken and not required [...] Its also removed from 2.1.x
trees.
Instead of using the requestroute script and kerneld, I highly recommend Eric Schenk's diald package to
manage your demand dialing.
Notes
[1]
Some distributions call this file modules.conf
[2]
Actually, this is not true. Late 1.3.x and all 2.x kernels support the use of an initial ramdisk that is
loaded by LILO or LOADLIN; it is possible to load modules from this disk very early in the boot
process. How to do it is described in the linux/Documentation/initrd.txt file that comes
with the kernel sourcefiles.
Notes
18