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
sync

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

Install
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

Test


sudo reboot

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