Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




Chapter 7.  Upgrading a kernel

Inevitably it happens, you have a custom built kernel, working just wonderfully except for one little thing that you know is fixed in the latest release from the kernel developers. Or a security problem is found, and a new stable kernel release is made public. Either way, you are faced with the issue of upgrading the kernel and you do not want to lose all the time and effort that went into making that perfect kernel configuration.

This chapter is going to show how easy it is to update a kernel from an older versions, while still retaining all of the configuration options from the previous one.

First off, please back up the .config file in the kernel source directory. You have spent some time and effort into creating it, and it should be saved in case something goes wrong when trying to upgrade.

cd ~/linux/linux-

cp .config ../good_config

There are only five simple steps that are needed to upgrade a kernel from a previously built one:

  1. Get the new source code.

  2. Apply the changes to the old source tree to bring it up to the newer level.

  3. Reconfigure the kernel based on the previous kernel configuration.

  4. Build the new kernel.

  5. Install the new kernel.

The last two steps work the same as described before, so we will only discuss the first three steps in this chapter.

In this chapter, we are going to assume that you have built a successful kernel release, and want to upgrade to the release.

Download the new source

The Linux kernel developers realize that all users do not wish to download the entire source code to the kernel for every update. That would be a waste of bandwidth and time. Because of this, they offer a patch [7] that can upgrade an older kernel release, to a newer one.

On the main website, you will remember that it contained a list of the current kernel versions that are available for download:

Figure 7.1. The main web site

The main web site

Previously, you used the link pointed to you by the F to download the entire source code for the kernel. However, if you click on the name of the kernel release, it will download a patch file instead:

Figure 7.2. Downloading a patch from

Downloading a patch from

This is what we want to do when upgrading. But we need to figure out what patch to download.

Which patch applies to which release?

A kernel patch file only will upgrade the source code from one specific release to another specific release. Here is how the different patch files can be applied:

  • Stable kernel patches apply to the base kernel version. This means that the patch will only apply to the 2.6.17 kernel release. The kernel patch will not apply to the kernel or any other release.

  • Base kernel release patches only apply to the previous base kernel version. This means that the 2.6.18 patch will only apply to the 2.6.17 kernel release. It will not apply to the last 2.6.17.y kernel release, or any other release.

  • Incremental patches upgrade from a specific release to the next release. This allows developers to not have to downgrade their kernel and then upgrade it, just to switch from the latest stable release to the next stable release (remember that the stable release patches are only against the base kernel, not the previous stable release.) Whenever possible, it is recommended that you use the incremental patches to make your life easier.

Finding the patch

As we want to go from the kernel release, to the release, we will need to download two different patches. We will need a patch from the release to the release, and then from the release to the release. [8]

The stable and base kernel patches are located in the same directory structure as the main source trees. All incremental patches can be found one level lower, in the incr subdirectory. So, to find the patch that goes from to, we look in the /pub/linux/kernel/v2.6/incr directory to find the files we need: [9]

cd ~/linux


cd ok, cwd=/pub/linux/kernel/v2.6/incr
ls **.bz2

-rw-rw-r--    1 536      536          2872 Aug 22 19:23 patch-
get patch-

2872 bytes transferred
get patch-

7901 bytes transferred

ls -F

good_config linux- patch-  patch-

[7] It is called patch because the program patch takes the file and applies it to the original tree, creating the new tree. The patch file contains a representation of the changes that are necessary to reconstruct the new files, based on the old ones. Patch files are readable, and contain a list of the lines that are to be removed and the lines that are to be added, with some context within the file showing where the changes should be made.

[8] If you need to upgrade more than two versions, it is recommended as a way to save steps, to go backwards, and then upgrade forward. In this case, we could go backward from to 2.6.17 and then forward from 2.6.17 to

[9] In this example, we use the very good lftp FTP program to download the patch files. Any ftp program or a web browser can be used to download the same files. The important thing here is to show where the files are located.

  Published under the terms of the Creative Commons License Design by Interspire