Linux kernel compilation

Author: Nediam <javier@nediam.com.mx>
Publication date: 2005-11-30


Requirements: To have on hand all the characteristics of the hardware of the computer (video card, monitor, hard disk, motherboard, processor, RAM, sound card, network card, modem, etc.). It is also recommended to have previous knowledge in the configuration of some boot loader, either LILO, GRUB, or some other one.

  1. Download from the official kernel site http://kernel.org/ the sources. Supposing that the version of the kernel is 2.4.31, the tar.bz2 file would be linux-2.4.31.tar.bz. Place that file in the directory /usr/src/.
  2. SERVER:/usr/src# bzcat linux-2.4.31.tar.bz2 | tar -xvf -
  3. SERVER:/usr/src# ln -s linux-2.4.31 linux
  4. SERVER:/usr/src# cd linux
  5. SERVER:/usr/src/linux# make menuconfig (and configure the kernel options according to the computer hardware)
  6. SERVER:/usr/src/linux# make dep

    Tip: if you got errors during make dep, it could be due to the gcc version that is being used, in particular version 4. This can be solved installing gcc-3 and after that making a symbolic link so that /usr/bin/gcc points to /usr/bin/gcc-3.
  7. SERVER:/usr/src/linux# make modules

    Tip: if the kernel was configured without module support ([] Enable loadable module support), this step is not necessary.
  8. SERVER:/usr/src/linux# make modules_install

    Tip: if the kernel was configured without module support ([] Enable loadable module support), this step is not necessary.
  9. SERVER:/usr/src/linux# nohup make bzImage &
  10. SERVER:/usr/src/linux# tail -f nohup.out (it will take a while for the kernel image to be generated)
  11. SERVER:/usr/src/linux# cd boot
  12. SERVER:/boot# cp /usr/src/linux/arch/i386/boot/bzImage kernel_2.4.31
  13. SERVER:/boot# cp /usr/src/linux/System.map System.map-2.4.31
  14. SERVER:/boot# ln -s System.map-2.4.31 System.map
  15. For versions 2.6.x of the kernel:
    SERVER:/boot# mkdir /sys
    SERVER:/boot# echo "none /sys sysfs defaults 0 0 " >> /etc/fstab
  16. Configure the boot loader (LILO, GRUB, etc.). For example, for LILO, the following lines should be added to /etc/lilo.conf:
    image=/boot/kernel_2.4.31
    label=Linux_2.4.31
    read-only
  17. SERVER:/usr/src# Reboot

Note: For kernel versions 2.6.x, if during the 'make' an error related module utilities appears, it is necessary to install that package. It can be downloaded from this page (then check the README and install it).


The latest version of this document is available at: http://nediam.com.mx/en/tips/kernel_compilation.php

<< 0 comments >>



TOP