I run Ubuntu Intrepid 8.10 on Dual Core 2 laptop with 4 GB of memory. The default kernel supplied by Ubuntu doesn’t support the 4GB memory, I could choose to run the server kernel but I also want to take advantage of the Core2 support in the kernel so I took it upon myself to compile a custom kernel.
Unfortunately the Ubuntu developers thought it was better to change the way kernel is build in Intrepid and the official Ubuntu How to compile a kernel on the Wiki isn’t set up for Intrepid yet. Most of the stuff I had to discover myself and to make sure I remember for the next time, but also to help benefit others for when they want to compile their own custom kernel, I decided to write it all down.
Updated: Nov 7, 2008
I’ll be doing everything as root.
First we need to install some applications so we can do the compilation:
apt-get install fakeroot build-essential apt-get install crash kexec-tools makedumpfile apt-get build-dep linux
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 as I package other software as well. All the commands I type will be done from this directory.
Getting the source
There are a couple of ways to get the kernel source from Ubuntu, using apt-get which this article is using or by using git. If you prefer to use git follow my other article I have written.
To get the source of your current running kernel, in my case it’s 2.6.27-7
apt-get build-dep linux-image-$(uname -r) apt-get source linux-image-$(uname -r)
The source code is installed in the directory linux-2.6.27.
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. Now for the fun stuff, editing the config so it fits my needs. I won’t go into detail which settings I changed, if somebody is interested I certainly can give that information. I use the current running config as my base. I create a copy of the kernel source to edit the config file.
cp linux-2.6-27 linux -r cd linux cp /boot/config-$(uname -r) . make menuconfig
When you’re done we make a backup of the config file.
mv .config ../config.core2 cd ..
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. My previous version is 2.6.27-7.13.
cd linux-2.6.27 cp debian/abi/2.6.27-7.13/i386/generic debian/abi/2.6.27-7.13/i386/core2 cp debian/abi/2.6.27-7.13/i386/generic.modules debian/abi/2.6.27-7.13/i386/core2.modules cp ../config.core2 debian/config/i386/
We also need to edit some files
- debian/scripts/misc/getabis
- debian/rules.d/i386.mk
- debian/control.stub
- debian/control
In the next few parts I’ll explain what you need to change
File: debian/scripts/misc/getabis
Search for the line:
getall i386 generic server
Change it in:
getall i386 generic server core2
File: debian/rules.d/i386.mk
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.27-7-generic
- Package: linux-headers-2.6.27-7-generic
- Package: linux-image-debug-2.6.27-7-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.
Compilation
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.
Installation
After the compilation is finished we’ll have two deb files in the parent directory. To install the files
dpkg -i linux-image-2.6.27-7-core2_2.6.27-7.14_i386.deb dpkg -i linux-headers-2.6.27-7-core2_2.6.27-7.14_i386.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.
Tags: 8.10, custom kernel, Git, how to, howto, Intrepid, Linux, linux kernel, Ubuntu







Entries (RSS)
Did you need to recompile the l-r-m or l-u-m modules for this or did they continue to work?
I don’t use the restricted modules myself and the ubuntu modules aren’t available.
I’m pretty sure you will have to compile them like previous releases of Ubuntu.
Why use the 32-bit kernel, while the 64-bit one can support 4Gb without the need to recompile?
You can find easier dependency/compilation/installation of kernel here, without touching/editing most of the files you describe above.
http://www.howtoforge.com/kernel_compilation_ubuntu
cheers
munkee:
Besides the 4GB I also changed some other options, like processor optimization, for my kernel and I also heard of problems with other software if you run 64bit, but I don’t know for sure.
slashdevdsp:
That describes compiling a vanilla kernel on Ubuntu, not the Ubuntu kernel. The use of make-kpkg also prevents you from compiling multiple flavors at once and according to the Ubuntu wiki it’s also the old-fashioned way.
i am pretty sure u can download the ubuntu-kernel source and build it, no different from building a vanilla kernel according to the howtoforge website, and I dont get the point of multiple flavours if you are going to be running it on a single machine, as I dont see myself booting to an optimised kernel just for playing games(one of the flavours) as for embedded devices it might make sense for evaluation. and from my understanding you can just wrap the whole thing in a script with different config files loaded from make menuconfig and using make oldconfig to reuse the base config for the new/ubuntu kernel.
ohh and could you point me to ubuntu wiki about compiling kernels, its been a while since i have compiled stuff
slashdevsp:
It’s right here: https://help.ubuntu.com/community/Kernel/Compile
In a business environment it comes in very handy to be able to compile multiple flavors. “Different” kernels for different machines, 64bit + 32bit for example, xen kernels, rt kernels etc.
Why do you want the wiki page, just follow my instructions
thanks for the info, i usually compile release kernels with ubuntu base configs althought i do compile them using cross compilers for my fpga boards, I could try to compile different flavours for my fpga board with varying different options at the same time
and thanks for the wiki link… damn i need to compile new kernels now again gah
did you mean “cp .config ../config.core2″ to make backup? you wrote “mv”
It wasn’t a typo, it doesn’t really matter if you do a mv or cp. I usually delete the linux directory after I have build my kernel.
A few steps later you do a cp of the config.core2 to the building directory and that way you have a backup of the config file.
In all honesty I prefer to use git to get the kernel source now-a-days, for instructions on using git to build a custom kernel see this article here: http://blog.avirtualhome.com/2008/10/28/how-to-compile-a-custom-kernel-for-ubuntu-intrepid-using-git/
You can mv the .config. menuconfig will just create a new one. THe difference is that your .config will help you with non-default defaults already chosen. Without a .config file, you might as well be compiling a vanilla kernel and will have to chose every options yourself (and pray you got them right if you are new to linux kernel compiling).
It keeps telling me that my kernel is not clean, I am using linux 2.6.27-7.15, Any idea why??
Re: Eduardo
Does it say you have to do make mrproper?
If so it probably means you are trying to compile your kernel in the same directory as where you ran make menuconfig.
When I run sudo apt-get install linux-kernel-devel fakeroot build-essential I get this error:
E: Couldn’t find package linux-kernel-devel
Any ideas?
Re: Rob
Thanks for reporting it should state:
apt-get install fakeroot build-essential
apt-get install crash kexec-tools makedumpfile
apt-get build-dep linux
I changed the document accordingly
But this is an horrible way to build a kernel!
do not exit procedure simple?
Developer don’t write a guide?
is very strange… developper don’t like user custom compilation kernel?
the old debian way use the linux-source with patch debian (or ubuntu)
why use this complicate procedure to build your kernel?
You have benefit for that?
For example i like to compile a kernel amd64
if i compile with the debian way the linux source i have a kernel_name.i386.deb , why this?
With your procedure is possible to obtain an amd64 kernel?
And what is the difference?
Tank you
Re: livio:
You can compile a AMD64 version for sure, you just have to update the right files, in short it means replacing all i386 with amd64 at the step Getting ready for compilation
The benefits of this procedure is that it allows you to keep the original configuration and you could essentially create several different flavors for different system configurations.
As I mentioned previously in the comments:
In a business environment it comes in very handy to be able to compile multiple flavors. “Different” kernels for different machines, 64bit + 32bit for example, xen kernels, rt kernels etc.
I don’t know why you get a i386 kernel when you use the old-fashioned Debian way, but I do think it’s a good reason not to use that method and use the above method.
I suppose i found the point:
The normal linux-source is a base kernel of distro (is old an 2.6.27-2 is the kernel of cd installation) and is a kernel vanilla + ubuntu patch
You compile with your config with old style debian way.
The kernel source for linux-image is the source of current (in use) kernel provided by git.
This kernel is “for developer”, have all config: x86, amd64 ecc ecc
BUT for exemple in my case:
i have kernel installed from ubuntu amd64 distro:
Linux 2.6.27-7-generic #1 SMP Tue Nov 4 19:33:06 UTC 2008 x86_64 GNU/Linux
this is equal to config (+ config.generic) present in amd64 directory of git kernel.
A this point it is possible to build with old debian way the kernel present on git,
the autobuild method is preferable to use only by developer for build of plus image with only one build operation or for flavour creator.
Hi!
I have just finished compiling my kernel, but when I try to install it, it stops and says me it cannot install nvidia(177.80) module. It is the first time I configure the kernel and maybe I made any mistakes when configuring the kernel, What do you think it could be?
Thanks
Re: Krazzykule
What kernel version did you have and what version did you compile and try to install?
Hello,
When I try to do make config, it returned me an error in ubuntu 8.10 linux 2.6.27-7-generic:
***Unable to find the ncurses library or the required header files.
*** make menuconfig requires the ncurses library
***Install ncurses (nacurses-devel) and try again.
But, when i tried to install ncurses-devel using apt get , it says
could not find package ncurse-devel.
it would be easier for newbies like me, if you had included the steps for it also
@Manish
I apologize Manish, to install ncurses you’ll need the libncurses5 and libncurses5-dev
@Peter
Thanks Peter. It went fine after installing libncurses5-dev.
Nice Howto but still my kernel will not compile.
I got the error:
makedumpfile -g /home/pachamama/src/linux-2.6.27/debian/linux-image-2.6.27-9-bieszkola/boot/vmcoreinfo-2.6.27-9-bieszkola -x /home/pachamama/src/linux-2.6.27/debian/build/build-bieszkola/vmlinux
get_debug_info: Can’t create a handle for a new debug session.
makedumpfile Failed.
make: *** [install-bieszkola] Fehler 1
I dried already different ways, at last with:
AUTOBUILD=1 NOEXTRAS=1 skipabi=true skipmodule=true skipdbg=true fakeroot debian/rules binary-bieszkola
Maybe you’ve an idea?!
@pachamama
I’m sorry, I’ve been trying to find more info about your error message but unfortunately there isn’t much out there, in fact this site pops up in 1st place when searching for “Can’t create a handle for a new debug session”
The only thing I can think of to do is to start over again and use the Git method (http://blog.avirtualhome.com/2008/10/28/how-to-compile-a-custom-kernel-for-ubuntu-intrepid-using-git/)
Hello:
I’m sorry but I forgot to post telling my success. But after installing the kernel and starting y realize it is slower than using the generic.
I compiled version 2.6.27-7-generic for a Intel Quad Core Q9300.
Can you help me to improve it?
Thanks
ya, I felt the same too. The transfer of data from USB to hard disk was slow. And the network interfaces were not working as well.
@Krazzykule and Manish
What settings in the kernel configuration did you change?
@pachamama
you have this error because you have removed the debug option from kernel configuration (which in my tests make it faster). just comment the two lines in debian/rules.d/2-binary-arch.mk that have the makedumpfile command.
I went through the entire process, and I cannot find
linux-image-2.6.27-7-core2_2.6.27-7.14_i386.deb
or
linux-headers-2.6.27-7-core2_2.6.27-7.14_i386.deb
I see them being created in the end of compilation.
@Amnon
It’s in the directory higher as where you compiled the kernel.
Example: Compilation in /home/amnon/kernel/linux-2.6
The deb files are in /home/amnon/kernel
did a search for
find / -name *.deb, nowhere to be found, they are not listed. I am missing something :-(.
@Amnon,
Not sure what to make of it. Do you have enough free diskspace for the deb files?
followed the directions to the letter, substituting “athlon-xp” for “core2″ where appropriate:
…
LD [M] drivers/video/vermilion/vmlfb.o
LD [M] drivers/video/vermilion/crvml.o
CC [M] drivers/video/sis/sis_accel.o
CC [M] drivers/video/sis/init.o
CC [M] drivers/video/sis/init301.o
CC [M] drivers/video/sis/initextlfb.o
LD [M] drivers/video/sis/sisfb.o
make[1]: *** [sub-make] Error 2
make[1]: Leaving directory `/root/linux-2.6.27′
make: *** [/root/linux-2.6.27/debian/stamps/stamp-build-athlon-xp] Error 2
not familiar with ubuntu, so i am completely lost here.
@ancjr
What changes did you make in the kernel config?
I changed lots of things. Is there any file which show it?
I can’t remember.
@peter
All changes were made under processor type & features. From memory: I turned off SMP, changed processor family to Athlon/k7, deselected generic x86 support, turned off the various laptop options and changed the timer freq from 250 to 300hz.
Thanks for your help!
@ancjr
You could deselect the Sis video driver if you don’t have use
Device Drivers -> Graphics support -> Support for frame buffer devices -> SiS/XGI display support
If you do / (slash) in make menuconfig and search for SIS it shows you what other options it depends on
Symbol: FB_SIS_300
Prompt: SiS 300 series support
Defined at drivers/video/Kconfig:1487
Depends on: HAS_IOMEM && FB_SIS
You can search for HAS_IOMEM and FB_SIS to see if they are selected as well.
I hope this helps a bit
@Peter
Ok, I got it to work after removing many unneeded modules/options. I also went ahead and did the git method from your other article. I started with a fresh install of Ubuntu and needed to install git-core, libncurses5, libncurses5-dev and edit debian/rules.d/2-binary-arch.mk as per natros’ suggestion.
Now, let’s see if it boots!
@anjcr
I’m glad it worked out for you. I’m sure it will boot
I’ll edit the page to add the files git-core, libncurses5, libncurses5-dev. Thanks for reporting
When I attempt to do the “fakeroot debian/rules binary-core2″ I get a message, “no rule to make target binary-core2. Stop.” I think I have done everything you said, but somehow something is missing. Can you guide me to what?
@David
Check the files
* debian/scripts/misc/getabis
* debian/rules.d/i386.mk
* debian/control.stub
* debian/control
for typo’s, especially the i386.mk file.
I’m sorry, Peter, but I double checked all the files. I didn’t find a typo anywhere; at least all the core2 substitutions are there. Sometimes a finger flick causes a typo elsewhere, but if so I didn’t catch it.
@David
Are you compiling a kernel for i386 or AMD64?
Peter, I hope this doesn’t show up twice — I just haven’t seen my response. I am compiling for i386. I am in the directory linux-2.6.27 while issuing the command, and have followed all your instructions as far as I can understand them. I’m running on Ubuntu Intrepid, on an HP Pavilion dv7 with dual processor (and I did include your “concurrency level” command).
Thanks so much for helping me!
@David
Sorry it seemed my anti-spam plugin thought you were a spammer, time to disable that thing again.
Here’s what I could do for you. If you tar up the debian directory and send it to me, I can see what happens here.
I’ll send you an email so you have mine to send it to.
@David
The file config.core2 in the directory debian/config/i386 is missing.
I deleted my file in my kernel compliation setup and get the same error.
having the same problem as David. I made sure that i copied the config.core2 and with no luck
/usr/bin/fakeroot: line 164: debian/rules: No such file or directory
persists
i am compiling for i386
It looks like you have a different error as Dan.
In your case the file debian/rules can’t be found.
When you start compiling make sure you are in the same directory as where the subdirectory debian exists.
In the example it would be linux-2.6.27.
make: *** No rule to make target `binary-core2′. Stop.
Sorry ! forgot to check that I was in right directory. Here is the new error that showed up.
by the way, in the guide where you edit control.stub and control. did you mean copy the package entry and append them to end of the file, and changing generic to core2?
Yes that’s what I meant.
Double check the files
* debian/scripts/misc/getabis
* debian/rules.d/i386.mk
* debian/control.stub
* debian/control
And make sure there are no typo’s in the core2 part.
If this isn’t the case please send a tar of the debian directory and send it to me. I’ll send you an email right now.
Was this done on a laptop or PC?
Hi Peter,
Excellent guide, thanks very much for posting. Can you please tell me what I need to change to enable the 32-bit kernal to use the full 4GB installed in my machine please? I had a look at the config file in /boot, and it already had CONFIG_HIGHMEM=y, but Ubuntu only recognises 3GB of the 4GB installed, so I guess there are other things that I need to change as well?
Again, many thanks for posting this, good stuff!
John
John,
You have to select 64GB memory to enable the full 4GB.
The easiest way to select it is by make menuconfig
Processor type and features ->High Memory Support