Home page of this blog

Sunday, October 14, 2012

Build script for kernel 3.6.2 optimized native for Ubuntu

Here is the script to build ubuntu (debian) packages optimized for the native processor

https://docs.google.com/open?id=0B_nTbpzPbbNJU0h1RzFLMG1lR2s


The following tries to dissect the script and how it works

Build dependencies

The portion below is used to install build environment in ubuntu, if the following are already installed, script just does not install it again(thanks to apt)



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 install flex

sudo apt-get install bison

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


Downloading kernel source and patching it with ubuntu patches to build ubuntu package



mkdir -p ~/Builds/Kernel362 
cd ~/Builds/Kernel362 


wget -c http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.6.2.tar.bz2
wget -c http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.6.2-quantal/0001-base-packaging.patch
wget -c http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.6.2-quantal/0002-debian-changelog.patch
wget -c http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.6.2-quantal/0003-default-configs.patch

rm -rf linux-3.6.2
rm -rf linux

tar xvjf linux-3.6.2.tar.bz2
ln -s linux-3.6.2 linux

cd linux

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




Creating new flavor and giving execute permissions to debian build scripts



chmod -Rv +x debian/rules

chmod -Rv +x debian/scripts/

cp debian.master/config/amd64/config.flavour.generic debian.master/config/amd64/config.flavour.native

fakeroot debian/rules clean
fakeroot debian/rules updateconfigs




Changing kernel config based on stable config



#copy existing config from rock stable 12.04 kernel using uname -r, do not save it in .config, as this file is heavily modified when calling editconfigs
cp /boot/config-`uname -r` stableconfig
#cp /boot/config-3.2.0-31-generic stableconfig

#give y to native config
#Load alternate config and choose stableconfig which is untouched by editconfigs, save alternate config and save .config after changing processor type and kernel frequency
fakeroot debian/rules editconfigs





This step needs a bit more explanation on how to base kernel config based on stable config, to do this I just put screenshots explaining briefly how this is done

When the script is running and comes to asking if we want to edit config, choose Y for native flavor

see below (I am giving n for every other flavor)


When the kernel config screen comes, scroll down and select Load an Alternate Configuration File


In the dialog, erase .config using backspace and type stableconfig



Following screens show, that I change processor type and kernel frequency, the old and new

Processor type old

Processor type new



Kernel frequency old


Kernel frequency new


After finishing all configuration changes, do not just exit!

Scroll down to Save an Alternation Configuration File


In the popped up dialog, erase stableconfig and type .config


Now choose exit in the main configuration screen


ABI  entries for new flavor and makefile changes



ABI_DIR=`ls debian.master/abi/`

cp debian.master/abi/$ABI_DIR/amd64/generic debian.master/abi/$ABI_DIR/amd64/native
cp debian.master/abi/$ABI_DIR/amd64/generic.modules debian.master/abi/$ABI_DIR/amd64/native.modules

sed -i s/getall\ amd64\ generic/getall\ amd64\ generic\ native/g debian.master/etc/getabis
grep native debian.master/etc/getabis

sed -i s/\=\ generic/\=\ generic\ native/g debian.master/rules.d/amd64.mk
grep native debian.master/rules.d/amd64.mk

cp debian.master/control.d/vars.generic debian.master/control.d/vars.native
sed -i s/\"Generic\"/\"core\ native\"/g debian.master/control.d/vars.native
grep native debian.master/control.d/vars.native


sed -i s/\=\ gcc/\=\ gcc\ \-march\=native\ \-pipe/g Makefile
sed -i s/\=\ g++/\=\ g++\ \-march\=native\ \-pipe/g Makefile
grep "march=native" Makefile


sed -i s/core2/native/g arch/x86/Makefile
sed -i s/core2/native/g arch/x86/Makefile_32.cpu
grep native arch/x86/Makefile_32.cpu
grep native arch/x86/Makefile





you can see above, I have given march=native you can choose whichever is your processor architecture

Building headers and kernel flavor



fakeroot debian/rules clean
skipabi=true skipmodule=true fakeroot debian/rules binary-headers
time skipabi=true skipmodule=true no_dumpfile=yes fakeroot debian/rules binary-native

The above builds kernel headers and kernel image for our new flavor

Just install the newly built packages using 

sudo dpkg -i *.deb






Core i7 optimized Ubuntu Kernel 

Kernel Headers All
Kernel Header corei7
Kernel Image


SHA256SUMS of the above in order


537e87a7c3200aab82624810526d25031ffd5093f406b32bc0f2e053e6213477  linux-headers-3.6.2-030602_3.6.2-030602.201210121823_all.deb

adf8fc79df2974622762f7e7ff84b8804f0b91f4927a70e3115d6326a2872bc2  linux-headers-3.6.2-030602-corei7_3.6.2-030602.201210121823_amd64.deb

001b05ffd6377b1f18d58704f850128f6b73525a9fb5c2744c30583b84b639e0  linux-image-3.6.2-030602-corei7_3.6.2-030602.201210121823_amd64.deb

Saturday, October 6, 2012

Kernel 3.6 build script for Ubuntu

I will make it short, :)

I built kernel 3.6,

The build script is here



and incidentally this is 150th post of this blog!

64 atom optimized Ubuntu kernel packages


SHA256SUMS of the 64bit 3.6 linux kernel packages I built with atom optimization

ae7a3348f43c8c31827bd6f61d90a1e280c334d41f1d37c539e2f7a203c24a0e buildkernel36atom.sh

ada5b5dddc64e064663a9c935266e6555e8b58d81746f78bb3eb7164ef5d9512 linux-headers-3.6.0-030600_3.6.0-030600.201209302035_all.deb

be3f14c920353ad571a5809a30e3a2be49665a71abf413a883a9118b84b11dc6 linux-headers-3.6.0-030600-atom_3.6.0-030600.201209302035_amd64.deb

097b0738e8a26ccfc6b93ed9c7e3a19b05e9d9d2aaac9e360b4de6eefdb5e03c linux-image-3.6.0-030600-atom_3.6.0-030600.201209302035_amd64.deb

Download links



Monday, October 1, 2012

Trying Slackware 14

I think it is a honor to run Slackware Linux

I am absolutely delighted to tell I installed Slackware Linux in my system. I have heard it is real tough to get Slackware installed in system when I was having arch linux 4 years back

Times have changed, I think slackware has become easy (I guess archlinux taught me how to run commands to bring UI up or add user :D )

I downloaded the recently released 14.0 and managed to install it from pendrive. I installed lilo to partition beginning so that my other Ubuntu partition would not be disrupted

Here are some screenshots







Stay tuned, more will follow about my Slackware obsession