Home page of this blog

Sunday, January 22, 2012

Ready, 3 2 1 go!

The magic kernel version is 3.2.1 and I am running it. I like it.

Here are the dropbox download links of  64 bit ubuntu packages optimized for i7 (should support i3 and i5 as well) . If you feel building yourself, go below the download links

How to Build yourself

Here is how I built it from source with ubuntu patches optimized for i7 processors
  1. Install build dependencies
  2. Download kernel source and Ubuntu patches
  3. Extract and apply Ubuntu patches
  4. Create i7 flavour
  5. Modify makefile for i7 specific optimization
  6. Build and install
  7. Test

Install build dependencies

Open terminal/konsole and execute the following apt-get commands if you don't have essential build packages necessary for building kernel from source in Ubuntu

Install Build essential to build kernel

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

Download kernel source and Ubuntu patches

create a new directory for building kernels, usually in home folder
mkdir -p ~/Builds

change to newly created directory
cd ~/Builds

get the kernel source
wget -c http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.2.1.tar.bz2

get ubuntu patches
wget -c http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.2.1-precise/0001-base-packaging.patch
wget -c http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.2.1-precise/0002-debian-changelog.patch
wget -c http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.2.1-precise/0003-default-configs.patch

Extract and apply Ubuntu patches

extract kernel source
tar xjvf linux-3.2.1.tar.bz2

soft link to linux folder
ln -s linux-3.2.1 linux

change to linux folder
cd linux

apply ubuntu patches
patch -p1 < ../0001-base-packaging.patch
patch -p1 < ../0002-debian-changelog.patch
patch -p1 < ../0003-default-configs.patch

Create i7 flavour

provide execute permissions to debian scripts and rules
chmod -Rv +x debian/rules
chmod -Rv +x debian/scripts/

create a new flavour for i7
cp debian.master/config/amd64/config.flavour.generic debian.master/config/amd64/config.flavour.i7

clean and update configs
fakeroot debian/rules clean
fakeroot debian/rules updateconfigs

provide the processor type to CORE2 and above, choose 1000 HZ as kernel frequency
fakeroot debian/rules editconfigs

copy the abi of generic flavour and generic modules
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

reflect the new flavour in abi
sed -i s/getall\ amd64\ generic\ virtual/getall\ amd64\ generic\ virtual\ i7/g debian.master/etc/getabis

reflect the new flavour in amd64.mk
sed -i s/\=\ generic\ virtual/\=\ generic\ virtual\ i7/g debian.master/rules.d/amd64.mk

copy vars.generic to reflect new flavour
cp debian.master/control.d/vars.generic debian.master/control.d/vars.i7

change vars.i7 to more meaningful names from generic
sed -i s/supported\=\"Generic\"/supported\=\"Nehalem\"/g debian.master/controld.d/vars.i7
sed -i s/target\=\"Geared\ toward\ x86_64/target\=\"Geared\ toward\ i7/g debian.master/control.d/vars.i7

Modify makefile for i7 specific optimization

edit main Makefile to append march and mtune of gcc with the latest corei7 target
sed -i s/\=\ gcc/\=\ gcc\ -march\=corei7\ -mtune\=corei7/g Makefile
sed -i s/\=\ g++/\=\ g++\ -march\=corei7\ -mtune\=corei7/g Makefile

edit arch specific makefile to change core2 to corei7
sed -i s/core2/corei7/g arch/x86/Makefile
sed -i s/core2/corei7/g arch/x86/Makefile_32.cpu

Build and install

make sure all the changes are synced to disk

clean again
fakeroot debian/rules clean

build dependency packages
skipabi=true skipmodule=true fakeroot debian/rules binary-indep

build i7 optimized header and kernel
time skipabi=true skipmodule=true no_dumpfile=yes fakeroot debian/rules binary-i7

sudo dpkg -i linux-headers-3.2.1-030201_3.2.1-030201.201201121644_all.deb linux-headers-3.2.1-030201-i7_3.2.1-030201.201201121644_amd64.deb linux-image-3.2.1-030201-i7_3.2.1-030201.201201121644_amd64.deb


sudo reboot

Boot into newly installed kernel. If booting into new kernel fails, use Ubuntu default kernel


  1. I have i7 2600k and i want to optimize for avx.
    Could you please add relevant instructions for sandy bridge(avx) optimizations?

  2. Compiled and installed, thanks.
    But, I just have to change only the configuration in "config.flavour.i7" ?

  3. Just change this

    change corei7 in Makefile to corei7-avx

  4. Please answer to my question

    "...change only the configuration in "config.flavour.i7" ?"

    Thank you.

  5. You are still missing the actual ubuntu patches for things such as ureadahead and apparmor.

  6. I tried this kernel in linux Mint 11 (at work), worked great except the built in nvidia-current driver didn't work right, had to uninstall and download the nvidia one from their site, remove nvidia-current and installed theirs, now it's silky smooth. :)

    In linux Mint 12 (at home), The kernel didn't work. Kept getting kernel panics, so I built a new kernel from scratch, adding the ubuntu patches was the only difference and it's much smoother now too. Not sure If I can post them here somehow, or megaupload lol since they killed it though.

    I think the most noticeable changes going from 2.6 - 3.0 kernels to this one is just overall snappiness, Virtualbox seems faster, as well as my Samsung SSD. Netflix runs nice and smooth within virtualbox too. Now if only Directx 11 worked perfectly with all new games and ASIO was built into wine without requiring JACK or some hack wineasio driver I'd be able to completely switch :) At least now i'm just down to 2 apps.

  7. can i have a tutorial on how to install ubuntu 64 bit with BTRFS as the default file system with compression enabled?

    read the speed comparison at phoronix and i have been searching for some tutorial on the net to do it but couldnt find any on how to do so on a fresh ubuntu installation.

  8. Great tutorial! In my personal case, I'm compiling to the nocona Intel family. Replacing corei7 and i7 for nocona does the trick.

    One thing though, isn't it faster to build the kernel passing the -pipe flag to gcc?
    Another thing is, how can I instruct make to use a concurrency_level to my needs?

    Thank you.

  9. No need to explicitly tell concurrency_level,kernel makefile/latest gcc detects number of cores and utilizes it to the max!

    yes adding pipe speeds up which uses your RAM

  10. Just wanted to point out a small correction under the instructions for
    "change vars.i7 to more meaningful names from generic
    sed -i s/supported\=\"Generic\"/supported\=\"Nehalem\"/g debian.master/controld.d/vars.i7"

    There is an extra d in the at the end should read "control.d/vars.i7"

    Thanks for your excellent blog please keep it up! :-)

  11. Thanks for the correction, encouragement, I will try to build 3.4 ... at present I hopped to Linux Mint 13

  12. Awesome Sankaran! I'm building the 3.4.1 now too. Although I'm a bit confused where should I put the -pipe that andradeR had mention to speed up the compile, in the lines you provided?
    "sed -i s/\=\ gcc/\=\ gcc\ -march\=corei7\ -mtune\=corei7/g Makefile
    sed -i s/\=\ g++/\=\ g++\ -march\=corei7\ -mtune\=corei7/g Makefile"

  13. Below the lines "gcc march=corei7 ...", there will be -O2, next to it append -pipe

    1. ok so your saying to manually go into the Makefile and add -pipe after -O2 ?

      or can I do something like you have there
      (e.g. "sed -i s/\=\ gcc/\=\ gcc\ -pipe\=corei7\ Makefile" )

  14. Yeah, you could do that using sed

  15. What changes should I make in order to use with i5?