Home page of this blog

Wednesday, October 26, 2011

Custom 64 bit Ubuntu Kernel 3.1 optimized for i3, i5 and i7


Kernel 3.1

I built the 64bit kernel 3.1 for my Kubuntu 11.10 desktop optimized for i7. Here is the screenshot of the kernel in action


Feel of the new kernel 3.1 seems to be very exciting. Kubuntu booted to login screen within 10 seconds. (With default kernel it took more than 20 seconds to boot Kubuntu 11.10 unlike ubuntu 11.10 which was faster to boot)

Here is how I built the kernel 3.1 Ubuntu way (in short 7 steps)

In brief
  1. Install build dependencies
  2. Download kernel source and ubuntu patches
  3. Extract and apply ubuntu patches
  4. Create a new flavour and tweak kernel config
  5. Modify Makefile for optimization
  6. Build
  7. Reboot and Enjoy

In detail

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

Download the source of newly released linux kernel 3.1. The following wget -c makes it simple to download from commandline


#Download kernel source



wget -c http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.1.tar.bz2


Here is how to download the 3.1 ubuntu patches

#Download ubuntu patches
wget -c http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.1-oneiric/0001-base-packaging.patch
wget -c http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.1-oneiric/0002-debian-changelog.patch
wget -c http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.1-oneiric/0003-default-configs.patch


Extract and apply ubuntu patches

Extract downloaded kernel source and apply patches. Here I used tar to unzip the bzip tarball and patch to apply the patch


#Extract kernel source



tar xjvf linux-3.1.tar.bz2


#Create a soft link 

ln -s linux-3.1 linux


#Enter linux directory

cd linux

#Apply the patches

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


Create a new flavour and tweak kernel config

Before creating a new flavor, give execute permissions to debian build scripts for building the kernel properly


#make debian/rules as executable

chmod -Rv +x debian/rules

#make debian/scripts directory executable

chmod -Rv +x debian/scripts/

To create a new flavour, just clone from generic flavor, here is how

#create i7 flavor
cp debian.master/config/amd64/config.flavour.generic debian.master/config/amd64/config.flavour.i7

Do the kernel configuration, I selected processor type as CORE2 and kernel frequency to 1000HZ (just give y only to the newly created flavor when executing editconfigs)


#clean
fakeroot debian/rules clean
fakeroot debian/rules updateconfigs
#give y only to i7 flavor, leave the rest untouched
fakeroot debian/rules editconfigs

Copy the abi related files from existing generic flavor and tweak to reflect the newly created flavor

#copy the abi entries for i7 flavor and add i7 entries in vars and amd64.mk
cp debian.master/abi/3.0.0-12.20/amd64/generic debian.master/abi/3.0.0-12.20/amd64/i7
cp debian.master/abi/3.0.0-12.20/amd64/generic.modules debian.master/abi/3.0.0-12.20/amd64/i7.modules
sed -i s/getall\ amd64\ generic\ server\ virtual/getall\ amd64\ generic\ server\ virtual\ i7/g debian.master/etc/getabis
sed -i s/\=\ generic\ server\ virtual/\=\ generic\ server\ virtual\ i7/g debian.master/rules.d/amd64.mk
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



Modify Makefile for optimization

This is the place where we apply the optimizations. Ubuntu 11.10 comes with gcc 4.6 which has added new architectue corei7


#edit arch/x86/Makefile and arch/x86/Makefile_32.cpu if you want to tweak the march and mtune params of gcc

vi Makefile

vi arch/x86/Makefile

vi arch/x86/Makefile_32.cpu

In the main makefile, I changed HOSTCC and HOSTCXX to look as follows


HOSTCC       = gcc -march=corei7 -mtune=corei7 -pipe

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



In other makefiles, replace lowercased core2 with corei7 (simple isn't it?)

Build

Do a clean build


#clean and build

fakeroot debian/rules clean



The following builds the common header and source debs

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

The following builds the newly created flavor. Note I added no_dumpfile=yes as it was not building the dumpfile.

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

Wait for sometime (depends on speed of your processor). No need to tweak concurrency settings, which are taken care automatically. Install the newly built debs as follows after going one directory above

cd ..

sudo dpkg -i linux-headers-3.1.0-030100_3.1.0-030100.201110241006_all.deb linux-headers-3.1.0-030100-i7_3.1.0-030100.201110241006_amd64.deb linux-image-3.1.0-030100-i7_3.1.0-030100.201110241006_amd64.deb

Reboot and Enjoy

To test the newly built kernel, reboot and select the newly installed kernel from grub. If the newly installed kernel does not boot for some reason, do not panic, select the old ubuntu kernel and boot. (Grub2 does not wait beyond 3 seconds if there is no other OS present and very annoying, press escape within first 3 seconds to display the grub menu if it does not display) Follow this to know more about how to customize grub2 http://maketecheasier.com/mastering-grub-2-the-easy-way/2009/11/19

or

https://wiki.ubuntu.com/Grub2

sudo reboot

Download links

I have uploaded the kernel 3.1 debs which I built and use.  If you don't want to build yourself you can try these.

Here are the SHA256SUM checksum


8d1c58d614056b3cb2e05562d1108cd0a25aa7900ea02f602e8da7a6ead00c83  buildscript.sh

3cbd100b33734330f6b4da7a25cce5c0a45db9cee16bf609c554cbc9cd7b3f98  linux-headers-3.1.0-030100_3.1.0-030100.201110241006_all.deb

6ad9338017182590ef791ed12bbcaf0857090fb6028ec90b6d81ea04c38948f5  linux-headers-3.1.0-030100-i7_3.1.0-030100.201110241006_amd64.deb

e1d62da1add7bfc0b9976fac7d8be32512da8eb09c5b41a6ab66b8c43d12b52e  linux-image-3.1.0-030100-i7_3.1.0-030100.201110241006_amd64.deb

Here are the download links



Tuesday, October 18, 2011

Ubuntu Oneiric Kernel Compilation



This tries to document how to build custom kernel for amd64 architecture the ubuntu way.

Install dependencies

These dependencies are required for building linux 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

sudo apt-get build-dep linux


Get kernel source code


Create a new folder/directory, this should be in a partition which has atleast 10 GB free space 

mkdir Builds
cd Builds
apt-get source linux-image-$(uname -r)


Work on copy of the kernel source


Take a copy of the kernel downloaded. By mistake some setting is changed, we can work on another fresh copy

cp linux-3.0.0 linux -r
cd linux

Create a new flavour


Here is giving execute permissions to debian build scripts before creating a new flavour

#make debian/rules as executable
chmod -Rv +x debian/rules
#make debian/scripts directory executable
chmod -Rv +x debian/scripts/

Here I create an i7 flavour (which should run on i3, i5 and i7)

#create i7 flavor
cp debian.master/config/amd64/config.flavour.generic debian.master/config/amd64/config.flavour.i7
#clean
fakeroot debian/rules clean
fakeroot debian/rules updateconfigs

Here is the place where we give kernel configuration (I changed kernel frequency from 250 HZ to 300 HZ and changed processor to CORE2)

#give y only to i7 flavor, leave the rest untouched
fakeroot debian/rules editconfigs

The following are to do with the ABI settings which we clone from existing Ubuntu and modify just the names to reflect our flavour

#copy the abi entries for i7 flavor and add i7 entries in vars and amd64.mk
cp debian.master/abi/3.0.0-12.19/amd64/generic debian.master/abi/3.0.0-12.19/amd64/i7
cp debian.master/abi/3.0.0-12.19/amd64/generic.modules debian.master/abi/3.0.0-12.19/amd64/i7.modules
sed -i s/getall\ amd64\ generic\ server\ virtual/getall\ amd64\ generic\ server\ virtual\ i7/g debian.master/etc/getabis
sed -i s/\=\ generic\ server\ virtual/\=\ generic\ server\ virtual\ i7/g debian.master/rules.d/amd64.mk
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

Modify makefile


vi Makefile


I changed only the main makefile HOSTCC and HOSTCXX as follows

HOSTCC       = gcc -march=corei7 -mtune=corei7
HOSTCXX      = g++ -march=corei7 -mtune=corei7



These are other makefiles to have a look at

vi arch/x86/Makefile
vi arch/x86/Makefile_32.cpu

Build


Clean before doing a build

#clean and build
fakeroot debian/rules clean

Just build and Ubuntu will take care of creating concurrent builds based on your processor count

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

Install

The built deb packages are in the parent directory, so change to previous directory

cd ..

The following installs the newly created flavour

sudo dpkg -i linux-headers-3.0.0-12_3.0.0-12.20_all.deb linux-headers-3.0.0-12-i7_3.0.0-12.20_amd64.deb linux-image-3.0.0-12-i7_3.0.0-12.20_amd64.deb

Reboot and enjoy

Here is screenshot showing i7 kernel in gnome-system-monitor



P.S: If you are lazy or scared to build your own custom kernel, wait till tonight. I am starting to office ... and will upload tonight

Here is the i7 optimized builds which I am using and can be used on any 64bit i3, i5 or i7

Kernel Image :  http://www.mediafire.com/file/tb9fo7omoaa8pxc/linux-image-3.0.0-12-i7_3.0.0-12.20_amd64.deb
Kernel Headers : http://www.mediafire.com/file/47s4dkbz5bf8ij3/linux-headers-3.0.0-12-i7_3.0.0-12.20_amd64.deb
Kernel Headers All : http://www.mediafire.com/file/ktw2d9d2qoyh3yz/linux-headers-3.0.0-12_3.0.0-12.20_all.deb
Oneiric Kernel Build Script : http://www.mediafire.com/file/pn3xmszxl9sy9cr/OneiricKernelCompilation.sh

SHA256SUMS-Oneiric.txt : http://www.mediafire.com/file/wvun5qrjim04j7q/SHA256SUMS-Oneric.txt


SHA256SUMS



ba00c0c3ee5d0875ea961f2ff4c7e54c460eb298b22c58e85d570f112ca323dd  linux-headers-3.0.0-12_3.0.0-12.20_all.deb
dcf30712689180ea6bb4d7d361c6660063c3a446531313989ee968deb9aa4927  linux-headers-3.0.0-12-i7_3.0.0-12.20_amd64.deb
f587a9d5ea51c5ec39b633b2ed64e63b06b9bc34dc25137729d6e969ce424766  linux-image-3.0.0-12-i7_3.0.0-12.20_amd64.deb
ed287ac072c0ee94cc79fd274cf81659259d06b244b70664ef95acc3ea507ec9  OneiricKernelCompilation.sh

Monday, October 17, 2011

Starting/Stopping x in Ubuntu 11.10

Today I spent my evening time in just installing/rebooting/restarting X server, installing xubuntu, installing ubuntu 11.10 just to get unity 3d right.

In the experiments, I learned a new thing about Ubuntu 11.10

It does not use gdm but uses lightdm


To stop the xserver, goto virtual console 1 (Ctrl + Alt + F1)

sudo service lightdm stop


To start the xserver, from virtual console 1 (Ctrl + Alt + F1)

sudo service lightdm start


Thought posting this may help someone having struggle with graphics drivers. Of course inserting/reinserting nvidia driver is trivial once the above is figured (sudo rmmod nvidia, sudo modprobe nvidia or sudo modprobe nvidia_current)

Finally after playing/experimenting for half a day, I figured that I am not supposed to mount tmpfs on RAM with noexec which caused failure in running scripts from RAM. Thank goodness I figured it finally

Saturday, October 15, 2011

Hi Kubuntu, bye Ubuntu

Title says it all.

I like rekonq browser, it is super fast. I am going to install Kubuntu 11.10

Hi Kubuntu

Here is the screen after Kubuntu live cd boots into



Here are the installation screenshots



Nice option asking to unmount mounted partitions before installing (see below)






See the top status bar showing installation in progress, while the front screen asking configuration questions, nice





I tried to attach screenshots using rekonq, it crashed


Rekonq asking to restore, but it could not restore like full fledged browsers


KInfoCenter in action


Kubuntu is good in utilizing RAM (if you have a lots of RAM!!)


Dolphin in action

Meanwhile installation completed, asking me to restart and giving an option to continue


Here is Konsole profile and I love the dark pastels theme


If you have SSD (Solid State Drive) add discard option to activate TRIM (trim is for wear leveling and increasing longevity of SSD life and is a must)

here is my root partition with discard entry


# / was on /dev/sdb1 during installation
UUID=90f606ab-567a-4336-8afe-292e1ffd3551 /               ext4    errors=remount-ro,discard 0       1




I mounted tmp on RAM,

see https://wiki.archlinux.org/index.php/Fstab#tmpfs

this above arch linux article is full of excellent tips


The above step of mounting tmp on RAM caused nvidia scripts to fail and after removing this entry of mounting tmp on RAM I got a full blown 3d effects in Kubuntu with my graphics card

After I changed wallpaper and added an analog clock, amazing isn't it


Right click task manager --> Task manager settings, and checked to show only apps from current desktop


System settings --> Application Appearnce --> Fonts --> enabled antialiasing like Ubuntu for nicer fonts (and increased font sizes)


Enabled additional drivers for nvidia (now supports post release update, no need to install bin files)



Nvidia driver installed and asking to restart


After rebooting, Kde 4.7 could not enable desktop effects with nvidia driver and it crashed, I tried to renable it and still it remains the same (my graphics card is Nvidia GTX 460 (nvidia fermi))

Color coding of the crash makes it look gorgeous


Funny, with nouveau driver graphics effects worked (but not very fast it ran slowly when doing effects)


Trying to renable desktop effects with nvidia driver and crash :(



After enabling canonical in software sources, I installed adobe flash plugin (yes 64 bit flash plugin)

After installing flashplugin, here is how I checked it


Adobe flashplayer in action (yes my favorite naruto)




To enable mp3 playback and mp4 playback, I installed kubuntu-restricted-extras


sudo apt-get install kubuntu-restricted-extras 




I tested an ogg sample from wikipedia article on http://en.wikipedia.org/wiki/Celine_dion


It played fine in browser, but Amarok failed to play it


Amarok in action, the beats are awesome after enabling equalizer (but no ogg by default)



I tried to save the sample ogg file and it crashed rekonq and I used chromium to save



Installed kaffeine player and tested an mp4 which I shot when I went to Mayiladuthurai, it could not play, default Dragon player was able to play



After installing xine plugins and restarting, I was able to play in Kaffeine!

To install all xine plugins here is how

sudo apt-get install libxine1-all-plugins

Kaffeine in action after installing xine plugins and restarting system



Kubuntu is very tempting, but I am ready for another distro hop


After I figured out that mounting tmp on RAM was causing failure in installing nvidia drivers properly, I removed it and reinstalled nvidia drivers.

See below screenshots to peek what a superb desktop Kubuntu is





Removed rekonq and kopete, installed firefox and pidgin

Software upates is unintrusive and shows a small popup on the right hand bottom corner, when clicked and confirmed to update, it started updating. Even the way it updates looks very attractive



Now Kubuntu looks close to my dream desktop


Thursday, October 13, 2011

My Ubuntu 11.10 Rant




Here is my rant. Ubuntu tries to be annoying, where is the checksum ?? I surfed mad across ubuntu.com to find a checksum of the file I downloaded

Sorry Ubuntu, this is irksome and I went to distrowatch to find out the release notes and release announcement. distrowatch.com displayed the SHA256SUMS link

Doesn't Ubuntu want people to verify their download, why does it make it so difficult to put a checksum in download page of Ubuntu. Won't  its users benefit from verifying their download.

What if some man in the middle attack caused a download of some other iso and the unsuspecting user thinks it is Ubuntu. Doesn't security weigh more than user interface, perhaps Ubuntu has seen a paradigm shift and I need a paradigm shift


See Ubuntu, your own sibling Kubuntu, Kubuntu explains beautifully about verifying the download along with easy access to checksums