How to Compile an Ubuntu 8.10 Kernel
Compile a 8.10 Kernel
The purpose of this tutorial is to show you how to set up a kernel that is highly tuned for your CPU, in this case a dual core Pentium for a workstation.
Caution: If you do something wrong..it happens…be sure to reboot and select an alternative kernel. You should always have several kernels in case of trouble.
Step #1: Download and install the necessary tools.
Download the necessary tools so that you have everything ready.
# apt-get install kernel-package libncurses5-dev fakeroot wget bzip2
You must have the source available to create a new kernel.
# apt-get install linux-source
You must be in the /usr/src directory to work or copy the source,
linux-source-2.6.27.tar.bz2, to the directory you want to work in. Either move into the /usr/src directory to work or into the alternative directory you will make the build in.
# cd /usr/src
This directory will contain the necessary headers to build the kernel. These are the source files.
You need to unpack the source that was downloaded.
# bzip2 -d linux-source-2.6.27.tar.bz2
# tar xvf linux-source-2.6.27.tar
Now you should have a directory that looks like this:
Create a symbolic link to this source directory and name it linux.
# ln -s linux-source-2.6.27 linux
Move into the directory, you can use the term linux as it is now a link to that folder.
# cd linux
The config file is a hidden file that has the configuration from the kernel that is installed. You will need to copy that because it has already determined your hardware devices.
# cp /boot/config-`uname -r` ./.config
When you copy this config file over, it is a file represents the hardware that the kernel discovered at boot and set up. It also reflects many default settings.
Step #2: Now the fun begins….
You are ready to start menuconfig which will allow you to choose your kernel specifics.
This opens the menu to start configuration.
Here you see it detected the .config file.
Now work your way through the menus and make the selections that you want to add or subtract. For example, here Reiserfs was originally a module that could be added, it had a “M” to indicate module that could be loaded. Bu it has been unchecked so modular support will not be available, thus saving space in your kernel. The “*” indicates that it will be loaded into the kernel and an empty option means that no support for that option will be placed in the kernel.
Once you have all of your modifications complete save the new .config file.
Run this command to clean up.
# make-kpkg clean
The next thing you want to do is create a kernel extension so that as you make kernels you are able to tell the versions apart. What I usually do is place my initials and a number so that I can keep track.
# fakeroot make-kpkg – -initrd – -append-to-version=-mw1 kernel_image kernel_headers
After –append-to-version= you write a string that will help you keep track of your kernel changes, it must begin with a minus (-) and must not contain whitespace.
This will take awhile.
After the successful kernel build, you can find two .deb packages in the directory you built the kernel in. If you were located in the linux directory, look in the directory above for the two .deb packages.
Now you can install and create .deb files so you can take your kernel to another machine with similar hardware. Run these commands as root in order to install them into the boot directory and modify your /boot/grub/menu.lst.
# dpkg -i linux-image-18.104.22.168-mw1_22.214.171.124-mw1-10.00.Custom_i386.deb
# dpkg -i linux-headers-126.96.36.199-mw1_188.8.131.52-mw1-10.00.Custom_i386.deb
You should now be able to select and test the new kernel when you reboot.
Now when I look in /boot/grub/menu.lst I see listed my new kernel:
## ## End Default Options ##
title Ubuntu 8.10, kernel 184.108.40.206-mw1
kernel /vmlinuz-220.127.116.11-mw1 root=UUID=b1c96812-724b-407d-a8b4-9aad3628540e ro quiet splash crashkernel=384M-2G:64M@16M,2G-:128M@16M
title Ubuntu 8.10, kernel 18.104.22.168-mw1 (recovery mode)
kernel /vmlinuz-22.214.171.124-mw1 root=UUID=b1c96812-724b-407d-a8b4-9aad3628540e ro crashkernel=384M-2G:64M@16M,2G-:128M@16M single
title Ubuntu 8.10, kernel 2.6.27-7-generic
kernel /vmlinuz-2.6.27-7-generic root=UUID=b1c96812-724b-407d-a8b4-9aad3628540e ro quiet splash crashkernel=384M-2G:64M@16M,2G-:128M@16M
Caution: You will need space in the /boot directory to save kernels as you build them. I typically build my /boot directory with 500 MBs of space.
Edit your timeout in the /boot/grub/menu.lst and increase it when you are building and trying kernels. That way it will not fly by so fast.
## timeout sec
# Set a timeout, in SEC seconds, before automatically booting the default entry
# (normally the first entry defined).
Comment out the hiddenmenu so that you will see the menu on boot. For more info check out our Building Linux Kernels online course.