Wednesday, February 07, 2007

Compiling 2.6.20 Kernel

It's been 9 months since I last compiled a kernel... 2.6.10 (I think) and I want to do it again, especially since 2.6.20 was released.

I'm pretty sure you've seen my screenshot yesterday, yes, it seems that 2.6.20 has ntfs-write support. So, for the purpose of visually documenting 2.6.20, I'll do it again for the 3rd time. The first time, I forgot to select inotify which prevented my kernel from booting up. The 2nd time, I couldn't get a PS/2 mouse support, just USB. I just hope I do it right this time..



My guide is HowtoForge:

http://www.howtoforge.com/kernel_compilation_ubuntu







Thanks Falko Timme for the guide!



Moving forward.



Create a root account that way, you don't have to issue sudo every time you issue a command, that will save us time. We can easily delete them later anyway.









Login as root





I will qoute Mr. Falko Timme here: "On Ubuntu 6.10, /bin/sh is a symlink to /bin/dash by default. /bin/dash seems to make problems when you compile software from the sources, at least I had that impression. That's why I make /bin/sh a symlink to /bin/bash instead."





Let's now install some packages needed to compile the kernel





This is the command, just in case:

apt-get install kernel-package libncurses5-dev fakeroot wget bzip2







Download the Kernel Source







wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.20.tar.bz2
















Unpack the, well, package using the following commands:



tar xjf linux-2.6.20.tar.bz2







ln -s linux-2.6.20 linux







cd /usr/src/linux





Next up is copying the configuration of the current kernel (2.6.17).

You may need to copy-paste the code below:



cp /boot/config-`uname -r` ./.config





It's now time to configure the kernel:



make menuconfig











Load the saved .config file











There are a few options we need to configure:

  1. Code Maturity Level Options
  2. General Setup
  3. Loadable Module Support
  4. Block Layer
  5. Processor Type and Features
  6. Power Management Options (ACPI, APM)
  7. Bus Options (PCI, PCMCIA, EISA, MCA, ISA)

  8. Executable File Formats
  9. Networking
  10. Device Drivers
  11. File Systems
  12. Instrumentation Support
  13. Kernel Hacking
  14. Security Options
  15. Cryptographic Options
  16. Library Routines
Then we have the:

  • Load an Alternate Configuration File (that we already did above) and the

  • Save an Alternate Configuration File






Code Maturity Level Options:





General Setup





Loadable Module Support





Block Layer





Processor Type and Features









Power Management Options





Bus Options (PCI, PCMCIA, EISA, MCA, ISA)





Executable File Formats





Networking





Device Drivers









File Systems









ATTENTION:

This is where I found out the NTFS-Write Support





Instrumentation Support





Kernel Hacking





Security Options





Cryptographic Options





Library Routines





BIG TIP: If you don't know what it's for, don't touch it. Leave it as is. Do not mess with it.

You've been warned.





And after configuring your kernel, go ahead and save it.





And then Exit out of it



Now it's time for us to build the kernel



Execute the following commands, copy-paste if you have to.



make-kpkg clean







fakeroot make-kpkg --initrd --append-to-version=-custom kernel_image kernel_headers

the --append-to-version=-xxx may be anything, but please don't forget the (-).







*****

Now's the time to go out and have lunch, or take your family for dinner.

This will take a while (around 2-4hrs depending on your system. I have a P3 733Mhz and it took me a little over 4hrs.)

*****



After compiling your kernel, it's time for use to install it, but you should be aware that you'll have 2 .deb files on /usr/src directory. One of them is an image, the other is the header. Mine on the other hand:





So now it's time to install my kernel by issuing the following commands



dpkg -i linux-image-2.6.20-dax_2.6.20-dax-10.00.Custom_i386.deb





and



dpkg -i linux-headers-2.6.20-dax_2.6.20-dax-10.00.Custom_i386.deb







And you're done, and if you check on your /boot/grub/menu.lst , you'll find another newer entry... yours!







so just reboot with that kernel and you'll be surprised at the speed and optimization.