Compiling a new 2.6 or 2.4 kernel on Debian GNU/Linux Sarge.

Configuring the 2.4 kernel on Debian 3.0.
Configuring the 2.4 kernel on Debian 3.0.

Compiling and Installing a 2.6+ Kernel on Debian Sarge. (Updated!)

To compile a new kernel on Debian 6.0, firstly you need to download a kernel source package from kernel.org. Once you have copied it to your home directory in an appropriate folder, just type tar -jxvf linux-3.0.3.tar.bz2 to unpack it then type cd linux-3.0.3 and type make mrproper to make sure the source tree is clean.

Then type make menuconfig and follow the options to customise your kernel. kernel config. Once this is completed, you
can type make bzImage && make modules to compile the kernel which may
take a long time to complete depending on what options you have selected during
the configuration phase.

Once this is completed you will need to run su -c “make modules_install”
and enter the root password to copy the modules to /lib/modules and then type make install to install the vmlinuz kernel image and other files to /boot. After this has been performed, two final tasks remain.

On a modern Debian or Ubuntu system you would type mkinitramfs -o initrd.img-3.0.3 3.0.3 and this would create the initrd file for you, then type sudo update-grub to update the bootloader and add the new kernel to the boot menu.

MKINITRAMFS(8)      mkinitramfs manual      MKINITRAMFS(8)

NAME
       mkinitramfs - low-level tool for generating an initramfs image

SYNOPSIS
       mkinitramfs [-c compress] [-d confdir] [-k] -o outfile [-r root] [-v] [version]

       mkinitramfs [--supported-host-version= hversion]

       mkinitramfs [--supported-target-version= tversion]

DESCRIPTION
       The mkinitramfs script generates an initramfs image. The initramfs is a compressed cpio archive.
       The archive can be used on a different box of the same arch with the corresponding Linux kernel.
       mkinitramfs is meant for advanced usage. On your local box update-initramfs calls mkinitramfs with the relevant parameters.
       update-initramfs keeps sha1sum of generated initramfs. It takes care to generate backups and eventually runs the bootloader.

       At boot time, the kernel unpacks that archive into RAM disk, mounts and uses it as initial root file system.
       All finding of the root device happens in this early userspace.

Then once those steps have been successfully completed, type su -c “update-grub” to update the bootloader. Then the computer can be rebooted and the new kernel can be selected in the boot menu.

Compiling and installing a 2.4 kernel on Debian GNU/Linux Sarge.

This is quite like the installation process for the 2.6 kernel. Just unpack
the kernel sources to your home directory and cd to the directory and type
make mrproper to make sure the source directory is clean. Then type
make menuconfig and follow the options to customise your kernel.

Once this is completed, you need to type make dep then make bzImage && make
modules
to compile the kernel which may take a long time to complete
depending on what options you have selected during the configuration phase. After this is
complete, type make modules_install then type the arch/i386/boot/bzImage
file to /boot and the System.map to the /boot directory. then type mkinitrd
-o /boot/initrd-1 /lib/modules/2.4.29
where 2.4.29 is the directory where
your kernel modules for your kernel image reside.

The compilation process.

cd linux-2.4.29/
make mrproper
make menuconfig
make BzImage && make modules
make modules_install
cp arch/i386/boot/bzImage /boot && cp System.map /boot
mkinitrd -o  /boot/initrd-1 /lib/modules/2.4.29

On my new Debian Sarge system
this how it was laid out after installing the modules. Then just edit your
/boot/grub/menu/lst file to add the new kernel. When you copy the System.map to
the /boot directory, you can name it System.map-1 for example and then type
ln -s System.map-1 System.map so that the mkinitrd utility can find
it. Then when you install another kernel you can just symlink that new
System.map file eg, System.map-2 to System.map

See below for an example.

total 11M
drwxr-xr-x   3 root root 4.0K  05-03-07 09:16 pm .
drwxr-xr-x  21 root root 4.0K  05-03-07 08:56 pm ..
lrwxrwxrwx   1 root root    9  05-03-07 06:34 am bzImage -> bzImage-1
-rw-r--r--   1 goku goku 856K  05-03-07 12:28 am bzImage-1
-rw-r--r--   1 root root  44K  04-03-07 11:38 pm config-2.4.27-2-386
drwxr-xr-x   2 root root 4.0K  05-03-07 02:28 pm grub
-rw-r--r--   1 root root 3.9M  05-03-07 03:43 am initrd-1
-rw-r--r--   1 root root 3.7M  05-03-07 08:57 am initrd.img-2.4.27-2-386
lrwxrwxrwx   1 root root   18  05-03-07 06:38 am System.map -> /boot/System.map-1
-rw-r--r--   1 goku goku 515K  05-03-07 06:38 am System.map-1
-rw-r--r--   1 root root 530K  02-03-07 05:18 am System.map-2.4.27-2-386
-rw-r--r--   1 root root 798K  05-03-07 08:57 am vmlinuz-2.4.27-2-386