Monday, August 25, 2008

Compiling the linux kernel

To compile a fresh linux kernel.

1. Download the kernel source from www.kernel.org let's say linux-x.y.z.tar.gz
2. Expand the archive in /usr/src directory "$tar -xzvf linux-x.y.x.tar.gz"
3. Create a linux link to the source directory
$ln -s linux-x.y.x linux

4. $cd linux
go into the source directory

5. If you want to delete the previously compiled kernel object files, configuration files run
$make mrproper

6. Configure the kernel (one of below)
6.1. $make config (you will be promted for each configuration parameter one by one)
6.2. $make menuconfig (you will be have text based menu in the terminal, easier for navigation, requires library ncurses installed)
6.3. $make xconfig (you will be have a graphical window to configure the kernel, you will need to have many packages installed).

7. Build the kernel
$ make

8. Build the modules
$make modules

9. Install the modules
$make modules_install

10. Install the kernel
$make install

This will create four files in directory /boot
  • vmlinuz-x.y.z (the kernel)
  • System.Map-x.y.z
  • config-x.y.y
  • initrd-x.y.z
To use the new kernel you will have to add an entry into me grub menu list, this is file /boot/grub/menu.lst You can look at the existing entries when preparing the entry for the new kernel. When you are done reboot the machine.

No comments: