How to compile a custom kernel for Ubuntu Intrepid

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.

For an overview of all articles on how to compile a kernel for Ubuntu check out the Compile a kernel for Ubuntu overview page

This article is filed under the categories Ubuntu » Compile a kernel and has the following tags associated with it: , , , , .
Showing 95 comments
Skip to the end and leave a comment.
  1. syko21

    Did you need to recompile the l-r-m or l-u-m modules for this or did they continue to work?

  2. Peter

    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.

  3. munkee

    Why use the 32-bit kernel, while the 64-bit one can support 4Gb without the need to recompile?

  4. slashdevdsp

    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

  5. Peter

    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.

  6. Peter

    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.

  7. slashdevdsp

    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.

  8. slashdevdsp

    ohh and could you point me to ubuntu wiki about compiling kernels, its been a while since i have compiled stuff

  9. Peter

    slashdevsp:
    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 ;-) It’s right here: https://help.ubuntu.com/community/Kernel/Compile

  10. slashdevdsp

    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

  11. Omid

    did you mean “cp .config ../config.core2″ to make backup? you wrote “mv”

  12. Peter

    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/

  13. Scot McPherson

    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).

  14. Eduardo

    It keeps telling me that my kernel is not clean, I am using linux 2.6.27-7.15, Any idea why??

  15. Peter

    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.

  16. Rob

    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?

  17. Peter

    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

  18. livio

    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

  19. Peter

    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.

  20. livio

    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.

  21. Krazzykule

    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

  22. Peter

    Re: Krazzykule

    What kernel version did you have and what version did you compile and try to install?

  23. Manish Shrestha

    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

  24. Peter

    @Manish
    I apologize Manish, to install ncurses you’ll need the libncurses5 and libncurses5-dev

  25. Manish Shrestha

    @Peter

    Thanks Peter. It went fine after installing libncurses5-dev.

  26. pachamama

    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?!

    • PL

      prepending
      no_dumpfile=true
      will help with this …

  27. Peter

    @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/)

  28. Krazzykule

    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

  29. Manish Shrestha

    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.

  30. Peter

    @Krazzykule and Manish

    What settings in the kernel configuration did you change?

  31. natros

    @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.

  32. Amnon Feiner

    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.

  33. Peter

    @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

  34. Amnon Feiner

    did a search for
    find / -name *.deb, nowhere to be found, they are not listed. I am missing something :-(.

  35. Peter

    @Amnon,

    Not sure what to make of it. Do you have enough free diskspace for the deb files?

  36. ancjr

    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.

  37. Peter

    @ancjr

    What changes did you make in the kernel config?

  38. Krazzykule

    I changed lots of things. Is there any file which show it?
    I can’t remember.

  39. ancjr

    @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!

  40. Peter

    @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

  41. ancjr

    @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! ;)

  42. Peter

    @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

  43. David

    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?

  44. Peter

    @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.

  45. David

    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.

  46. Peter

    @David

    Are you compiling a kernel for i386 or AMD64?

  47. David

    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!

    • Peter

      @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.

  48. Peter

    @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.

  49. andy

    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

    • Peter

      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.

      • andy

        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?

        • Peter

          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.

          • david barajas

            Was this done on a laptop or PC?

  50. JRobbo

    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

    • Peter

      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

  51. Mads Madsen

    If you get the error:
    “make: *** No rule to make target `binary-core2′. Stop.”
    Please verify that the config.core2 is present inside the debian/config/ directory, for some reason I did’t get the copied over probaly.

    Btw. great guide! :)

  52. Mjrwingnut

    when I typed in ” sudo apt-get build-dep linux”

    this is what I got:

    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    E: You must put some ‘source’ URIs in your sources.list

    Do I need to add some repositories to my sources.list?

    • Peter

      Yes you do.
      This is how to do add them:
      System -> Administration -> Software Sources

      In the tab: Ubuntu Software place a checkmark by sources. Click close -> Click Reload.

  53. Ethan

    Hi Peter,
    When I’m trying to compile the kernel, i get the following error:
    “/usr/src/linux-2.6.27 is not clean, please run ‘make mrproper’ i the ‘/usr/src/linux-2.6.27′ directory.

    I noticed you mentioned that this kinda error occurs when trying to compile kernel in the same directory as where you ran make menuconfig. But I “make menuconfig” in “/usr/src/linux” and try to compile the kernel at “/usr/src/linux-2.6.27″ as instructed in the guide. Why I still get this error? Where am I supposed to compile the kernel then?

    Actually, I’m a bit confused about this part of the guide. You first “cp linux-2.6-27 linux -r” and then “make menuconfig” with in /usr/src/linux. After that, you modify all the files in “/usr/src/linux-2.6.27″. I’m a newb and could you please explain a bit what exactly is doing here?

    Thanks

    • Peter

      I’m not sure why you get the not clean error message.

      Make sure you copy the Linux 2.6.27 directory and only do the configuration in the Linux directory. In your case my guess is you have the following two directories in /usr/src, linux-2.6.27 and linux. You might have other directories but they are not related to this guide.

      I copy the Linux 2.6.27 directory to Linux as a working directory. When you are done with the configuration you copy the config file to the parent directory and
      copy the configuration file you created to the directory Linux 2.6.27. It also provides you with a backup of your configuration.

      • Ethan

        You are right, peter. I have two directories in /usr/src: linux and linux-2.6.27. I followed the following steps:

        1. I ran “make menuconfig” in “/usr/src/linux”.

        2. After I configured, I “cp /usr/src/linux/.config /usr/src/config.core2″.

        3. Then “cd /usr/src/linux-2.6.27″. Modified all the files as instructed.

        4. Run the following command within “/usr/src/linux-2.6.27″:
        “CONCURRENCY_LEVEL=2 NOEXTRAS=1 skipabi=true skipmodule=true fakeroot debian/rules binary-core2″

        Then I got the following error:
        “/usr/src/linux-2.6.27 is not clean, please run ‘make mrproper’ i the ‘/usr/src/linux-2.6.27′ directory.”

        Did I make any mistakes among above steps?

    • Robert

      Go to your source dir and do the following ( worked for me on 8.04 Hardy ):

      cp -R debian ../
      make mrproper
      cp -R ../debian ./
      fakeroot debian/rules clean

  54. MjrWingnut

    What repositories should I add?

    • Peter

      You don’t have to add repositories, all you have to do is add the sources of the official Ubuntu repositories.
      This is how to do add them:
      System -> Administration -> Software Sources

      In the tab: Ubuntu Software you place a check mark by sources.
      Click close -> Click Reload.

  55. Chris

    How do you get the linux-image-debug package to build? I’m only getting the image and headers packages, not the debug package.

    I’m trying to get the crash utility to work, which needs the vmlinux file — hoping that gets built as part of the debug package. Any tips?

    Or, any tips on getting the crash utility to work on ubuntu intrepid, in general?

    • Peter

      vmlinux is a part of the debug package.
      To create the debug deb you will have to do the following

      sudo mkdir /CurrentlyBuilding

      Now do the normal compilation.

      When the compilation is done you will have to rename the debug package. By default the debug package is renamed so it won’t end up in Ubuntu’s repository. Instead of having the extension deb, the extension is ddeb. So rename it back to deb and you can install the package.

      Note that if you have the directory /CurrentlyBuilding and you do not want to build the debug package to be build add skipdbg=true to the compilation command:
      CONCURRENCY_LEVEL=2 NOEXTRAS=1 skipabi=true skipmodule=true skipdbg=true fakeroot debian/rules binary-core2

  56. trlkly

    Just had a thought. Have you talked to the Ubuntu developers about maybe including a package that includes your kernel “fix”? More and more people are using 4G+ memory and/or dual core in their computers.

    Even better would be if the installer could detect you needed it and install the “fixed” kernel…

    • Peter

      No I haven’t talked to the Ubuntu developers.
      I agree with the 4GB+ memory part, that should just be part of the generic kernel, right now it’s only part of the server kernel. And it doesn’t make a difference on how your computer operates if you don’t have 4GB of memory. Unlike having a processor specific kernel.

      The other thing is that if you start making different kernels for different hardware, like processors, you’ll end up with a whole bunch of kernels and they already took out the debug kernel image because it took to long to create it.
      And in all honesty I think the average person running Ubuntu on their desktop won’t even notice a difference between running a generic and a processor specific kernel, I know I don’t.

      Right now they have a generic, server and virtual kernel and I do believe that is the right way to go right now. Sometimes they also have a RT kernel, but the RT patches aren’t available for the kernel version Intrepid is running.

  57. bixejo

    Hi Peter,

    Thank you very much for this rocking howto.

    I’ve followed your instructions to create a customized flavour kernel (I set “kmon2″ as the flavour name).

    Everything went ok, but near to the end (I guess, after more than 3 hours compiling) I got the following error:

    ===========
    salsa20_i586 / salsa20_generic : salsa20
    padlock_sha / sha1_generic : sha1
    padlock_aes / aes_generic : aes
    padlock_sha / sha256_generic : sha256
    make: *** [install-kmon2] Error 1
    ===========

    I don’t know too much about this, but sounds to me like it’s trying to install the kernel rather of generating .deb files, and then I get this error as I did run it with “fakeroot” as you suggested, and not with “sudo”.

    I don’t get either .deb files for the kernel and headers.

    Any advice? Thank you very much again, and congrats for your excellent work.

    –Bixejo

  58. Pierre

    Hi Peter,

    thanks for your work of putting this up, worked like a charm for me !!

    I wanted NVidia acceleration *and* the full 4G RAM visibility with PAE,
    which is not available in the default ubuntu-desktop kernel.
    So I followed your tutorial to make my own kernel, starting from
    the default kernel after update (“2.6.27-11-generic”).

    In the make menuconfig I only added “High Memory Support” for 64GB
    in “Processor type and features” … created my own flavour named pae64g …
    compiled in a vmware virtual machine (70 minutes …)

    And after installation and reboot on the new kernel, the full 4G visible in ‘top’ !
    And the NVidia driver (menu System, Administration, Hardware Drivers)
    accepted to install itself on the custom kernel without any problem.

    Cheers,
    Pierre

  59. Ryan Egesdahl

    To the person above who had problems with the ‘makedumpfile’ part, and to all others with a similar problem, there is an environment variable you can pass to debian/rules that bypasses the command without having to edit any files:

    no_dumpfile=true

    Apparently, someone already thought of this problem.

  60. Robert

    I just did a build of the unmodified generic flavor and while my .deb is a reasonable 18.5MB my build generated 2.5GB of intermediate files and a bunch of additional .debs:

    linux-headers-lum-2.6.24-24-386_2.6.24-24.39_i386.deb
    linux-headers-lum-2.6.24-24-generic_2.6.24-24.39_i386.deb
    linux-headers-lum-2.6.24-24-server_2.6.24-24.39_i386.deb
    linux-image-debug-2.6.24-24-generic_2.6.24-24.53_i386.deb

    Why does it generate these 4 extra debs?

    I’m doing this for 8.04 Hardy but don’t think that should make a difference.

    • Peter

      It looks like you didn’t tell the compiler what flavor to build. To build the generic I believe you would say binary-generic.

      • Robert

        Sorry I wasn’t clear. I built both

        linux-headers-2.6.24-24-generic_2.6.24-24.53_i386.deb
        linux-image-2.6.24-24-generic_2.6.24-24.53_i386.deb

        I just got those other .deb *in addition* to the two above generic .debs.

  61. Robert

    Is there a guide to building a linux-ubuntu-modules flavour to go along with the custom kernel? I’m going to need some of the firmware and module from that package in my initramfs for my laptop to work properly. I’ve tried making similar alterations to what’s done for the kernel flavour but quite frankly I’m shooting in the dark with this debian build system.

  62. kaendesmut

    Hi: In other ‘kernel-compiling’ tutorials and books, the authors doesn’t recomend almost any operation under root privileges. Why do you make all as root? Is there any difference?

    • Peter

      There’s not a difference. Building it is non-root will work as well. There isn’t a really a reason why I build as root in this article.

      I personally never understood why most authors don’t want you to do stuff as root. As long as you are careful not much can go wrong.
      The things you need be root for is the installation of packages, the first few steps as well as the final step of installing the newly compiled kernel.

  63. garingz

    Hi ,
    I’m newbie in compiling kernel,
    i wanna ask, what i have to configure (after make menuconfig)
    if my kernel want to support for function of TSC (time stamp counter) like RDTSC or rdtscll?,
    because i’ve to compile some extension of program, then i getting error like this ;
    ……..
    common/scheduler.cc: In member function `void
    RealTimeScheduler::sync_cputicks()’:
    common/scheduler.cc:1059: `rdtscll’ undeclared (first use this function)
    common/scheduler.cc:1059: (Each undeclared identifier is reported only once
    for
    each function it appears in.)
    make: *** [common/scheduler.o] Error 1*
    ……..
    i’ve read some clues in mailing list and they said that i must compile complete kernel source, but after i compile my kernel, the same error still exist.

  64. Ken McD

    Peter, will you update this “apt-get” kernel compile method to reflect the recent changes as you’ve done for the “git” method?
    http://blog.avirtualhome.com/2009/09/08/how-to-compile-a-kernel-for-ubuntu-jaunty-revised/

    • Peter

      I’ll see what I can do.
      I haven’t used this method personally in a long time.
      It probably will be for Jaunty or maybe even Karmic.

      • Ken McD

        I was able to piece together enough information to make it work. Probably need to use the git method anyway. Looked to be too much work for me right now. Thanks for the helpful documentation!

  65. Ken McD

    When I use this method, my grub doesn’t seem to work right any more. Cold boot, I get the menu and my standard -generic kernel. BUT all reboots just load the new, custom -ken kernel. For reboots, the new, -ken kernel always loads, no matter what I have entered for default in menu.lst. AND when I reboot, Ubuntu never goes to text mode. http://paste.ubuntu.com/287960/

    • Peter

      What I noticed with Jaunty, I should check if it’s still the case, that if I reboot, it doesn’t really reboot. What I mean is I never saw my BIOS page which means the machine didn’t really turn of and on again. I’m not even sure if I ever saw the grub menu. I guess it goes unnoticed until you decided to have a different default startup kernel in grub, in your case #2.

      • Ken McD

        Exactly my situation.

      • Peter

        I just rebooted and everything is normal, I see my BIOS startup. The reboot problem occurred with the default kernel as well. Not sure what changed to make it work normally again.

    • Peter

      Edit the following file:
      /etc/defaults/kexec
      and check the line LOAD_KEXEC. Set it to false to reboot with BIOS.

      # Defaults for kexec initscript
      # sourced by /etc/init.d/kexec and /etc/init.d/kexec-load

      # Load a kexec kernel (true/false)
      LOAD_KEXEC=false

      # Kernel and initrd image
      KERNEL_IMAGE="/vmlinuz"
      INITRD="/initrd.img"

      # If empty, use current /proc/cmdline
      APPEND=""

      • Ken McD

        That worked!

        This test system is recent, from last 3-4 months. I have done a few updates and stock kernel updates. Other than that, this is basic system. I only started doing the kernel compile on it. And did it by using these kinds of instructions to keep my custom kernel separate from current and future stock kernel updates.

        ken@ken-ubuntu:~$ lsb_release -a
        No LSB modules are available.
        Distributor ID: Ubuntu
        Description: Ubuntu 9.04
        Release: 9.04
        Codename: jaunty
        ken@ken-ubuntu:~$

  66. Sham

    Hey nice tutorial, i followed some of your explanations and got a succesfully working kernel, i just wanna ask that now i want to create another kernel, do i have to remove the 2nd kernel and if not, is there anything i need to do like cleaning up for instance before restarting the process or can i go ahead and begin customising and compiling my 3rd kernel. I want to use the same kernel-source i used for the previous kernel i made, but i want to use the original config file i had in the 1st place.

    So basically im asking you to tell me what i need to do before repeating the same process again on the same system just so that i don’t face any hiccups while i’m at it. :)

    • Peter

      Do a clean up : sudo debian/rules clean
      and instead of compiling with binary-core2 (just using my example) you should compile with binary-i386 or binary-amd64, depending on your processor.

  67. shaun

    I get a similar error to the guy who posted comment 26, namely the following. You said at the time you could not help him/her….perhapps you could now as two people have got the same error ?

    Cheers, Shaun.

    WW: Explicitly asked to ignore failures (probably not good)
    II: New modules (you’ve been busy, wipe the poop off your nose)
    II: Done
    dh_testdir
    dh_testroot
    dh_clean -k -plinux-image-2.6.31-15-samsung
    dh_clean -k -plinux-headers-2.6.31-15-samsung
    dh_clean -k -plinux-image-debug-2.6.31-15-samsung
    # The main image
    # compress_file logic required because not all architectures
    # generate a zImage automatically out of the box
    install -m644 -D /home/guest/src/source/debian/build/build-samsung/arch/i386/boot/bzImage \
    /home/guest/src/source/debian/linux-image-2.6.31-15-samsung/boot/vmlinuz-2.6.31-15-samsung
    install -m644 /home/guest/src/source/debian/build/build-samsung/.config \
    /home/guest/src/source/debian/linux-image-2.6.31-15-samsung/boot/config-2.6.31-15-samsung
    install -m644 /home/guest/src/source/debian.master/abi/2.6.31-15.50/i386/samsung \
    /home/guest/src/source/debian/linux-image-2.6.31-15-samsung/boot/abi-2.6.31-15-samsung
    install -m644 /home/guest/src/source/debian/build/build-samsung/System.map \
    /home/guest/src/source/debian/linux-image-2.6.31-15-samsung/boot/System.map-2.6.31-15-samsung
    makedumpfile -g /home/guest/src/source/debian/linux-image-2.6.31-15-samsung/boot/vmcoreinfo-2.6.31-15-samsung \
    -x /home/guest/src/source/debian/build/build-samsung/vmlinux
    get_debug_info: Can’t create a handle for a new debug session.

    makedumpfile Failed.
    make[1]: *** [install-samsung] Error 1
    make: *** [binary-samsung] Error 2

    • celebro

      Had the same problem. Here’s something jbernardo wrote in topic for Jaunty:

      I just want to add that for those having problems with makedumpfile like the “get_debug_info: Can’t create a handle for a new debug session” because you removed kernel debug info while configuring it, you can pass “no_dumpfile=true” the same way you pass “skipabi=true” in the build line.

  68. Thahir

    Can u please tell me how to compile realtime kernel for ubuntu jaunty.
    Thanks

    • Peter

      You can’t compile a RT kernel for Jaunty with the Ubuntu kernel sources. The RT team never released a patch for the 2.6.28 kernel which is the kernel version Jaunty uses.

  69.  

Leave a comment

For questions and/or support consider using the forums.

find-complexional