First get the necessary parts: A suitable kernel and the latest modules package. Then you should install the module utilities as per the instructions included in the package. Pretty simple: Just unpack the sources and run make install. This compiles and installs the following programs in /sbin: genksysm, insmod, lsmod, modprobe, depmod and kerneld. I recommend you add some lines to your startup-scripts to do some necessary setup whenever you boot Linux. Add the following lines to your /etc/rc.d/rc.S file (if you are running Slackware), or to /etc/rc.d/rc.sysinit if you are running SysVinit, i.e. Debian, Corel, RedHat, Mandrake or Caldera:
# 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 # Your standard fsck commands go here # And you mount command to mount the root fs read-write # Update kernel-module dependencies file # Your root-fs MUST be mounted read-write by now if [ -x /sbin/depmod ] then /sbin/depmod -a fi
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 inter-dependencies. 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/?]
where you can answer with an M for "Module". Generally, only the drivers necessary for you to boot up your system should be built into the kernel; the rest can be built as modules.
Essential drivers required to boot your system must be compiled into the core kernel and cannot be loaded as modules. Typically this will include the hard-disk driver and the driver for the root filesystem. If you have a dual-boot machine and rely on files found in the foreign partition, you must also compile support for that filesystem into the core kernel.
When you have gone through the make config, compile and install the new kernel and the modules with make dep clean bzlilo modules modules_install.
Compiling a Kernel Image: The make zImage command will stop short of installing a kernel and will leave the new kernel image in the file arch/i386/boot/zImage. To use this image, you will need to copy it to where you keep your boot-image and install it manually with LILO.
For more information about configuring, building and installing your own kernel, check out the Kernel-HOWTO posted regularly to comp.os.linux.answers, and available from the Linux Documentation Project and its mirrors.
Now reboot with the new kernel. When the system comes back up, you can run ps ax, and you should see a line for kerneld:
PID TTY STAT TIME COMMAND 59 ? S 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 2E2B-1102 Directory for A:/ binuti~1 gz 1942 02-14-1996 11:35a binutils-22.214.171.124-126.96.36.199.diff.gz libc-5~1 gz 24747 02-14-1996 11:35a libc-5.3.4-5.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:
osiris:~ $ /sbin/lsmod Module: #pages: Used by: floppy 11 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!