Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm interested in compiling a new kernel under Ubuntu 12.04 x86 64 bit.

I found this wiki page which is basically a mirror for this blog and there are a lot of steps (git, etc.) that appear useless to me.

With earlier releases/distros, I used to create a .config file and modify a Makefile if I needed to, then just run make and it's done.

Is there is a simple way to do this under Ubuntu?

share|improve this question
add comment

2 Answers

up vote 12 down vote accepted

1. Use apt-get source to download the Ubuntu version of the kernel

apt-get source linux-image-$(uname -r)

gives a folder that contains, for example:

linux-3.2.0                linux_3.2.0-26.41.dsc
linux_3.2.0-26.41.diff.gz  linux_3.2.0.orig.tar.gz

The bolded diff includes all the Ubuntu/Debian customizations.

2. To build a stock kernel with your own .config, use the "old-fashioned" Debian make-kpkg method

This is the alternate old-fashioned way described in the wiki.

sudo apt-get install kernel-package

If you are compiling a kernel for the first time.

sudo apt-get build-dep linux-image-$(uname -r)

Then

cd into the source directory (here, linux-3.2.0),

and either:

make oldconfig to create .config

with your running kernel's configuration, or copy a third-part .config to this directory Depending on whether you want a text or graphical config, install: Text:

sudo apt-get install libncurses5 libncurses5-dev

Graphical:

sudo apt-get install qt3-dev-tools libqt3-mt-dev

  • Then run

make menuconfig

(text) or for graphical

make xconfig

Which configures.

When done, just run

make-kpkg

with:

make-kpkg -j N --initrd --append-to-version=my-very-own-kernel kernel-image kernel-headers

where N is how many jobs to run in parallel (usually the number of CPUs you have), and my-very-own-kernel is a custom string to identify this build.

When done, the kernel image and header files will be ready as debs in the parent directory; you can simply install them with sudo dpkg -i, which will also take care of adding GRUB entries, etc.

share|improve this answer
    
why they tells you nothing about this diff, to me a diff is just a diff, it can contain everything. –  user827992 Jul 14 '12 at 10:22
    
I don't know, you would have to ask them (google for Canonical Kernel Team). I just told you how to build it ;) –  izx Jul 14 '12 at 10:29
    
ok, last question, how to apply this compressed diff? :D I have to go in the linux-3.2.0 directory and run patch -p1 <../patch.diff ? –  user827992 Jul 14 '12 at 10:48
    
There's no need to apply the diff; apt-get source ... did that for you already! –  izx Jul 14 '12 at 10:54
add comment

Worth checking out:

https://wiki.ubuntu.com/Kernel/BuildYourOwnKernel

share|improve this answer
1  
Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. –  Eliah Kagan Aug 10 '12 at 18:31
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.