Howto Recompile the Kernel - UBUNTU Way
5/18/2010 03:57:00 PM
Posted by johnhomer
First, why should you upgrade or change your kernel? Here are just some of the reasons:
- You need a feature that only the newer kernel supports
- You came across a bug which is fixed in the newer version
- You have a device driver that needs kernel recompile either as a module or compiled with the kernel
- You are bored
As for me, I got bored.
Overview of the process:
- Update apt sources
- Install the necessary pre-requisites
- Get the kernel source
- Compile
- Install the kernel and modules
- Reboot with the new kernel
Here are are the steps:
1. Update your APT sources
apt-get update
2. In Ubuntu 10.04, /bin/sh is linked to /bin/dash. This may be a problem during compilation. Change the link from /bin/dash to /bin/bash
rm -f /bin/sh ln -s /bin/bash /bin/sh
3. Install pre-requisites
apt-get install kernel-package libncurses5-dev fakeroot wget bzip2
4.Get the kernel source
cd /usr/src/
wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.34.tar.bz2
tar xjf linux-2.6.34.tar.bz2
ln -s linux-2.6.34 linux
cd linux
5. Copy the config of the running kernel as a basis configuration for the new kernel. It's usually a good idea to do this.
cp /boot/config-`uname -r` ./.config
6. Now we are ready to select kernel options. This is also the time to select weather you want a driver compiled as module, with the kernel or not to include at all. You have to options in doing this -- using a nice GTK menu or using the console (curses based). The latter is usually the way to go but if you want the former make sure you install libgtk2.0-dev and libglade2-dev first. For now, we will go with the console (curses)
make menuconfig
or
make gconfig
This will bring up the kernel configuration menu. Go to "Load Alternate Configuration File" and choose ".config" as the configuration file. This will load the configuration for the currently running kernel. Browse through the options and make your changes. When you are finished select "Exit" and choose YES to save.
7. We are now ready to compile the kernel. This process will take a considerable amount of time depending on the speed of your machine and the number of modules you choose to compile.
make-kpkg clean
fakeroot make-kpkg --initrd --append-to-version=-custom kernel_image kernel_headers
You can substitute anything for --append-to-version paramater as long as it starts with a "-". This string may be your version or revision number or simply just a tag.
8. When compilation is done, we can now install the new kernel and modules
cd /usr/src/ [email protected]:/usr/src# ls -la total 106128 drwxrwsr-x 5 root src 4096 2010-05-18 14:50 . drwxr-xr-x 11 root root 4096 2010-05-18 09:29 .. lrwxrwxrwx 1 root src 12 2010-05-18 09:33 linux -> linux-2.6.34 drwxr-xr-x 25 root root 4096 2010-05-18 14:48 linux-2.6.34 -rw-r--r-- 1 root src 67633622 2010-05-17 05:37 linux-2.6.34.tar.bz2 drwxr-xr-x 24 root root 4096 2010-02-10 01:07 linux-headers-2.6.32-12 drwxr-xr-x 7 root root 4096 2010-02-10 01:07 linux-headers-2.6.32-12-generic -rw-r--r-- 1 root src 6675822 2010-05-18 14:50 linux-headers-2.6.34-custom_2.6.34-custom-10.00.Custom_i386.deb -rw-r--r-- 1 root src 34340580 2010-05-18 14:47 linux-image-2.6.34-custom_2.6.34-custom-10.00.Custom_i386.deb
dpkg -i linux-image-2.6.34-custom_2.6.34-custom-10.00.Custom_i386.deb dpkg -i linux-headers-2.6.34-custom_2.6.34-custom-10.00.Custom_i386.deb
9. Reboot. Enjoy!
This entry was posted on October 4, 2009 at 12:14 pm, and is filed under
linux
. Follow any responses to this post through RSS. You can leave a response, or trackback from your own site.
Subscribe to:
Post Comments (Atom)
Post a Comment