Upgrading the Kernel
From Freespire
To upgrade to a new kernel version we need to create new versions of each of the four layers. We will start with los-kernel-source-2.6.14:
Contents |
Upgrading the Source Package
# apt-get source los-kernel-source-2.6.14 # mv los-kernel-source-2.6.14-2.6.14.7 los-kernel-source-2.6.17 # cd los-kernel-source-2.6.17 # ls -lF total 42556 drwxr-xr-x 2 david david 464 2006-06-15 14:36 debian/ -rw-r--r-- 1 david david 39172170 2006-06-15 14:31 linux-2.6.14.tar.bz2 -rw-r--r-- 1 david david 1978 2006-06-15 14:31 Makefile -rw-r--r-- 1 david david 27436 2006-06-15 14:31 patch-2.6.14.7.bz2 -rw-r--r-- 1 david david 4312757 2006-06-15 14:31 patch-2.6.14.bz2 drwxr-xr-x 2 david david 3216 2006-06-15 14:36 patches/ drwxr-xr-x 2 david david 112 2006-06-15 14:36 scripts/ -rw-r--r-- 1 david david 2829 2006-06-15 14:31 setkver -rwxr-xr-x 1 david david 7874 2006-06-15 14:31 unpack*
In this directory we see some downloads from kernel.org: linux-2.6.14.tar.bz2, patch-2.6.14.7.bz2. (We also see patch-2.6.14.bz2, but this file is no longer used.) Lets download the latest stable kernel from ftp.kernel.org, and then edit the unpack script to use that instead of 2.6.14.7:
diff -ru unpack~ unpack
--- unpack~ 2006-06-15 14:31:59.000000000 -0700
+++ unpack 2006-07-18 10:14:24.000000000 -0700
@@ -40,8 +40,8 @@
let do_clean = List.mem "--clean" (Array.to_list Sys.argv)
- let base_version = "2.6.14"
- let patch_series = ["2.6.14.7"]
+ let base_version = "2.6.17"
+ let patch_series = ["2.6.17.6"]
let base_tarball = "linux-" ^ base_version ^ ".tar.bz2"
let base_dir = "linux-" ^ base_version
let kernel_version =
(I have downloaded the 2.6.17 tarball and the 2.6.17.6 patch, rather than just the 2.6.17.6 tarball, to save bandwidth when the 2.6.17.7 patch comes out.) Now we need to add an entry to debian/changelog to reflect the new version, and change uses of the 2.6.14 version number in debian/control:
--- changelog~ 2006-06-15 14:36:04.000000000 -0700 +++ changelog 2006-07-18 10:17:59.000000000 -0700 @@ -1,3 +1,9 @@ +los-kernel-source-2.6.17 (2.6.17.6-1) unstable; urgency=low + + * New kernel release. + + -- David Fox <david.fox@linspire.com> Tue, 18 Jul 2006 10:17:59 -0700 +
--- control~ 2006-06-15 14:31:59.000000000 -0700
+++ control 2006-07-18 10:19:34.000000000 -0700
@@ -1,15 +1,15 @@
-Source: los-kernel-source-2.6.14
+Source: los-kernel-source-2.6.17
Section: base
Priority: optional
Maintainer: David Fox <david.fox@linspire.com>
Build-Depends: debhelper, ocaml-findlib, libpcre-ocaml-dev, kernel-patch-mppe, bzip2
Standards-Version: 3.5.9.0
-Package: los-kernel-source-2.6.14
+Package: los-kernel-source-2.6.17
Architecture: all
Section: devel
Priority: optional
-Depends: bzip2, los-kernel-headers-2.6.14 (>= ${Source-Version})
+Depends: bzip2, los-kernel-headers-2.6.17 (>= ${Source-Version})
Provides: los-kernel-source, kernel-source, kernel-source-lindows, kernel-source-2.6
Description: Linspire Kernel Source Package.
This package contains the tarball of the source files of the Linux kernel
@@ -18,7 +18,7 @@
unpacked along with the kernel headers files before starting a kernel
module build.
-Package: los-kernel-headers-2.6.14
+Package: los-kernel-headers-2.6.17
Architecture: all
Section: devel
Priority: optional
@@ -28,14 +28,14 @@
tarball. It gets unpacked on install so that the /usr/src/linux link will
be valid.
-Package: los-kernel-link-2.6.14
+Package: los-kernel-link-2.6.17
Architecture: all
Section: devel
Priority: optional
-Depends: los-kernel-headers-2.6.14 (>= ${Source-Version})
+Depends: los-kernel-headers-2.6.17 (>= ${Source-Version})
Conflicts: los-kernel-link
Replaces: los-kernel-link
-Provides: los-kernel-link, los-kernel-headers-version-2.6.14
+Provides: los-kernel-link, los-kernel-headers-version-2.6.17
Description: Pull in kernel headers and provides the /usr/src/linux link
When you build kernel related code, you need to have a link /usr/src/linux
to the kernel source tree because libc has a link /usr/include/linux that
Now we can try to build the package. On the first run of dpkg-buildpackage we learn that the build dependency kernel-patch-mppe is needed, so we install it and try again. This time we learn that some of the patches applied by the unpack script will not apply to this kernel. The first failure is the edd.diff patch (in the patches directory.) Examining the file it is trying to modify (linux-2.6.17/arch/i386/boot/edd.S) we note with relief that that change has been applied to the kernel source, so we can safely remove the patch:
--- unpack~ 2006-07-18 10:28:35.000000000 -0700
+++ unpack 2006-07-18 10:28:18.000000000 -0700
@@ -126,9 +126,6 @@
(fun version -> apply ("../patch-" ^ version ^ ".bz2"))
Params.patch_series;
- (* This is from 2.6.17-rc1 *)
- apply "edd.diff";
-
(* BEGIN THIRD PARTY PATCHES *)
(*apply "patch-2.6.14-rc3-rt1";*)
Another build attempt. Predictably, the patch suspend2-2.2-rc15-for-2.6.14 doesn't apply to kernel 2.6.17. We must go to suspend2.net and download version 2.2.7 for kernel 2.6.17. We also need to modify unpack to use this new version:
--- unpack~ 2006-07-18 10:36:06.000000000 -0700 +++ unpack 2006-07-18 10:35:23.000000000 -0700 @@ -55,8 +55,8 @@ let suspend2 = true - let suspend2ver = "2.2-rc15" - let suspend2file = "suspend2-" ^ suspend2ver ^ "-for-2.6.14" + let suspend2ver = "2.2.7" + let suspend2file = "suspend2-" ^ suspend2ver ^ "-for-2.6.17" let suspend2dir = suspend2file let bootsplash = true
This time, it is the bootsplash patch that won't apply. Off to bootsplash.org to download version 3.1.6-2.6.15, with a corresponding modification to unpack:
--- unpack~ 2006-07-18 10:43:07.000000000 -0700
+++ unpack 2006-07-18 10:42:41.000000000 -0700
@@ -152,9 +152,9 @@
if Params.bootsplash then begin
(*apply "linux-2.6.12-rc5-git1-bootsplash-3.1.6.patch";*)
(*apply "bootsplash-extra.diff";*)
- apply "bootsplash-pre.patch";
- apply "bootsplash-3.1.6-2.6.13.diff";
- apply "bootsplash-post.patch";
+ (*apply "bootsplash-pre.patch";*)
+ apply "bootsplash-3.1.6-2.6.15.diff";
+ (*apply "bootsplash-post.patch";*)
end;
if Params.win4lin then begin
A number of other patches required modifications or removal, but an exhaustive list is outside the scope of this document - the list will be different for every version of the kernel. Suffice it to say that after several more attempts, all the patches applied and the build completed. Next task is to install the resulting .deb files and try to build los-kernel-image-2.6.17:
sudo dpkg -i ../los-kernel-source-2.6.17_2.6.17.6-1_all.deb ../los-kernel-headers-2.6.17_2.6.17.6-1_all.deb
../los-kernel-link-2.6.17_2.6.17.6-1_all.deb
The source and headers packages contain tarballs with, as you might expect, the kernel source and header files. These are installed as tarballs to save space and to make it easy to remove the unpacked version and re-extract the original files. The link package contains the link /usr/src/linux pointing to this particular version of the kernel source. The other layers of the kernel packaging use this link to determine what version of the kernel they are building modules for.
Upgrading the Image Package
Now we must retrieve and modify the los-kernel-image-2.6.14 package to build our new 2.6.17 kernel. As before, we use
cd .. apt-get source los-kernel-image-2.6.14 mv los-kernel-image-2.6.14-2.6.14.4 los-kernel-image-2.6.17 cd los-kernel-image-2.6.17
to retrieve the package, and then add an entry to debian/changelog to set the new version number, and change all occurrences of 2.6.14 in debian/control to 2.6.17. As usual, on our first build attempt we find there are build dependencies that need to be installed: in this case libdb3-dev and time. After those are installed, the next major task is to update the kernel config file for version 2.6.17. Soon after the build is started, the script will start asking questions about kernel configuration parameters that are new in 2.6.17, or have changed since 2.6.14. All these questions must be answered. We generally enable all kernel module options and try to enable any new features that don't seem dangerous or wasteful of CPU or memory resources.
Eventually it will stop asking questions and begin compiling the kernel. At this point it is very important to copy the modified config file, in kernel-source-2.6.17/.config, back to the location where the original was copied from, config. Then you should kill the build and restart it - if the config file has been properly modified and copied, there should be no more questions.
Oh, woe betide! A compile error:
CC mm/filemap.o
mm/filemap.c:396: error: redefinition of `__kcrctab_filemap_write_and_wait'
mm/filemap.c:369: error: `__kcrctab_filemap_write_and_wait' previously defined here
mm/filemap.c:396: error: redefinition of `__kstrtab_filemap_write_and_wait'
mm/filemap.c:369: error: `__kstrtab_filemap_write_and_wait' previously defined here
mm/filemap.c:396: error: redefinition of `__ksymtab_filemap_write_and_wait'
mm/filemap.c:369: error: `__ksymtab_filemap_write_and_wait' previously defined here
{standard input}: Assembler messages:
{standard input}:949: Error: symbol `__kcrctab_filemap_write_and_wait' is already defined
{standard input}:954: Error: symbol `__kstrtab_filemap_write_and_wait' is already defined
{standard input}:960: Error: symbol `__ksymtab_filemap_write_and_wait' is already defined
make[3]: *** [mm/filemap.o] Error 1
make[2]: *** [mm] Error 2
make[2]: Leaving directory `/mnt/sda3/dsf/tla/tos@linspire.com--skipjack/los-kernel-image--fos--2.6.17/kernel-source-2.6.17'
Command exited with non-zero status 2
Searching (grepping) around in the patches for "filemap_write_and_wait", I discover that the fat-flush-option-for-hotplug-devices.patch adds an export for this symbol. Then I downloaded the incremental patches patch-2.6.15.bz2, patch-2.6.16.bz2, and patch-2.6.17.bz2 and look through them for "filename_write_and_wait". Sure enough, an export for that symbol was added in the kernel 2.6.16 patch. Now we have to modify fat-flush-for-hotplug-devices.patch, rebuild the source packages, and retry our build of the image:
# cd ../los-kernel-source-2.6.17
(edit patches/fat-flush-option-for-hotplug-devices.patch)
# sudo dpkg-buildpackage
# sudo dpkg -i ../los-kernel-source-2.6.17_2.6.17.6-1_all.deb ../los-kernel-headers-2.6.17_2.6.17.6-1_all.deb
../los-kernel-link-2.6.17_2.6.17.6-1_all.deb
# cd ../los-kernel-image-2.6.17
# sudo dpkg-buildpackage
Eventually I had to disable the supermount patch pending updates from its maintainer, but the image package build succeeded. This produced the following debs:
- los-kernel-image-2.6.17_2.6.17-1_i386.deb
- los-kernel-image-drm-2.6.17_2.6.17-1_i386.deb
- los-kernel-image-alsa-2.6.17_2.6.17-1_i386.deb
- los-kernel-config-2.6.17_2.6.17-1_i386.deb
- los-kernel-default-image-2.6.17_2.6.17-1_i386.deb
- los-kernel-default-config-2.6.17_2.6.17-1_all.deb
Upgrading the Extras Package
The first step is to install all the debs we just created. It may be necessary to manually uninstall the los-kernel-default-config package first. Now we must build the los-kernel-extras package to get our third party modules. Next we retrieve the los-kernel-extras-2.6.14 package and add an entry to the debian/changelog file and modify the debian/control file to go from kernel 2.6.14 to 2.6.17. Now we need to make this package build -- this almost certainly means repeating the "Upgrading Kernel Modules" task described above for each misbehaving sub-package, or else disabling some sub-packages if you are in a hurry.

