728x90 AdSpace

Latest Article



Linux Kernel Compilation Steps & Tutorial , How to Compile a Kernel: The Ubuntu ?





LINUX KERNEL COMPILATION TUTORIAL AND STEPS
Linux Kernel Compilation Steps & Tutorial , How to Compile a Kernel: The Ubuntu ?

(for Lucid Linux Ubuntu 10.04 and i386 architecture machines)
--- version 1 Date: 28.09.2010 ---
I. How to Compile a Kernel: The Ubuntu Way (Lucid Linux Ubuntu 10.04)

NOTE: Accessing some parts of the system, installing system wide programs, such as a kernel, requires root privileges. Do not forget to add sudo to the beginning of most commands mentioned in the instructions below, which will grant you root priviledges during the execution of the next command.
1) Update your package database:

aptitude update

2) Install all needed packages for kernel complation:

aptitude  install  kernel-package  libncurses5-dev  fakeroot  wget  bzip2

3) Download the kernel sources to /usr/src and go to this directory by following command
                        cd /usr/src

4) Download the latest kernel source by first seeing the latest version of Kernel on www.kernel.org

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

5) Unzip the compiler source code by executing the following command

tar xjf linux-2.6.35. 5.tar.bz2

6) Form the symbolic link for linux-2.6.20.15

ln –s linux-2.6.35. 5linux

7) Go to the newly created directory by above command

cd  /usr/src/linux

8) Configure the kernel by copying configuration file from the host system. Go to boot folder manually and check the name of the name resembling the following file which we are copying.

cp /boot/config-2.6.24-19-generic   ./.config


9) Now run the following command and do the following changes to

make menuconfig

- Linux kernel configuration menu appears.
- Select “Load an Alternate Configuration File” .
- .config shall appear, as the name of the configuration file you wish to load, in the dialog box that appears next. Press <Ok>.
- (Optional) Make your configuration choices browsing through the configuration options.
- When you are finished, select Exit and answer the question “Do you wish to save
your new kernel configuration ?” with Yes.

10) Make sure that your Current directory must be /usr/src/linux

                        cd  /usr/src/linux

11) Build the kernel by executing the following two commands

make-kpkg clean

fakeroot make-kpkg --initrd –append-to-version=-APPENDUOURNAME kernel_image kernel_headers

After --append-to-version= you can write any string that helps you identify the kernel, but it must begin with a minus (-) and must not contain whitespace.
After having entered the last command, the kernel compilation starts. Depending on your kernel
configuration and your processor speed, kernel compilation may take some hours.

12) Install the new kernel by executing the following commands one by one:

cd /usr/src

ls –l

dpkg –i linux-image-2.6.35.5-custom_2.6.35.5-custom-10.00.Custom_i386.deb

dpkg –i linux-headers-2.6.35. 5-custom_2.6.35.5-custom-10.00.Custom_i386.deb

13) After having built the kernel successfully, you shall find two .deb packages in the /usr/src directory The .deb package linux-image-2.6.35.5-custom_2.6.35.5-
custom-10.00.Custom _i386.deb contains the actual kernel and the .deb package linuxheaders-2.6.35.5-custom_2.6.35.5-custom-10.00.Custom_i386.deb contains
files needed if you want to compile additional kernel modules later on.
NOTE: Even after installation of the .deb packages under /usr/src .deb packages linuximage-2.6.35.5-custom_2.6.35.5-custom-10.00.Custom _i386.deb and
linux-headers-2.6.35.5-custom_2.6.35.5-custom-10.00.Custom _i386.deb
shall remain. Thus, you can now even transfer the two .deb files to other Ubuntu systems and install them there exactly the same way, which means you do not have to compile the kernel there again.

13) If you want to see the ubuntu splash screen (or use text mode) before you get to X instead of just a black screen, you'll want to make sure the framebuffer driver loads:
echo vesafb | sudo tee -a /etc/initramfs-tools/modules
echo fbcon | sudo tee -a /etc/initramfs-tools/modules

14) Since Ubuntu Lucid (10.04) the image postinst no longer runs the initramfs creation commands. Instead, there are example scripts provided that will perform the task. These scripts will work for official kernel images as well. For example
sudo cp /usr/share/doc/kernel-package/examples/etc/kernel/postinst.d/initramfs  /etc/kernel/postinst.d/initramfs
 
sudo cp /usr/share/doc/kernel-package/examples/etc/kernel/postrm.d/initramfs  /etc/kernel/postrm.d/initramfs

15) Note: I couldn't get the above scripts to help in generating an initrd for the kernel - and so the built kernel couldn't boot; the only thing that worked for me was the recommendation in the following link. "use initramfs command. It is real solution."; what I used (after the custom built kernel's *.deb's were installed), was:
Execute the following commands one by one.
 
cd /boot
sudo mkinitramfs  -o initrd.img-2.6.35. 5-APPENDUOURNAME
sudo update-grub2

16) Restart your system now.
sudo reboot

17) Make sure the “APPENDUOURNAME” kernel is selected during restart.

18) Check if the system is using the new kernel by typing:
uname –r
It should display: 2.6.35. 5- APPENDUOURNAME


no image
  • Title : Linux Kernel Compilation Steps & Tutorial , How to Compile a Kernel: The Ubuntu ?
  • Posted by :
  • Date : 14:46
  • Labels :






  • Blogger Comments
  • Facebook Comments

0 comments:

Post a Comment