Site Navigation
Harry's Place Business Site Tools Articles Change Colour
Diary
Almost a blog
Other Sites
The Banana Tree

If you are color blind try the Color chooser Color chooser Color chooser

Compiling a kernel for debian

This guide is mainly here to help me when it comes to building new kernels. I do it so infrequently that I miss little bits or forget to do something that involves me then trying to recover from a bodged kernel. It is not a definitive guide just enough to get me through the whole process

Kernel Compiling is easy

I have heard people say that compiling a kernel is hard. let me say now for the record its not compiling a kernel thats hard its all the other stuff you need to do that is hard. Compiling a kernel can be done as follows

         apt-get install kernel-source-2.6.5
         apt-get install kernel-patch-debian-2.6.5
         cd /usr/src
         tar jxvf kernel-source-2.6.5.tar.bz2
         ln -s kernel-source-2.6.5 linux
         cd linux
         make oldconfig
         make-kpkg clean
         make-kpkg --initrd kernel_image
         cd ../
         rm linux
        

Quite simply that is as simple as it gets but there is more to it than this. Select "oldconfig" is a reliable way to get a working kernel. This option compiles a kernel based on options that where previously selcted in your currrent kernel. Newer kernels have extra options and you will be prompted for these where they occour. It is normally safe to just go with the defaults unless you know you want that specific option set.

There was one step that I deliberately left out of the above and that is installing the kernel. This is where most people balls thigs up and end up with an unbootable system. A smart investment is a rescue CD. This may take a while to download but trust me, its worth its weight in gold when everything goes pear shaped you can use it to get back into the system and sort things out. Another thing I always do is to make sure that I always have an old kernel that is reliable and my lilo config is setup so that I can boot the old one at the boot prompt if I want to this can also save some heartache. To install the debian package createed above just do:

        cd /usr/src
        dpkg -i kernel-image-2.6.5_10.00.Custom_i386.deb
        

Lilo configuration

After the kernel has been installed it is wise to check your lilo config. My /etc/lilo.conf

            lba32
            boot=/dev/hda
            root=/dev/hda2
            install=/boot/boot-menu.b
            map=/boot/map
            delay=20
            vga=normal

            default=linux

            #---------------------------------------
            #
            #  CURRENT KERNEL
            image=/vmlinuz
                initrd=/initrd.img
                label=linux
                read-only

            #---------------------------------------
            #
            # SAFE KERNELS 
            image=/boot/vmlinuz-2.2.20-compact
                label=safe
                read-only
                optional

            #-------------------------------------------
            #  
            #  TESTING KERNELS

            image=/boot/memtest86+.bin
                label=memtest86
        

You can see that I have an old 2.2.20 kernel that I know is good and whenever I get a problem I can just use it to boot the system