AUTHOR: Bruce Dubbs <bdubbs at linuxfromscratch dot org>

DATE: 2003-10-26

LICENSE: GNU Free Documentation License Version 1.2

SYNOPSIS: Manage multiple kernels in an LFS system.

DESCRIPTION:
The instructions in LFS provide for a single kernel.  This hint provides
a way to manage multiple kernels for different objectives.

PREREQUISITES:
This hint is applicable for anyone building multiple kernels in an 
LFS system.

HINT:
When building the kernel, there is a method of tagging it to make
configuration of different versions easier.  This method uses the 
EXTRAVERSION parameter to tag the kernel.  The build process looks like:

DATE=`date +-%Y%m%d`
VERSION=2.4.22

make mrproper
make EXTRAVERSION=$DATE menuconfig
make CC=/opt/gcc-2.95.3/bin/gcc EXTRAVERSION=$DATE dep
make CC=/opt/gcc-2.95.3/bin/gcc EXTRAVERSION=$DATE bzImage
make CC=/opt/gcc-2.95.3/bin/gcc EXTRAVERSION=$DATE modules
make CC=/opt/gcc-2.95.3/bin/gcc EXTRAVERSION=$DATE modules_install
make mandocs 
cp -a Documentation/man /usr/share/man/man9 
cp arch/i386/boot/bzImage /boot/linux-${VERSION}${DATE}
cp System.map /boot/System.map-${VERSION}${DATE}

At this point, you need to edit /boot/grub/grub.conf to
add your new kernel and then reboot.

What this does
==============

First we set a DATE variable in the current shell in the form 20031026. We
also set the VERSION variable to the version of the kernel we are creating.

We then build the configuration.  make menuconfig will create a .config
file in the linux source directory and the include/linux/version.h file
where the version resides.  If you want to upgrade an existing 
configuration, after you run make mrproper, you can copy a saved copy of 
your .config file to the top kernel source directory and use:

yes "" | make  EXTRAVERSION=$DATE oldconfig

This will reuse your old configuration and use the defaults for any changed
configuration parameters in an updated kernel.

The EXTRAVERSION variable will embed a string into the kernel version.  This 
will create a response to the `uname -r` command which will look something
like "2.4.22-20030915".  It will also insert any modules you make into the 
directory /lib/modules/<version number>.  For example:
  
   /lib/modules/2.4.22-20030915/

Copying the kernel image, bzImage, to /boot/linux-${VERSION}${DATE} will
identify the kernel version and date compiled for future reference.

Copying System.map to /boot/System.map-${VERSION}${DATE} will allow the
kernel to always find the proper System.map without any symbolic links
because it always looks for the map in this form before it looks for
a plain System.map file.

There are several variations you can use by merely changing the DATE variable.
For instance if you want to add a time (hours and minutes) to the kernel 
version, you can use:

DATE=`date +-%Y%m%d%H%M`

or you can use a simple version number (-1, -2, -3, etc.) that you might want
to set manually:

DATE=-2

In all cases, the method above will properly match up your System.map file to 
the kernel when booting.  I recommend always starting the EXTRAVERSION with a 
dash (-).

Alternative Method
==================

Instead of adding the EXTRAVERSION to each make file, you can just change it
in the Makefile with:

sed -i -e "s/^EXTRAVERSION =.*/EXTRAVERSION = $DATE/" Makefile 

then:

make menuconfig
make CC=/opt/gcc-2.95.3/bin/gcc dep
make CC=/opt/gcc-2.95.3/bin/gcc bzImage
make CC=/opt/gcc-2.95.3/bin/gcc modules
make CC=/opt/gcc-2.95.3/bin/gcc modules_install

and continue as above.

CHANGELOG:
[2003-10-28]
  * Add EXTRAVERSION to make oldconfig
[2003-10-27]
  * Add EXTRAVERSION to make menuconfig
  * Add alternative sed method
[2003-10-26]
  * Initial hint.