Building 2.4 series kernel
```````````````````````````
Back in '97 '98 or so when I started playing with linux, the first thing
one had to do was compile the kernel to suit one's machine. I had settled
on RedHat, simply because I bought an InfoMagic LINUX Developer's Resource
six CD set with Redhat 4.1, Debian 1.2.10 and Slackware 3.2. I managed to
install RedHat, Slackware wanted lots of floppy disks, Debian -- not me.
Then I'd forget the kernel compile sequence and the result was an unbootable
machine. Reinstall, start over. So I wrote a script to automate the
process, started keeping the distro kernel as backup and generally learned
how not to break machine. Ran RedHat 6.2 + WinNT4 for several years while
I was at uni. Then I start upgrading distro and my old makeKernel script
didn't work reliably. Two factors, Redhat kernel too far away from vanilla,
and the distro 'hooking' /sbin/installkernel when 'make install' used.
The correct thing to do is hook ~/bin/installkernel, the advantage is the
script is called from kernel context and 'knows' the compile environment.
Updating kernel
````````````````
Example, today Willy Tarreau released patchset 2.4.29-hf5:
# cd /usr/src
# cp -al linux-2.4.29 linux-2.4.29-hf5
# cd linux-2.4.29-hf5
# zcat /somewhere/2.4.29-hf5.withver.diff.gz | patch -p1
# make mrproper
# cp /boot/config-2.4.29-hf4 .config
# make oldconfig
# make dep
# make install
# make modules modules_install
# vim /etc/lilo.conf
# lilo -v
# reboot
make install
`````````````
Taking control of the kernel install process. Down in the kernel source
tree find: /usr/src/linux-2.4.29-hf5/arch/i386/boot/install.sh, this script
is called during the 'make install' process, the important parts, a) it is
ten years old, and b) it optionally passes install control to the user:
# Copyright (C) 1995 by Linus Torvalds
. . .
# User may have a custom install script
if [ -x ~/bin/installkernel ]; then exec ~/bin/installkernel "$@"; fi
if [ -x /sbin/installkernel ]; then exec /sbin/installkernel "$@"; fi
# Default install - same as make zlilo
. . .
Since kernel install user is root, the file we make will be in /root/bin,
but since that is a volatile location, wiped away on reinstall OS, I
symlink it to /usr/local/bin/installkernel instead.
installkernel
``````````````
I place installkernel in /usr/local/bin, then symlink to it from
/root/bin/installkernel.
Here is matching /etc/lilo.conf and output from 'lilo -v'.
notes
``````
1. I do hosted compiles for smaller boxen, for example the firewall box.
Therefore I tell the Makefile where to find the target machine:
--- linux-2.4.29/Makefile 2005-01-20 01:10:14.000000000 +1100
+++ linux-2.4.29-hf5-dt/Makefile 2005-03-20 07:13:07.000000000 +1100
@@ -1,7 +1,7 @@
VERSION = 2
PATCHLEVEL = 4
SUBLEVEL = 29
-EXTRAVERSION =
+EXTRAVERSION = -hf5-dt
KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
@@ -74,7 +74,8 @@
# images. Uncomment if you want to place them anywhere other than root.
#
-#export INSTALL_PATH=/boot
+export INSTALL_PATH=/home/deltree/boot
+export INSTALL_MOD_PATH=/home/deltree
#
# INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory
Prior to building a kernel for 'deltree', I mount its NFS / export to
/home/deltree on the compile host. After compile run, I need only
edit /etc/lilo.conf and run lilo on the target machine, then reboot.
2. Take care when using hardlinked source trees (cp -al) to duplicate
Makefile before editing it, for example:
mv Makefile Makefile~; cp Makefile~ Makefile; vim Makefile
If you forget this, you also change Makefile in master source tree,
this is _not_ required if you cp -al a tree then patch it with something
that alters Makefile, the patch program takes care of duplicating
hardlinked files for you.
3. 2.6 series calls the script from top-level, path to .config need
adjusting. I copy .config to /boot/config-$KERNELRELEASE for years
now as I tend to track most recent 2.4 series. Makes updating easy.
4. Make friends with your bootloader. Gain confidence you can always
reboot to distro kernel. My machines run Slackware-10.1 or -current.
5. For 2.6 series: make && make install && make modules_install
6. If you not use custom installkernel script, prepend destination
path to 'make install' above, for example:
'INSTALL_PATH=/boot make install'
will place bzImage-* and System/map-* into the usual directory, then
edit /etc/lilo.conf and run lilo -v to install new kernel.
7. Disclaimer: This works for me, and there are many ways to achieve
the same result. If you break your machine, you get to keep the pieces.
Beam me up, home.