Ubuntu Jaunty has been released a few days ago so it’s time write up an article on how to compile your own kernel for Ubuntu Jaunty.
As of Ubuntu Jaunty’s kernel 2.6.28-15.49 the kernel developers have made changes to the kernel source. The changes have such a big impact on how to compile a kernel for Ubuntu Jaunty that I had to revise this article. I wrote up a new article, I strongly suggest following the new article. I’m keeping this article for historic references.
I’ll be using git to get the latest kernel version. As I have described in previous articles, this is my favorite way to get the sources and it is in my opinion the fastest way to make changes later on when you want to update your own kernel to the latest version. I am compiling the i386 version, if you want to compile for amd64 you need replace i386 for amd64 throughout this article.
I suggest adding my Launchpad repository to get the latest version of git, follow the instructions of the article Updated git packages for Ubuntu Jaunty to add my repository.
Let’s get started on preparing our machine for compiling our own kernel for Ubuntu Jaunty.
Open a terminal.
sudo su - apt-get install fakeroot build-essential apt-get install crash kexec-tools makedumpfile apt-get build-dep linux apt-get install git-core libncurses5 libncurses5-dev
Create a directory where you would like to build your kernel, this directory will hold the kernel source in a sub directory and all the deb files will end up in this folder. I choose /d1/packaging/kernel/jaunty .
Getting the source
/d1/packaging/kernel/jaunty git clone git://kernel.ubuntu.com/ubuntu/ubuntu-jaunty.git source
The source code is installed in the directory source.
We will create a branch in which we will be doing our modifications. That way the master branch will stay in tact which will make future updates a whole lot easier.
To see the latest version:
cd source cat debian/changelog|more
Press q to get back to the prompt.
This results in something like this:
linux (2.6.28-12.43) UNRELEASED; urgency=low CHANGELOG: Do not edit directly. Autogenerated at release. CHANGELOG: Use the printchanges target to see the curent changes. CHANGELOG: Use the insertchanges target to create the final log. -- Stefan Bader
Thu, 16 Apr 2009 20:11:13 +0200 linux (2.6.28-11.42) jaunty; urgency=low
The latest version is the first version after the UNRELEASED section. In this case it is 2.6.28-11.42. Sometime there is no UNRELEASED section and in that case the latest version is the first version you see.
You could select any version you see in the changelog but for the sake of this article we’ll use the latest version.
git checkout Ubuntu-2.6.28-11.42 -b core2
This will create a branch called core2.
Creating a new config
I’ll be using the method of creating a new flavor, this adds a bit more work but you can always compile the original kernels.
Important: If you upgraded to Jaunty from a previous version of Ubuntu by using the update-manager or by hand using apt-get/aptitude and you were running a custom kernel you will need to create a new config based on the config of Jaunty. I used my “old” config file and ran into several strange behaviors.
To create a clean config:
cp debian/config/i386/config .config cat debian/config/i386/config.generic >> .config
If you want to compile a kernel for a server replace generic for server.
To make the modifications:
When you’re done we make a backup of the config file.
mv .config ../config.core2
Now we need to clean up the git tree
git reset --hard git clean -xdf
Getting ready for compilation
Because we are going to be creating a new flavor based on a existing flavor (generic in my case) we need to create some extra files. During compilation the process checks the previous release for some settings, as we’re creating a local flavor it doesn’t exist in the source, so we’re creating it. The previous release in this case is 2.6.28-11.42, you can the previous release
cp debian/abi/2.6.28-11.41/i386/generic debian/abi/2.6.28-11.41/i386/core2 cp debian/abi/2.6.28-11.41/i386/generic.modules debian/abi/2.6.28-11.41/i386/core2.modules cp ../config.core2 debian/config/i386/
We also need to edit some files
In the next few parts I’ll explain what you need to change
Search for the line:
getall i386 generic server
Change it in:
getall i386 generic server core2
Search for the line:
flavours = generic server
Change it in:
flavours = generic server core2
Files: debian/control.stub and debian/control
For both files we need to copy three sections:
- Package: linux-image-2.6.28-11-generic
- Package: linux-headers-2.6.28-11-generic
- Package: linux-image-debug-2.6.28-11-generic
A section is defined from the line Package to the next line starting with Package.
In the copied sections we need to replace “generic” with “core2″ on all the lines that start with Package.
Now we need to commit our changes in the git repository
git add . git commit -a -m "Core2 modifications"
The text after -m is the message you add to your commit.
It’s finally time for compiling.
CONCURRENCY_LEVEL=2 NOEXTRAS=1 skipabi=true skipmodule=true fakeroot debian/rules binary-core2
Because I have a Dual Core I want to utilize both processors by setting the CONCURRENCY_LEVEL. Set this to the amount of processors you have, if you have only one, just skip it completely. No matter grab yourself some coffee while we’re compiling.
It’s wise to also run the following.
CONCURRENCY_LEVEL=2 NOEXTRAS=1 skipabi=true skipmodule=true fakeroot debian/rules binary-indep
After the compilation is finished we’ll have several deb files in the parent directory. To install the files
cd .. dpkg -i linux-image-2.6.28-11-core2_2.6.28-11.42_i386.deb dpkg -i linux-headers-2.6.28-11-core2_2.6.28-11.42_i386.deb linux-headers-2.6.28-11_2.6.28-11.42_all.deb
Check your bootloader if the newly installed kernel is the default one, for grub edit the file /boot/grub/menu.lst
Reboot and enjoy your newly installed kernel.
In the next few days I’ll also post an article on how to update your custom if a newer version of the Jaunty kernel has been released.