Menu Close

How To Build Linux Kernel 3.2.0-7.13 For i7 Systems On Ubuntu 11.10

First a big thanks to Daniel Fletcher for pointing me in the right direction. Some things you should know before you start.. building your own kernel isn’t easy and it takes a lot of practise and rebuilding. There is not much info to be found about configuring the kernel so you will have to find out how it works by trial and error. This guide is for 32bit systems.

Before you start you need to install some extra packages you need to build the kernel. To install the packages open a terminal window and copy+paste the following lines:

sudo apt-get install fakeroot build-essential crash kexec-tools makedumpfile kernel-wedge libncurses5 binutils-dev libelf-dev libdw-dev libnewt-dev libncurses5-dev

sudo apt-get --no-install-recommends install asciidoc xmlto

Now you need to make a folder to work in, i made this folder on my desktop and named it build. To create the folder copy+paste the following line:

mkdir -p ~/Desktop/builds

Change into the builds directory using the following command:

cd ~/Desktop/builds

Now download the kernel source:

wget -c

Extract the content into the build folder:

tar -xzf linux_3.2.0-7.13.tar.gz

Now you need to create a soft link for the ubuntu-precise folder:

ln -s ubuntu-precise linux

Now cd into the ubuntu-precise folder using the soft link:

cd linux

Before creating the i7 flavour, you need to give execute permissions to the rules file and scripts folder in the debian folder:

chmod -Rv +x debian/rules
chmod -Rv +x debian/scripts/

To create the i7 flavour you can copy the generic flavour and save it as i7 flavour with the following command:

cp debian.master/config/i386/config.flavour.generic debian.master/config/i386/config.flavour.i7

Before editing the kernel config you need to clean and update the rules file inside the debian folder.

fakeroot debian/rules clean
fakeroot debian/rules updateconfigs

To edit the kernel config:

fakeroot debian/rules editconfigs

You only have to edit config: i386/config.flavour.i7. When done select exit and save the config file when prompted. If you disabled/removed something that you shouldn’t remove you will be notified about it and you will see an error message. If this happens you can reconfigure the kernel using the same command line.

In the next step you will copy the abi related files from the existing generic flavour and tweak them to reflect the newly created i7 flavour and copy the abi entries for the i7 flavour and add the i7 entries in vars and

cp debian.master/abi/3.2.0-6.12/i386/generic debian.master/abi/3.2.0-6.12/i386/i7

cp debian.master/abi/3.2.0-6.12/i386/generic.modules debian.master/abi/3.2.0-6.12/i386/i7.modules

sed -i s/getall\ i386\ generic\ server\ virtual/getall\ i386\ generic\ server\ virtual\ i7/g debian.master/etc/getabis

sed -i s/\=\ generic\ server\ virtual/\=\ generic\ server\ virtual\ i7/g debian.master/rules.d/

cp debian.master/control.d/vars.generic debian.master/control.d/vars.i7

sed -i s/\"Generic\"/\"core\ i7\"/g debian.master/control.d/vars.i7

In the next steps you will make some changes to the following files: the Makefile, arch/x86/Makefile and arch/x86/Makefile_32.cpu.

To edit the Makefile copy+paste the follwoing line:

gedit Makefile

When the Makefile is open search for the lines:

HOSTCC = gcc

And replace gcc with:

gcc -march=corei7 -mtune=corei7 -pipe

and g++ with:

g++ -march=corei7 -mtune=corei7 -pipe

In the arch/x86/Makefile you need to replace all the core2 with corei7 (don’t change CORE2).To edit the arch/x86/Makefile copy+paste the following line:

gedit arch/x86/Makefile

When done save and close the file.

In the arch/x86/Makefile_32.cpu file you need to replace all the core2 with corei7 (don’t change CORE2).To edit the arch/x86/Makefile copy+paste the following line:

gedit arch/x86/Makefile_32.cpu

When done save and close the file.

Now it’s time to do a clean build. To start building copy+paste the following line:

fakeroot debian/rules clean

Copy+paste the following line to build the common header and source debs:

skipabi=true skipmodule=true fakeroot debian/rules binary-indep

Use the following line to build the newly created flavor:

time skipabi=true skipmodule=true no_dumpfile=yes fakeroot debian/rules binary-i7

Now wait while the kernel is being built, this can take some time and it depends on the speed of your system.

When the kernel is built cd back into the builds directory with the following command:

cd ..

And to install the kernel copy+paste the following line:

sudo dpkg -i linux-headers-3.2.0-7_3.2.0-7.13_all.deb linux-headers-3.2.0-7-i7_3.2.0-7.13_i386.deb linux-image-3.2.0-7-i7_3.2.0-7.13_i386.deb

When installed you may need to reconfigure grub and you can do that with the following command:

sudo update-grub

When grub is reconfigured reboot your system. To check which kernel you are using open a terminal window and copy+paste the following line:

uname -a

The output should like this:


0 0 votes
Article Rating
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments