Quote: I have a very good DENTAL PLAN. Thank you.
(Courtesy of fortune cookies)

Welcome to the Cool Spot of the Sun

Compiling a Kernel under debian

Some basic utilities needed are Debian itself, wget(if the newest sources are required),kernel-package, libqt3-dev, bzip2, gzip

all what is needed is opening a command prompt in 'superuser mode' using the 'su' command. First we do an update just to make sure that we have the latest package list. Also unless the path is mentioned, the command is path-independent and can be used anyplace.

apt-get update

apt-get install kernel-package libqt3-dev wget

Once the basic packages have been installed we need to find the latest kernel-source(s). There are 2 options here, downloading the latest kernel from www.kernel.org or using a debian kernel package(.deb)

  • Option 1: ftp to the kernel.org site at ftp.kernel.org. The kernel is in the subfolder /pub/linux/kernel. Search for the latest kernel there. By the way the kernel has to be saved in /usr/src Once can even use wget here to get it. 'wget ftp-or-http-link-address'
  • Option 2: go to the command prompt and use apt-cache search kernel-source. If there are too many packages you can grep or pipe it. So use either
    'apt-cache search kernel-source|grep kernel-source'
    or
    'apt-cache search kernel-source|less'

    Once this is done install the package using 'apt-get install kernel-source-2.X.XX'

Normally the packages at kernel.org are either .tar.gz extension or .tar.bz2 extension. Also the .deb package installed will make such an extension file in /usr/src. Now we need to unzip it.

bzip2 -d *.bz2 or gzip -d *.gz
and then untar using 'tar -xvf *.tar'.
Note: done on the kernel-source file downloaded in the /usr/src folder.

Now make a symbolic link now for the linux folder.

ln -s kernel-source-2.6.8 linux
Where the untarred kernel folder is kernel-source-2.6.8. Use appropriate folder name in your example. Also right now we are working in 'su' mode in /usr/src.

Now 'cd' to our new linux directory using 'cd /usr/src/linux'.
Make sure that you are in a X-supporting terminal to use graphical kernel configuration.
Use this command to fire up the kernel configuration menu 'make xconfig'. If you are working in a non-X terminal use 'make menuconfig' or'make config'. 'menuconfig' depends on ncurses library. You might have to call up our friend 'APT' to configure it.

Now some (personal) notes on kernel configuration

  • Enable APIC if you are using a laptop and want the battery indicator, etc.
  • RTAI, i think doesnot like module versioning 'on'. So disable it. The option is in
    Loadable Module Support->Enable Loadable module support->Module Versioning. Don't fret if it is not present.
  • Also if you are using Ext3, make sure its a part of the kernel and not a module. Just imagine, when you reboot if it is as a module, it cannot load up the harddisk as Ext3 is not compiled in kernel and so you cannot also load up the module. Kindof a chicken-egg problem. To enable ext3 support in kernel, the option is
    File systems->Ext3 Journalling support.
    This compile in kernel is true for all types of File systems, so make sure that the corresponding Filesystem driver is compiled in kernel.
  • A default configuration is available in /usr/src/linux/arch/i386/defconfig for a i386 system, and similarly for a PowerPC(ppc64) its in /usr/src/linux/arch/ppc64 folder. You can copy that config to your /usr/src/linux/ and rename it to '.config'. This .config is the file where all the options chosed in the kernel-configuration are stored.

Now we are at the step where we can start compiling the kernel. Here the 'kernel-package' package will help us. It has a tool called as make-kpkg.
make-kpkg has a couple of options that are useful

  • --revision number ==>helps to set a revision number
  • --append_to_version foo ==>helps appending an extraversion info
  • kernel_image ==> This target produces a Debian package of the Linux kernel source image, and any modules configured in the kernel configuration file .config
  • binary ==> This target produces all four Debian kernel packages by running the targets kernel_source, kernel_headers, kernel_doc and kernel_image.

Now just type
make-kpkg kernel-image and take a break for coffee. In some time, abt 14 minutes on a dual-powerpc or 24 minutes on a 1.6Ghz P-M, a kernel-image****.deb file will be created in the /usr/src folder. Sometimes it doesnot compile cleanly and make crashes. In that case see what is wrong, might be conflicting options, or even bad-options which don't let a clean compile. In that case disable those options.
Que: which options to disable? try to see where it has crashed. for example if it crashes after entering /driver/net/***, means that it has crashed somewhere near those options.Its really trial-and-errors, but its really rare that it make-crashes happens.

The kernel-image****.deb file is created in the /usr/src folder. If you have given any version and appends than those will also show up in '****'.deb
Install this kernel now using the dpkg command

  • dpkg -i kernel-image-****.deb

You will see lots of messages while dpkg installs the .deb file. You will notice it will be telling you that it is adding the kernel option in the grub/lilo list. In some cases, you might have to make a custom initrd image. That occurs normally in pristine hardware like js20 blades.

In such a rare circumstances to make an 'initrd' image. Use mkinitrd command.
see its man page. Also once you make an initrd image. You will have to add it to the lilo and grub configuration.

Now if you reading this and followed all the commands, you should be ready to 'reboot', crossing your fingers and booting to your new kernel.


Get Firefox!  Use OpenOffice.org lastRSS.php - RSS parser for PHP Valid HTML 4.01! Valid CSS! IP Address Lookup


The visitor number 13195
Disclaimer