Compiling kernel 2.6.21

From Linuxintro
Revision as of 02:50, 28 September 2011 by 200.195.176.98 (talk) (→‎Build it)

This is an example how to compile a Linux kernel. It has been tested for SUSE Linux 10.2 and kernel 2.6.21, but should work same or similar for every combination.

Check prerequesites

  • Make sure you have a compiler installed
yast -i gcc 

Get the code

  • Download the kernel from ftp.kernel.org
wget ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.21.tar.bz2
  • unpack the kernel
bunzip linux-2.6.21.tar.bz2
  • unpack the kernel for the second time
tar xvf linux-2.6.21.tar

Last one to uiltize this is a rotten egg!

Install it

  • install the drivers
make modules_install
  • install the kernel
cp arch/x86_64/boot/bzImage /boot/vmlinuz-2.6.21

This will install the kernel for the x86_64 architecture.

  • prepare the initial ramdisk
cp System.map /boot
mkinitrd

This will build an initial ramdisk for all kernels contained in /boot.

  • add an entry to the bootloader. Let's take grub's /boot/grub/menu.lst:
title 2.6.21-selfcompiled
   root (hd0,0)
   kernel /boot/vmlinuz-2.6.21 root=/dev/sda1
   initrd /boot/initrd-2.6.21

Newer kernels

x86_64 and x86_32 were merged into the x86 folder.