how to compile and install linux kernel

by Torstan  2011-7-3 13:20

 

In this weekend, I just want to try compiling and installing linux kernel. The root cause is I am a programmer having 3 years working experience图片. After 2 days, I succeeded. I am so happy. Now I am recording the flow.

Before all steps, I describe the environment I used. I have installed a ubuntu on VMware which works on window XP. So I decided to install another linux version on the VMware.

On Saturday, I intended to install the latest linux version, 2.6.39.2. After getting the source code form www.kernel.org, I followed the instructions in the README in the extracted file. However, I failed to boot the system with the newest kernel. Then I googled the error messages, and found that I made a big mistake, no initrd file generated. After I used mkinitramfs to generate it, I failed again. I guessed everything seemed ok except the grub file, menu.lst under /boot/grub. I googled the meanings of all the items in grub file, such as root, and root of kernel. I recompiled code and installed kernel several times, and failed on and on. Fortunately, I used update-grub command, which automatically updated menu.lst for me. I believe it more reasonable than what I wrote. I still failed...In the evening, I noticed that I had installed several kernels by automatic update, for example, 2.6.24-16-generic, 2.6.24-24-generic and 2.6.24-29-generic. All of them are at brach 2.6.24, so I guessed I should try 2.6.24 version of code. What's more, make config is not easy.

On sunday moring, I succeeded, after a lot of failure. Here are the steps.
1) download version 2.6.24 from http://www.kernel.org/pub/linux/kernel/v2.6/
2) extract file by using tar xjvf linux-2.6.24.tar.bz2
3) cd linux-2.6.24/
   make mrproper
  cp /boot/config-2.6.24-16-generic .config
  make oldconfig
  make
  sudo make modules_install install
  sudo update-initramfs -c -k 2.6.24
  edit menu.lst in /boot/grub to add an option of 2.6.24
4) reboot and express ESC to choose kernel 2.6.24.
5)done

Finally, I checked what kernel is used.
图片torstan@stan:~$ uname -r
2.6.24


posted on 2012-02-18 22:33  Torstan  阅读(359)  评论(0编辑  收藏  举报

导航