At the beginning of the year the Linux kernel 3.2 was released and Canonical has made it the official kernel for Ubuntu 12.04 LTS (Precise Pangolin), but what if you want to run the Linux kernel 3.2 on your Ubuntu 11.10 (Oneiric Ocelot)? Well you can, by compiling your own version following this step by step guide. We’ll be using the Ubuntu 12.04 LTS version of the Linux Kernel 3.2
Introduction
git
I’ll be using git to get the latest kernel version. 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 suggest adding my Launchpad repository to your system. The repository holds the latest version of git and is usually updated within a day of a new release of git, follow the instructions on the page Git Packages for Ubuntu to add my repository.
Architecture
I am compiling the amd64 which basically is the version used for all 64 bit versions, if you want to compile for i386 you need replace amd64 for i386 throughout this article.
Flavor
I choose the name i7 as the flavor name as I’ll be building a kernel geared towards my laptop which has a i7 processor. Besides the change of processor type in the configuration I also have some other changes but that’s beyond this article.
Preparations
Let’s get started by preparing our machine for compiling the Linux kernel 3.2
Open a terminal.
sudo su - apt-get install fakeroot build-essential apt-get install crash kexec-tools makedumpfile kernel-wedge apt-get build-dep linux-image-$(uname -r) apt-get install git libncurses5 libncurses5-dev libnewt-dev exit
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/development/kernel/ubuntu/precise
Getting the source
cd /d1/development/kernel/ubuntu/precise git clone git://kernel.ubuntu.com/ubuntu/ubuntu-precise.git source cd source
The source code of the kernel is installed in the directory source.
Creating a branch
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 it a whole lot easier when we want to update our own Ubuntu 11.10 kernel 3.2 at a later time.
To see all the available kernels available type the following command:
git tag|grep Ubuntu-3.2|sort -V
The Ubuntu kernel developers tag each version as Ubuntu- and therefore we can checkout the version we want as
git checkout Ubuntu-3.2.0-8.15 -b i7
This will create a branch called i7.
Don’t select kernels like Ubuntu-3.2.0-1403.3, where the number after the second dash is in the thousands. These are specialized kernels and they may not work on your specific machine.
Creating a new config
I’ll be using the method of creating a new flavor, this adds a bit more work but this allows you to always compile the original kernel, if you wanted to.
We’ll use the flavor you are currently running as the base for our own flavor being i7. Please note that, as discovered by one of the readers of this blog, the extension needs to be in small caps.
cp /boot/config-`uname -r` debian.master/config/amd64/config.flavour.i7 fakeroot debian/rules clean debian/rules updateconfigs
To make changes to the configuration file we need to edit the configuration file. The kernel developers have created a script to edit kernel configurations which has to be called through the debian/rules makefile, unfortunately you will have to go through all the flavors for this script to work properly.
debian/rules editconfigs
The script will ask you if you want to edit the particular configuration. You should not make changes to any of the configurations until you see the i7 configuration
Do you want to edit config: amd64/config.flavour.i7? [Y/n]
Make your changes, save the configuration and then keep answering no to any other questions until the script ends.
When you’re done, make a backup of the config flavor file.
cp debian.master/config/amd64/config.flavour.i7 ../.
Now we need to clean up the git tree in order to get ready for compilation.
git reset --hard git clean -df
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.
To see the previous release we use:
ls debian.master/abi
The previous release in this case is 3.2.0-8.14
cp debian.master/abi/3.2.0-8.14/amd64/generic debian.master/abi/3.2.0-8.14/amd64/i7 cp debian.master/abi/3.2.0-8.14/amd64/generic.modules debian.master/abi/3.2.0-8.14/amd64/i7.modules
Copy our flavored configuration file back.
cp ../config.flavour.i7 debian.master/config/amd64/
We need to edit some files:
File: debian.master/etc/getabis
Search for the line:
getall amd64 generic virtual
Change it in:
getall amd64 generic virtual i7
File: debian.master/rules.d/amd64.mk
Search for the line:
flavours = generic virtual
Change it in:
flavours = generic virtual i7
File: debian.master/control.d/vars.i7
This files does not exist and in order to make the compilation process aware of our own flavor we want to compile we need to create it.
cp debian.master/control.d/vars.generic debian.master/control.d/vars.i7
You can edit the file and make it your own.
arch="i386 amd64" supported="i7 Processor" target="Geared toward i7 desktop systems." desc="x86/x86_64" bootloader="grub-pc | grub-efi-amd64 | grub-efi-ia32 | grub | lilo (>= 19.1)" provides="kvm-api-4, redhat-cluster-modules, ivtv-modules, ndiswrapper-modules-1.9"
We need to commit our changes in the git repository.
git add . git commit -a -m "i7 Modifications"
The text after -m is the message you add to your commit.
Compilation
It’s finally time for compiling, to keep our newly created branch in pristine condition we will do the compilation in a separate branch. We keep our branch clean as this will help later on when we want to update our new branch to a newer kernel.
git checkout -b work fakeroot debian/rules clean
All the packages will be created in the directory /d1/development/kernel/ubuntu/oneiric
Create independent packages:
skipabi=true skipmodule=true fakeroot debian/rules binary-indep
The above statement will create the following deb files:
linux-source-3.2.0_3.2.0-8.15_all.deb linux-doc_3.2.0-8.15_all.deb linux-tools-common_3.2.0-8.15_all.deb inux-headers-3.2.0-8_3.2.0-8.15_all.deb
Create the tools package:
skipabi=true skipmodule=true fakeroot debian/rules binary-perarch
The above statement will create the following deb file:
linux-tools-3.2.0-8_3.2.0-8.15_amd64.deb
Create the flavour depended files:
skipabi=true skipmodule=true fakeroot debian/rules binary-i7
The above statement will create the following deb files:
linux-headers-3.2.0-8-i7_3.2.0-8.15_amd64.deb linux-image-3.2.0-8-i7_3.2.0-8.15_amd64.deb
Install the new Kernel
After the compilation is finished we’ll have the above packages in the parent directory.
To install the files
cd .. sudo dpkg -i linux-headers-3.2.0-8-i7_3.2.0-8.15_amd64.deb linux-headers-3.2.0-8_3.2.0-8.15_all.deb linux-image-3.2.0-8-i7_3.2.0-8.15_amd64.deb
Check your bootloader if the newly installed Ubuntu 11.10 kernel is the default one, for grub check the file /boot/grub/menu.lst or if you run grub2 check /boot/grub/grub.cfg
Reboot and enjoy your newly installed Ubuntu 11.10 kernel 3.2.

Hi,
I had to edit also this file debian.master/d-i/kernel-versions.in to successfully compile the kernel.
Nice article!
P.
Greetings, I appreciate this series of articles. I tried this step by step, but ended up getting:
Error! Bad return status for module build on kernel: 3.2.0-9-i7 (x86_64)
Even though all of the config and build steps looked fine. Any pointers on where to check what went wrong in the process?
One small note from someone still learning all the ropes. You say you chose the directory /d1/…, which I thought I would mimic to make sure I didn’t put anything in the wrong place. So I created this directory, with sudo since it is in the / level. I then used chown to give myself full permissions to this directory and all subdirectories I create in it (without sudo of course). Is this the correct procedure?
Thanks!!
“Error! Bad return status for module build on kernel: 3.2.0-9-i7 (x86_64)”
There should be more than this – what module failed? What error number (twenty-something?) Try finding it in editconfigs, and do some research on the module & kernel. I found a kernel link error when i removed amd_pci support – the community already had a two-line fix. In that case i (after backing it up) edited the ..pci/Makefile (which was exciting) and re-rolled the flavoured deb. No new commit needed.
Good luck!
Excellent write-up – thanks!! Worked as written on my dell tower desktop, currently compiling on this hp mini.
Further confirmed working on a x32 headless oneiric server via ssh, in addition to the x64 precise dual-core atom laptop and Pentium D tower
Correction – the 3.2 kernel doesn’t play nicely with my nvidia card (yet). Stepping down to 11.10 and 3.0. 3.2 doesn’t seem different anyway, except that it’s broked
that is, the closed source nvidia drivers are broken, in that they’re closed source.
“dpkg-gencontrol: error: error occurred while parsing Recommends field: grub-pc | grub-efi-i386 | grub-efi-ia32 | grub | lilo (BOOTLOADERgt;= 19.1)
dh_gencontrol: dpkg-gencontrol -plinux-image-3.2.0-8-i7 -ldebian/changelog -Tdebian/linux-image-3.2.0-8-i7.substvars -Pdebian/linux-image-3.2.0-8-i7 returned exit code 255
make: *** [binary-i7] Error 25″
After one hour of compilation, this is what I got
I’m very new to linux, and instead of using AMD64, i’m using i368… I followed everything on the instruction and changed everything from AMD64 to i368.. When I tweaked in the kernel was just the timer from 250hz to 1000hz… Please help!
I’m not sure but maybe grub-efi-i386 does not exist – ia32 refers to the i386 architecture
somewhere it needs the libncurses5-dev installed …
so now I also built my first kernel. *nice*
… as it clearly says on this site … must have missed that
Hi,
I do not understand why is there those commands:
cp debian.master/config/amd64/config.flavour.i7 ../.
…
cp ../config.flavour.i7 debian.master/config/amd64/
I have the same content of this file before/after those commands?
So, what is the point of it ?
thank you for answer,
regards,
Martin
He does a “git clean -df” just after that, so it would be lost unless you saved it somewhere outside of git.
/Ivar
This is great. Could you please make a post where you explain how to update to the latest version, and apply any checked-in changes? Thanks.
hmmm…. When I get to the Install New Kernel part I am getting errors…the rest went through like a dream.
I changed amd64 with i386 as I am using a 32bit and the name I used instead of i7 is t1…
sudo dpkg -i linux-headers-3.2.0-8-i7_3.2.0-8.15_amd64.deb linux-headers-3.2.0-8_3.2.0-8.15_all.deb linux-image-3.2.0-8-i7_3.2.0-8.15_amd64.deb
Errors:
done
root@christine:/usr/src/test1/source# cd
root@christine:~# dpkg -i linux-headers-3.2.0-8-i7_3.2.0-8.15_amd64.deb linux-headers-3.2.0-8_3.2.0-8.15_all.deb linux-image-3.2.0-8-i7_3.2.0-8.15_amd64.deb
dpkg: error processing linux-headers-3.2.0-8-i7_3.2.0-8.15_amd64.deb (–install):
cannot access archive: No such file or directory
dpkg: error processing linux-headers-3.2.0-8_3.2.0-8.15_all.deb (–install):
cannot access archive: No such file or directory
dpkg: error processing linux-image-3.2.0-8-i7_3.2.0-8.15_amd64.deb (–install):
cannot access archive: No such file or directory
Errors were encountered while processing:
linux-headers-3.2.0-8-i7_3.2.0-8.15_amd64.deb
linux-headers-3.2.0-8_3.2.0-8.15_all.deb
linux-image-3.2.0-8-i7_3.2.0-8.15_amd64.deb
root@christine:~# dpkg -i linux-headers-3.2.0-8-t1_3.2.0-15.24_i386.deb linux-headers-3.2.0-8_3.2.0-15.24_all.deb linux-image-3.2.0-8-t1_3.2.0-15.24_i386.deb
dpkg: error processing linux-headers-3.2.0-8-t1_3.2.0-15.24_i386.deb (–install):
cannot access archive: No such file or directory
dpkg: error processing linux-headers-3.2.0-8_3.2.0-15.24_all.deb (–install):
cannot access archive: No such file or directory
dpkg: error processing linux-image-3.2.0-8-t1_3.2.0-15.24_i386.deb (–install):
cannot access archive: No such file or directory
Errors were encountered while processing:
linux-headers-3.2.0-8-t1_3.2.0-15.24_i386.deb
linux-headers-3.2.0-8_3.2.0-15.24_all.deb
linux-image-3.2.0-8-t1_3.2.0-15.24_i386.deb
root@christine:~# linux-headers-3.2.0-8-t1_3.2.0-8.15_i386.deb
linux-headers-3.2.0-8-t1_3.2.0-8.15_i386.deb: command not found
root@christine:~# sudo dpkg -i linux-headers-3.2.0-8-i7_3.2.0-8.15_amd64.deb linux-headers-3.2.0-8_3.2.0-8.15_all.deb li
dpkg: error processing linux-headers-3.2.0-8-i7_3.2.0-8.15_amd64.deb (–install):
cannot access archive: No such file or directory
dpkg: error processing linux-headers-3.2.0-8_3.2.0-8.15_all.deb (–install):
cannot access archive: No such file or directory
dpkg: error processing li (–install):
cannot access archive: No such file or directory
Errors were encountered while processing:
linux-headers-3.2.0-8-i7_3.2.0-8.15_amd64.deb
linux-headers-3.2.0-8_3.2.0-8.15_all.deb
li
I am not seeing what I have done here to make it throw these errors…I see that it says no file or directory…but it makes no sense as the compilation of the kernel seemed to go just fine…
Did you changed directory after the compilation is finished?
The .deb files are placed in the parent directory of the directory you ran your compilation in.
Example:
/d1/kernel/source – holds the kernel source, where you run you compilation
/d1/kernel – holds the .deb files.
Whoo Hoo!!! It is working great!! thanks for the help…
I will be referencing your site in my blog if that is ok with you.
again thanks,
Christine
Not a problem, and of course it’s ok to reference this site.
thanks for the guide!! wondering if anyone can help here? i get as far as skipabi=true skipmodule=true fakeroot debian/rules binary-lemon (dont ask me why i named it lemon)
i get this as an output
l@le:~/kernel/source$ skipabi=true skipmodule=true fakeroot debian/rules binary-lemon
make: *** No rule to make target `binary-lemon’. Stop.
hope you can help here
thanks
Somewhere you left “i7″ and didn’t replace with “lemon.”
Hi,
Thanks for your article.
But I get the same output
Pavel% skipabi=true skipmodule=true fakeroot debian/rules binary-i7
make: *** No rule to make target `binary-i7′. Stop.
I have the same output than Lloir:
no hay ninguna regla para construir el objeto ….
help pleasee
I have the same output than Lloir:
no hay ninguna regla para construir el objeto “binary-i7″ ….
help pleasee
Got this error:
“dpkg: dependency problems prevent configuration of linux-headers-3.2.0-8-i7:
linux-headers-3.2.0-8-i7 depends on linux-headers-3.2.0-8; however:
Package linux-headers-3.2.0-8 is not installed.
dpkg: error processing linux-headers-3.2.0-8-i7 (–install):
dependency problems – leaving unconfigured”
trying to install “linux-headers-3.2.0-8-i7″
thanks a lot for this useful page
sorry, meant trying to install linux-headers-3.2.0-8
The non-i7 headers are called : linux-headers-3.2.0-8_3.2.0-8.15_all.deb
The exact numbering might be different, depending on the kernel version you compiled.
where i have to create /d1/development/kernel/ubuntu/precise folders? after creating these folder i did run cd /d1/development/kernel/ubuntu/precise but getting error messege “bash: cd: /d1/development/kernel/ubuntu/precise: No such file or directory”
Would these steps work for building a non “ubuntu” tagged kernel? Such as if I cloned the 3.4.x branch from the kernel.org git repository?
My intent is to compile and build the kernel to create drivers for the linux-media (v4l-dvb) project. So, I need to use the latest development branch.
If the steps in this tutorial won’t work, could you create a tutorial for building/installing a non-ubuntu kernel?
Thanks, and have a great day:)
Patrick.
It’s on my to-do list, I actually compiled the 3.3 kernel myself this week. I’m hoping to put it all in writing early next week.
@Patrick_Dickey – In the meantime, here’s the Ubuntu writeup on compiling mainline/upstream kernels: https://wiki.ubuntu.com/KernelTeam/GitKernelBuild. Ubuntu isnt’ rolling 3.3 kernels (yet) so you’ll pull from Linus. If you’ve already used Peter’s method you can copy those scripts and headers to use in the overlay directory.
It works well, but check the step numbers if you use the ubuntu-package overlay method.
check out localmodconfig to save yourself some cycles.
also, try distcc if you’ve got a spare machine. Freakin’ amazing. I just compiled 3.3.0 in ~1.5hr on my mini running a single-core Atom N455. The desktop did the heavy lifting.
@#Peter, thanks again for this series – you totally got me hooked!
also, try xconfig – the nested menus are nice, and the search function is a boon
@Matt
I’m glad I got you hooked
@Peter – thank you very much, it works good here.
How about the ubuntu extra patch for aufs, dm-raid4-5, fsam7400 and ndiswrapper?
how to include them ?
i’m waiting for your 3.3 tuts
once again, thank you for this tutorial.
have a great day.
everything was going fine as per ur tutorial,,but as i gave the command fakeroot debian/rules clean it gives error
sed: can’t read debian.master/changelog: No such file or directory
and i am stucked at this point..
plz help me out
Followed your instructions but got:
dpkg-gencontrol: error: package linux-image-3.2.0-16-new not in control info
dh_gencontrol: dpkg-gencontrol -plinux-image-3.2.0-16-new -ldebian/changelog -Tdebian/linux-image-3.2.0-16-new.substvars -Pdebian/linux-image-3.2.0-16-new returned exit code 255
make: *** [binary-new] Error 25
what is getall? where do i find it
Hello there! Thank You for great tutorial, it is working just with 7.0.4 RC kernel.
But this version not stable and there will be next, so please, can You add information – how to update my local copy of kernel (after commit) from source up to latest changes on site? Thaqnk You very much!
Hello!
Can someone can tell me how to use “make localmodconfig”