# KC8: Backup Kernel

## phypor

Navigation: [prev KC7: How do I know when to compile something into the kernel, and when should I compile it as a module?] [next KC9: Multiple Kernels] [Kernel Compilation] [Table of Contents]

KC8: How do I install a new kernel while still keeping my current one around so that I can use it if necessary? 

These scripts automate updating and archiving kernels.

Do the following as root:

First check where your boot partition is mounted

```

bash# grep boot /etc/fstab

```

take note of the /dev/hd?? where /boot is mounted for the following scripts

```

bash# nano /usr/sbin/kernel-save

```

and paste in the following:

```

#!/bin/sh

# Substitute the ?? here with what came up in the grep /etc/fstab above

BOOT='/dev/hd??'

WHEN=`date +%y%m%d`

WHAT="$1"

mount $BOOT /boot

cp -v /boot/System.map "/boot/System.map-$WHEN-$WHAT"

cp -v /boot/bzImage "/boot/bzImage-$WHEN-$WHAT"

cp -v /boot/config "/boot/config-$WHEN-$WHAT"

```

```

bash# nano /usr/sbin/kernel-install

```

and paste in the following:

```

#!/bin/sh

# Substitute the ?? here with what came up in the grep /etc/fstab above

BOOT='/dev/hd??'

mount $BOOT /boot

cp -v /usr/src/linux/System.map /boot

cp -v /usr/src/linux/arch/i386/boot/bzImage /boot

cp -v /usr/src/linux/.config /boot/config

```

Finally, change the privs so those can be executed as root:

```

bash# chmod 700 /usr/sbin/kernel-save

bash# chmod 700 /usr/sbin/kernel-install

```

After kernel compile, to save a copy of your old kernel and install the new one do

```

bash# kernel-save information-about-old-kernel

bash# kernel-install

```

If you get a message about boot already being mounted, it doesn't affect anything.

Substitute the 'information-about-old-kernel' with a real bit of infomation...

kernel-save pre-alsa-09

kernel-save vanilla-2.4.19

kernel-save original-stable

The part about System.map may not be neccessary for everyone,

if you know you don't need it, then just comment it out.

----------

## rac

Feedback to [FAQF] KC: Kernel Compilation.

----------

