|How to Compile a Linux Kernel to a Newer Version|
|How to - Linux|
Page 1 of 2
This article describes how to compile a Linux kernel to a newer version. There are a couple of reasons you might want to upgrade the kernel. One is to take advantage of a specific new feature or driver. Another would be to protect your Linux PC against security vulnerability or just to maintain an up-to-date and healthy system.
Performance: A lot of times there is some general code clean up and algorithm fixes that will increase the performance of various parts of the kernel.
Features: Linux lags behind Windows for support of the newer hardware features. All of the PC hardware is created around the Windows API and therefore the Linux maintainers have to write a lot of the features from scratch. Currently, the APCI features are being heavily worked on and improved.
Bug Fixes: As long as Linux is being updated there is always going to be bug fixes.
The following table gives the step by step procedure to upgrade the Linux 2.4 Kernel. For 2.6 we need to have an initrd image also, which is shown in the next session.
Download the source tar ball example <linux-22.214.171.124.tar.gz> from the link given below:
Copy the source tar ball to /usr/src/linux-126.96.36.199.tar.gz.
Extract the tar ball using the following command:
This command creates the source directory linux-188.8.131.52 in the directory /usr/src.
After this it is better to clean the build tree for any left over files in the directory. There are two ways of cleaning it. You can do a mrpoper, it cleans all previous config files, dependency info and object files or you can do a make clean, which is what I am doing here.
Move the config file from /boot to /usr/src/ linux-184.108.40.206. (This is so that you do not have to select and verify all options, you do not have to do this step and step 6, if you are willing to sit and select/unselect all the options provided in the kernel configuration).
Move copied config file to .config.
Create a configuration to use for the kernel compile using the following command(execute the command from /usr/src/ linux-220.127.116.11 directory).
One limitation for using menu option is that, you need to have ncurses library installed. If your kernel does not support GUI or you do not have ncurses, then you can do the following:
After configuring the kernel for your hardware save your configuration and then run the following command:
This will check that all the dependencies and include files are in place for compilation to take place.
Compile the kernel. make bzImage starts the kernel compile. This will create a compressed kernel image.
"make modules" will start compiling the various modules that you asked to build.
Install the modules. make modules_install will take the newly compiled modules and place them in /lib/modules/. You definitely need to be root user at this point.
The newly compiled kernel will be in usr/src/ linux-18.104.22.168/arch/i386/boot as bzImage.
Copy the new kernel to /boot and rename it:
Copy the file /usr/src/linux-22.214.171.124/ System.map to boot directory.
Create a soft link for vmlinuz to the vmlinuz-126.96.36.199
Make a new “grub”entry for the new kernel in /boot/grub/grub.conf
For example the entry will be as follows:
Reboot the machine and at the grub prompt enter Red Hat Linux (linux-188.8.131.52) to boot the new kernel.
If the system boots properly then half of the work is done. Now check out the various devices and see if you haven't missed out some important device driver.