Separate Kernel Trees Frodo Looijaard, frodol@dds.nl v1.0, 11 July 1998 1. Introduction This document describes a setup which allows the installation and use of several distinct kernel trees, even when they have the same release number. When you are working on some kernel-related development, trying out a new compiler version or installing pre-versions, this document might be useful to you. Note that some distributions may already have something comparable to the setup described below. If the directory trees in /lib/modules are named 2.0.34 for kernel versions 2.0.34, this is probably not the case. If they are named 2.0.34-something, you will probably not need this document. Note that I have only tested this for 2.0.x kernels. I would appreciate to hear whether it works out for 2.1.x kernels too. 2. Setup To allow the use of several kernels with the same release number, we will refer to kernel versions as a concatenation of release number and compilation number, separated by a dash. Example: Kernel version 2.0.32, third compilation, would be called 2.0.32-3 During execution of /etc/rc (at system start-up), several steps must be taken to ensure this will work (VERSION is a version number as explained above): * /usr/src/linux must be linked to /usr/src/VERSION * /lib/modules/current must be linked to /lib/modules/VERSION You can determine VERSION with the following code snippet: ---Cut Here--- kernel_version () { local IFS_safe="$IFS" IFS="#-$IFS" set -- `uname -v` IFS="$IFS_safe" echo `uname -r`-$2 } ---Cut Here--- Using this function, you can add something like this to your rc-files (this code is a bit paranoid, but better be safe than sorry): ---Cut Here--- echo "Selecting the current modules..." KERNELD=yes VERSION=`kernel_version` if [ -d "/lib/modules/$VERSION" ] ; then if [ -L /lib/modules/current ] ; then rm -f /lib/modules/current fi if [ ! -e /lib/modules/current ] ; then ln -s "$VERSION" /lib/modules/current else echo "ERROR: /lib/modules/current exists and is not a symbolic link." echo " Module loading may produce unexpected results, perhaps even" echo " resulting in data loss. We will not load kerneld. Expect" echo " many errors below." KERNELD=no fi else echo "ERROR: /lib/modules/$VERSION not found." echo " Kerneld can not be started, modules will not be loaded" echo " automatically. Expect many errors below." KERNELD=no fi ---Cut Here--- Moreover, the file /etc/conf.modules must be present and contain at least the following information (sometimes this file is called modules.conf): ---Cut Here--- # Where to find the dependency file depfile=/lib/modules/current/modules.dep # These are the paths to the kernel version-specific modules path[fs]=/lib/modules/current/fs path[misc]=/lib/modules/current/misc path[net]=/lib/modules/current/net path[scsi]=/lib/modules/current/scsi path[block]=/lib/modules/current/block path[ipv4]=/lib/modules/current/ipv4 # These are the paths to additional modules which are kernel independent path[fs]=/lib/modules/extra/fs path[misc]=/lib/modules/extra/misc path[net]=/lib/modules/extra/net path[scsi]=/lib/modules/extra/scsi path[block]=/lib/modules/extra/block path[ipv4]=/lib/modules/extra/ipv4 # These are the paths to modules which are inserted at boot-time for all # kernel versions. Note that by making symbolic links to ../current/... # you can still load different modules for different kernels. path[boot]=/lib/modules/boot # These are the paths to modules which are inserted at boot-time for # specific kernels path[boot]=/lib/modules/current/boot ---Cut Here--- To ensure this scheme works, you have to be careful when compiling a new kernel: * Make sure the combination of release and compilation numbers is unique. You can set the compilation number by entering the number _minus one_ in /.version (delete this file to use number 1). * After calling module_install, rename /lib/modules/RELEASE to /lib/modules/VERSION (where RELEASE is the kernel release number), or use the small patch below: ---Cut Here--- *** /tmp/linux/Makefile Wed Feb 4 19:41:45 1998 --- linux/Makefile Wed Feb 4 20:04:45 1998 *************** *** 275,279 **** modules_install: @( \ ! MODLIB=/lib/modules/$(VERSION).$(PATCHLEVEL).$(SUBLEVEL); \ cd modules; \ MODULES=""; \ --- 275,279 ---- modules_install: @( \ ! MODLIB=/lib/modules/$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)-`cat .version`; \ cd modules; \ MODULES=""; \ ---Cut Here--- 3. Copyright and disclaimer This document is copyright (c) 1998 by Frodo Looijaard (frodol@dds.nl). You may freely copy and distribute it, as long as you recognize me as the author, and mark any changes you make as being your own, and distribute this notice with it. This document is distributed in the hope it is useful, but without any warranty. If following the guidelines herein blows up your system, I will not be held responsible.