Installing Kernel From Source
Willy Sudiarto Raharjo
16 August 2008
25 comments

Introduction

We know that every operating system has a core, which called kernel. Kernel is a vital component in operating system design, since it is the core and it has a lot of function, such as managing input/output, filesystem, loading modules for additional hardware, and many other functions. Well developped kernel will make the system stable and less vulnerable. This is what happened in GNU/Linux kernel development lead by Linus Torvalds (main kernel) and Chris Wright along with Greg Kroah Hartman (-stable team). They maintain the kernel development process in order to make GNU/Linux sistem operating works better, faster, modern, and also up to date. Up until now, there are two major version in kernel development, 2.4.x and 2.6.x. The stable and development scheme is no longer used. Everything that comes up marked as final version is considered stable version.

Usually, if you have installed a distro (combination of kernel with a lot of collection of utilities and application) like Fedora Core, Mandriva, SuSE, Debian, they have included the kernel, but as the kernel development move on, sometimes you have to upgrade your kernel to the latest version, in order to get new facility, new hardware support, and also bug fix on the previous kernel. The process can be easy or difficult, depends on your skill and also the package you are using. If you use your distro's package (RPM, DEB, and TGZ), the process will be lot easier, since it has been prepared by the developer team and the only thing you have to do is install it and configure your boot loader configuration files. Meanwhile, if you tried to install from the original kernel source (called Vanilla), you have to learn few new things first. The process itself cannot be guarranted as 100% safe, so it's not for newbie or production machines, but in this article i will try to give some small tutorial on how to compile the kernel from source based on my experience with some help from some friends of mine. In this article, i will use Slackware as the main distro.

Preparations

Slackware 12.1 (the latest version of Slackware as i write this article) by default comes with 2.6.24.5 kernel. This kernel is not very out-of date, since the latest stable version is still 2.6.26.2 (this version will be used in this article). If you want to look how to install the kernel which is shipped with Slackware's CD, please look at my other article Installing Kernel on Slackware. This article will be the next step of that article, as it will try to build the kernel from source, not from the binary packages.

First of all, get the vanilla version of the kernel from the official site for GNU/Linux Kernel. Make sure you download the Full kernel, since there are some version shipped in the page. Next, you need your distro's config file. It will be used as a base to configure your future kernel. You can build it manually, but in my personal opinion, it's best to use your distro's config file and update it according with your requirements. It will be less pain and time, since you are sure that the config file is working and similar with your distro's configuration. In this case, i will use Slackware's config file which can be found at Slackware's repository under kernels/huge26.s directory. I usually use the slackware-current version, so the directory tree will be slackware-current/kernels/huge26.s/config (it will be different for each mirrors. I use OSUOSL mirror for example). I always put my config file on my Box.net account, so feel free to download it if you are wondering what kind of configuration i used.

The hotplug binary is not used anymore and all configuration can be done using only udev.rules contained in a new udev packages. Also, try to upgrade your GCC (GNU C Compiler) and GLIBC packages (and some other library for common development) to the latest version in Slackware-Current version before you compile the kernel. It will ensure you that the kernel will be configured with the latest GCC and GLIBC. I'm using GCC 4.2.3 and GLIBC 2.7 currenly, that is used in Slackware-Current (per 16 August 2008).

Installation

After the preparation steps has been finished, we can start the kernel installation. First of all, put the kernel into /usr/src directory and extract it using

tar -xjvf linux-2.6.26.2.tar.bz2

It will extract the kernel and make a new directory called linux-2.6.26.2. The process will take some time, as the kernel itself is big enough (around 46 MB with bzip2 compression). If it's finished, it's good idea to make some symlink from /usr/src/linux to point to your new kernel directory. You can delete the previous symlink if there is one and start making a new one with

rm /usr/src/linux
ln -s /usr/src/linux-2.6.26.2 /usr/src/linux

Next, put your Slackware config file into your kernel directory and rename it .config. After that, go into the directory. Type

cp /boot/config linux-2.6.26.2/.config
cd linux-2.6.26.2

Because you already have your config file, you don't have to configure all of the kernel build parameter by yourself. Just let the kernel knows that you are going to use your own config file rather than building it from scratch by typing

make oldconfig

When building newer kernel (for example 2.6.26.x and your system is running 2.6.25.x), new features will be asked and you will have to answer those questions. Always read the help provided by pressing "?". I always tried to avoid EXPERIMENTAL features as it's still too buggy. Any driver is recommended to be build as module and not bloating the kernel image itself.

After it's finished, you should edit the config file again, since Slackware config by default was set to use i486 architecture for the processor type. You can use several ways, but if you have graphical screen, i suggest you to use

make xconfig

Other possibility are

make menuconfig

In my situation, i changed the processor type into i586 and above, enable the HIGHMEM feature (4 GB), enable the kernel preemptive configuration (suitable for desktop), and add the APM module to make the CPU idle when not used (good for saving battery). You can add or modify the configuration to suit your need. When you are done configuring the kernel, save it and exit.

Next is the compilation process. Start by making the kernel image itself by typing

make bzImage

The process will take some time, so get yourself a cup of coffee and some snacks before you re-check your status. When it's done and without errors, the kernel is placed in arch/x86/boot/bzImage. Copy that file and put it in /boot and rename it into vmlinux-2.6.26.2 by typing

cp arch/x86/boot/bzImage /boot/vmlinuz-2.6.26.2

Next step will be compiling your modules. Do it by typing

make modules

Followed with

make modules_install

When the modules are installed, your next step will be copying System.map and config into your /boot partition

cp System.map /boot/System.map-2.6.26.2
cp .config /boot/config-2.6.26.2

All done with the hard stuff. Now edit /etc/lilo.conf to add an option to boot the new kernel. Make sure that you leave an option available to boot an old working kernel. Then, run "/sbin/lilo" and make sure there where no errors. Reboot, select the new kernel, and see if it worked. If not, reboot and select the kernel you were using before. Here's my lilo.conf :

#Linux bootable partition config begins
image = /boot/vmlinuz-2.6.26.2
  root = /dev/hdc9
  label = Linux-2.6.26.2
  read-only
# Linux bootable partition config ends

Here is my /boot :

README.initrd -> /usr/doc/mkinitrd-1.3.2/README.initrd
System.map -> System.map-2.6.26.2
System.map-2.6.26.2
boot.1600
boot_message.txt
config -> config-2.6.26.2
config-2.6.26.2
diag1.img
initrd-tree/
initrd.gz
map
slack.bmp
vmlinuz -> vmlinuz-2.6.26.2
vmlinuz-2.6.26.2
WARNING : MAKE SURE YOU DON'T MESS UP AND GET RID OF THE WORKING KERNEL. (Taken from Shilo's guidance)

When you reboot your system, try to log in into text mode. This way, you can reinstall some third-party modules, such as NVidia or ATI driver or it won't boot into graphical screen (if you set your run level into 4) when you have logged in using your account.

Test .. Test

If you find your kernel is working, Congratulations. But your work isn't finished yet. You have to make sure that every program is working fine with the new kernel. You should spent few hours (or days) to make sure that your kernel is working perfectly on your system. After that, you can delete the old kernel to save some space, or you can start tuning the kernel again so it will meet your ideal performance. Happy tweaking...

Conclusion

Installing kernel from source is not a hard process if you follow the instructions carefully. I would like to give my credit to Patrick J. Volkerding who has made Slackware and Shilo, who gave me a working guidance. Without their help, this article wouldn't be made.

Last Update : 2 July 2009 :: 17:47:27

Comments

1 Please visit my site
site
site
site
site
site
site
site
site
site

Regards

Posted by Harry Gunnoe on 14 Nov 2010 @ 21:06:08

2 Please visit my










Regards

Posted by Elizabet Magarelli on 13 Nov 2010 @ 08:47:40

3 Please visit my site, site1, site 2, site 3, site 4, site 5.

Regards

Posted by Maria Salte on 10 Nov 2010 @ 19:21:28

4 Hello,
Please see me site , site , site , site , site .
Regards.

Posted by Naida Weatherbee on 6 Nov 2010 @ 05:20:31

5 Hello,
Please see me site , site , site , site , site .
Regards.

Posted by Dayle Roecker on 3 Nov 2010 @ 20:45:06

6 Hello. See my site

Posted by Stefan Spittle on 26 Oct 2010 @ 16:42:02

7 Hello. See my site

Posted by Richard Stadnik on 26 Oct 2010 @ 11:33:04

8 Hello. See my site

Posted by Will Valaitis on 26 Oct 2010 @ 06:24:45

9 Please visit my site.

Regards

Posted by Ailene Petges on 22 Oct 2010 @ 12:11:51

10 Please visit my site.

Regards

Posted by Willetta Salome on 22 Oct 2010 @ 02:52:31

11 Please visit my site.

Regards

Posted by Hue Mconnell on 21 Oct 2010 @ 17:11:11

12 Please visit my site.

Regards

Posted by Darius Monforte on 21 Oct 2010 @ 07:42:44

13 Please visit my site.

Regards

Posted by Jeanie Phanthanouvon on 20 Oct 2010 @ 19:20:28

14 Please visit my site.

Regards

Posted by Paul Phearsdorf on 20 Oct 2010 @ 03:15:06

15 Please visit my site.

Regards

Posted by Teodoro Mentzel on 19 Oct 2010 @ 18:21:44

16 Please visit my site.

Regards

Posted by Erick Pniewski on 18 Oct 2010 @ 18:59:22

17 I thik that not everybody thing something about storage heaters (in polish dynamiczne piece akumulacyjne). Please read somethin about it. That is realy cheap electric heater.
You can heat big house and your bild for electric will be low.

Regards.
Denny Sammis

Posted by Stefany Obanion on 18 Oct 2010 @ 05:06:03

18 Please visit my site: storm

Regards.

Posted by Iona Parrent on 16 Oct 2010 @ 21:17:56

19 Please visit my site.

Regards

Posted by Kristofer Szopinski on 14 Oct 2010 @ 07:14:58

20 Houses are expensive and not every person can buy it. However, home loans are created to aid people in such situations.

Posted by MavisLUNA on 8 Mar 2010 @ 03:38:14

21 you did not mention about creating a new initrd. assuming i am using ext3, do i still need to generate a new initrd after compiling the kernel?
advance thanks!

Posted by ebros on 8 Aug 2009 @ 08:19:33

22 Sama-sama. Pastikan saja Anda membaca changelognya kernel dulu sebelum melakukan proses upgrade, karena biasanya rilis kernel final selalu ada perubahan dan paket-paket tertentu harus diupgrade

Posted by Willy Sudiarto Raharjo on 18 Jun 2006 @ 11:48:10

23 om Willy,
thank you for your guidance.
refreshing. . . . .

salam kenal

Posted by manaen on 6 Jun 2006 @ 11:27:24

24 Bukannya gak mau, cuma yang baca situs saya bukan cuma dari Indonesia, jadi paling aman ya pake bahasa universal aja. Sekalian buat belajar juga sih :D

Posted by Willy Sudiarto Raharjo on 29 May 2006 @ 08:26:35

25 Mendingan pake bahasa indonesia,
bahasa jawa lebih bagus :)
kalo bahasa inggris khan dah banyak pren ..

Posted by g on 26 May 2006 @ 16:02:08

Post Your Comments

Your Name: *Comment:
Kode Rahasia

*Write code above:
Note: * denotes required field