[ILUG] Kernel install script

Kenn Humborg kenn at linux.ie
Sun Sep 10 22:21:53 IST 2000


Here's something I just knocked up for myself.  Other Red Hat
users might find it useful.

Later,
Kenn


------8<------ /usr/local/sbin/install-kernel -------8<------
#!/bin/sh

# (C) 2000 Kenn Humborg
# GPLed.  Hunt around http://www.fsf.org for a copy of the GPL.

# Standard disclaimers apply.  If this breaks your
# machine, you get to keep both pieces.

# This script should be run as root from the root dir of a linux
# kernel source tree.  It does the following:
#
#  o  does a make bzImage modules
#  o  determines the full kernel version from include/linux/version.h
#  o  copies arch/i386/boot/bzImage to /boot/vmlinuz-<VER>
#  o  copies System.map to /boot/System.map-<VER>
#  o  copies .config to config-<VER>
#  o  installs the modules after cleaning out old modules
#  o  if a reference to this image exists in /etc/lilo.conf, it 
#     runs lilo, otherwise it prints a warning that lilo.conf 
#     needs to be edited.
#
# To get the full benefit from this script, you should change
# EXTRAVERSION in the kernel Makefile whenever you want to try
# out a new kernel config.  E.g. I usually use -kh1, -kh2, etc.
# This way multiple kernels (and their modules) can live side-by-side
# and can be selected via LILO options.  The Red Hat boot scripts
# will find the right modules and link /boot/System.map to the
# correct System.map for you.

# First look for the files we expect to find in a kernel source root
if [ ! -f Makefile -o ! -f Rules.make -o ! -f REPORTING-BUGS ] ; then
   echo Current directory doesn\'t look like a kernel source dir root
   exit 1
fi

make bzImage modules 
if [ ! $? = 0 ] ; then
   echo Kernel compilation failed
   exit 1
fi

VERSION=grep UTS_RELEASE include/linux/version.h | cut -d\" -f 2
if [ -z "$VERSION" ] ; then
   echo Unable to determine kernel version
   exit 1
fi

IMAGE=/boot/vmlinuz-$VERSION

cp -fv arch/i386/boot/bzImage $IMAGE
cp -fv System.map /boot/System.map-$VERSION
cp -fv .config config-$VERSION
rm -rf /lib/modules-$VERSION
make modules_install

sed -e 's/#.*//' /etc/lilo.conf | grep -q $IMAGE 

if [ $? = 0 ] ; then
   lilo
else
   echo Image file $IMAGE not referenced in /etc/lilo.conf.
   echo You will need to edit this file and run lilo manually
   exit 1
fi





More information about the ILUG mailing list