We're Getting Mutants in the MCU - The Loop


Welcome to my first HowTo on compiling a custom kernel on our own. Though this HowTo deals with Ubuntu, the procedure is very similar in other distributions as well. If what we need is just additional drivers for supporting a device which is not available by default, we need to compile just the headers rather than compiling the entire kernel. The idea of custom kernel is to remove unwanted portions of the kernel, mainly drivers for hardware devices which is not in your current computer, thus making the kernel as small as possible, supporting the devices we have with us.

This HowTo is based on several other HowTos available in, with an added personal touch of expeirence.

The kernel source under current complitation, which we are going to do perform now, is a 2.6.20 Kernel image frm, the main source of Linux Kernel. The kernel will be compiled on a P4 2GHz processor for Kubuntu 6.10 Distribution. There will be only minor difference performing the same on Ubuntu or Xubuntu.

BEFORE starting actuall work have a look at the NOTES at the end of the article.

Here we go..

Step 1.

  First of all, we need a tarball containing the source code which can be download
  as follows. Just enter the command in a terminal and you will get the kernel source
  tar ball downloaded. (The size of download will be approx 41MB)
  wget -c

Step 1.1

  Extract the source code in a location of our choice, say our home directory.
  sudo tar -xvjf linux-2.6.20.tar.bz2 .

Step 2.

   Now we need to get all the other necessary packages with are required to compile our kernel.
   sudo apt-get install build-essential bin86 kernel-package libqt3-headers
   libqt3-mt-dev wget libncurses5 libncurses5-dev

Step 3.

   Now its time to drop ourself into a root shell to carry on the compilation.
   sudo -i

Step 4.

   Change to the directory where we have extracted the source code. For eg.
   cd /home/myuser/linux-2.6.20

Step 5.

   Now to import your current kernel configuration. For that first we need to know the current kernel
   version and hence use the command 'uname -r' to find it. Then copy the current config file into the
   location where we are compiling our custom kernel. 
   cp /boot/config- .config

Step 6.

   We need to configure our kernel, with the following command.
   For additional pointers refer Click Here. This is for customizing the kernel to what we want it to have.
   make xconfig

Step 7.

   Clean up the kernel source directory from previous target builds. Any old data here will be
   used by the build. So better to clean it up before we compile ours.
   make-kpkg clean

Step 8.

   Compile and make the linux kernel binary images.
   make-kpkg -initrd --revision=linux-2.6.20 kernel_image kernel_headers modules_image
   (You can replace 2.6.20 with anything e.g. 'custom_kernel' or whatever you want.)

Now, time to show some patience and leave it to work. We can have a cool shower or walk out and have some tea before it finishes its work and our custom kernel is all ready to be booted in.

Step 9.

   Hopefully, if everything goes well, we would be finally having a couple of .deb files with us, similar  
   to 'linux-headers-2.6.20_386_i386.deb' & 'linux-image-2.6.20_386_i386.deb'. Now, we have to install
   these .deb packages and for that issue the following commands in the terminal.
   dpkg -i linux-headers-2.6.20_386_i386.deb & dpkg -i linux-image-2.6.20_386_i386.deb

Once the installation is done, Viola! We have our new custom kernel! Just reboot your system and this time remember to select your custom built kernel. We can modify /boot/grub/menu.lst for making it to boot in this kernel by default :)

NOTE : - 1) for the kernel compilation steps you don't need to be super user i.e. while performing all those make commands

BUT you will need to login as root if you wish to install the deb packs

ALWAYS FOR A THUMB RULE try to minimize the use of super user account.

2) for easy editing make gconfig would be better as it is now a better interfae (you will need to have GTK+ and glade installed in your system.)

3) After every thing is said and done i would like to again remind eeryone the basic reason for recompiling the kernel. to make it more tightly integrated as per your hardware so you should have sound knowledge about your hardware and system setup. EX: - if yo have all FAT32 partitions besides linux ones you don't need to have NTFS support inbuild.

Also if you wish to play songs you can't just leave soundcard support

4) do keep in mind that stock kernel (the kernel which comes preinstalled) are compiled in order to support maximum possible hardware, if you are recompiling the kernel you should definately have a look at the selections being made, the key areas were you can tweak are the device drivers are, a) remove support for unneccessary drivers b) remove support for ISA as it is rarely found in any board now.

also even though we gave you a lot of idea the final words are yours, so don't panic just start doing it.

LAST EDITED Anantshri 10:06, 30 May 2007 (BRT)

Community content is available under CC-BY-SA unless otherwise noted.