#! /bin/bash # # installkernel -- last edit 2008-09-09 # # installkernel # `````````````` # this script is called by linux-kernel's 'make install' option to copy # the kernel files (bzImage, System.map, .config) to the /boot directory # the script is used for both 2.4 and 2.6 series kernel installs # # Copyright (C) 2004-2008 Grant Coady # # based on linux/arch/i386/boot/install.sh # GPL v2 per linux/COPYING by reference # # installation # ````````````` # the linux 'make install' looks for this script in two places, # in this order: # # ~/bin/installkernel # /sbin/installkernel # # copy installkernel to one of the above locations but don't overwrite # any distribution copy of /sbin/installkernel # # limitations # ```````````` # does not build initrd files -- I've never used them # # optional # ````````` # if you use a backup kernel naming option in /etc/lilo.conf # this script will backup the old kernel files of the same version if # it finds the line 'bzImage-$(uname -r).old' in /etc/lilo.conf, for # example: # # /etc/lilo.conf # ... # image = /boot/bzImage-2.6.26.5a # label = 2.6.26.5a # # image = /boot/bzImage-2.6.26.5a.old # label = 2.6.26.5a.old # ... # # when installing bzImage-2.6.26.5a the script will rename existing kernel # files to the *.old extension, in this case: bzImage-2.6.26.5a.old, # config-2.6.26.5a.old and System.map-2.6.26.5a.old # # home site # `````````` # http://bugsplatter.id.au/bash/kernel/ # # installing kernel to alternate target # `````````````````````````````````````` # Usually the root user invokes the script as `make install` and expects the # kernel files to appear in /boot and the kernel modules in /lib/modules. # # To install the kernel files to an alternate directory, specify # INSTALL_PATH; for example, install kernel to staging area: # # INSTALL_PATH=/staging/area/boot make install # # see also # ````````` # kbuild-install and kbuild-install-local scripts from the home page above, # these scripts are what I use to build kernels for some years now # # Changelog # `````````` # 2008-09-09 # rewrite the above commentary ME=installkernel VERSION="2007-01-17" echo -e "\n$ME:\nGrant's installkernel script, $VERSION" DEBUG= [ $DEBUG ] && echo " * Arguments: kernel version: $1 kernel image file: $2 kernel map file: $3 default install path: $4 " BOOT_DIR="/boot" # default INSTALL_PATH, when $4 is empty # check we have a valid kernel target directory if [ -n "$4" ] && [ "$4" != "$BOOT_DIR" ] then if [ -d $4 ] then BOOT_DIR=$4 else echo -e "\n\n$ME: fatal: missing kernel target directory:" echo -e "\t$4" exit 1 fi fi # where to find .config, based on kernel series if [ -f '.config' ] then echo "* 2.6 kernel" DOT_CONFIG=".config" else echo "* 2.4 kernel" DOT_CONFIG="../../../.config" fi # create kernel file names with version --> $(uname -r) CONFIG="$BOOT_DIR/config-$1" KERNEL="$BOOT_DIR/bzImage-$1" SYSMAP="$BOOT_DIR/System.map-$1" echo "* Destination files: config: $CONFIG kernel: $KERNEL System.map: $SYSMAP " # perhaps backup prior kernel files, if lilo.conf has matching .old stanza if grep -q "bzImage-$1.old" /etc/lilo.conf then echo "* Moving old kernel files to $BOOT_DIR/*.old" [ -f $CONFIG ] && mv $CONFIG "$CONFIG.old" [ -f $KERNEL ] && mv $KERNEL "$KERNEL.old" [ -f $SYSMAP ] && mv $SYSMAP "$SYSMAP.old" fi # write new kernel echo -e "\n* Writing new kernel files to $BOOT_DIR" cp $DOT_CONFIG $CONFIG cat $2 > $KERNEL cp $3 $SYSMAP #end