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-2.6.17.11
$
cp .config ../good_config
There are only five simple steps that are needed to upgrade a kernel from a
previously built one:
-
Get the new source code.
-
Apply the changes to the old source tree to bring it up to the newer level.
-
Reconfigure the kernel based on the previous kernel configuration.
-
Build the new kernel.
-
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
2.6.17.9 kernel release, and want to upgrade to the 2.6.17.11 release.
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 kernel.org website, you will remember that
it contained a list of the current kernel versions that are available for
download:
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:
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 2.6.17.10 patch will only apply to the 2.6.17 kernel release. The
2.6.17.10 kernel patch will not apply to the 2.6.17.9 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.
As we want to go from the 2.6.17.9 kernel release, to the 2.6.17.11
release, we will need to download two different patches. We will need a
patch from the 2.6.17.9 release to the 2.6.17.10 release, and then from the
2.6.17.10 release to the 2.6.17.11 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 2.6.17.9 to 2.6.17.10, we look in the
/pub/linux/kernel/v2.6/incr directory to find the
files we need:
[9]
$
cd ~/linux
$
lftp ftp.kernel.org/pub/linux/kernel/v2.6/incr
cd ok, cwd=/pub/linux/kernel/v2.6/incr
lftp ftp.kernel.org:/pub/linux/kernel/v2.6/incr>
ls *2.6.17.9*.bz2
-rw-rw-r-- 1 536 536 2872 Aug 22 19:23 patch-2.6.17.9-10.bz2
lftp ftp.kernel.org:/pub/linux/kernel/v2.6/incr>
get patch-2.6.17.9-10.bz2
2872 bytes transferred
lftp ftp.kernel.org:/pub/linux/kernel/v2.6/incr>
get patch-2.6.17.10-11.bz2
7901 bytes transferred
lftp ftp.kernel.org:/pub/linux/kernel/v2.6/incr>
exit
$
ls -F
good_config linux-2.6.17.9/ patch-2.6.17.10-11.bz2 patch-2.6.17.9-10.bz2