Introduction, ah it will be boring, skip below first screenshot to get the kernel compilation how to.
But if you have time to read and patience to hear, good luck with the following paras, :)
After long time, I am finding a bit of free time and used my leisure time to build i7 optimized kernel, recorded every command into script, install and test and create this article for later reference for anyone who would wish to build/play around with kernel ... and know what?
I followed my own earlier article to build this kernel, why not?
My memory is not unlimited and after many tries with Ubuntu, Fedora, Kubuntu and in between some heavy office work, some boring books to read from libraries (due to due dates), exploring my xperia phone with ics updates, fixing my windows 7 which gobbled a whole day, updating my friends galaxy s2 to ics, googling cars, visiting relatives, spending my time in doctors lobby and much more day to day stuff ...
My linux sense triggered again to build and play with Kernel 3.4
This time, I do not have Ubuntu (sorry Unity I am damn confused how to use it)
It hardly matters, I have a better Ubuntu which is Mint 13 with Cinnamon. Now the base is Ubuntu 12.04 and everything related to kernel compilation is same to my happiness.
I have been too lazy to touch Mint and build kernel, as it is quite stable and does not give me problems to look inside or play around. But hey, I am not going to let Mint spoil my geekiness
Here I come, Mint, to shatter your stability and perched laziness by pushing my custom built kernel into you to displace your rock stable kernel
Come on gutsy guys, if you dare, you could get yourself into kernel compilation voyage. If you are faint hearted, be happy with Mint 13 default, do not even touch it
Read ahead, buf if you are impatient to build and try the fruits of my efforts, scroll down to the bottom and you have the download links. This time I tried google drive for sharing and it should be easy to download (tell me if you like)
Straight to the point, here is the Mint 13 screenshot showing new kernel running
To build Kernel 3.4.4 in Mint13 or Ubuntu 12.04 yourself follow this steps
- Install Build dependencies
- Download Kernel 3.4.4 and Ubuntu patches
- Extract and apply Ubuntu patches
- Create i7 flavour and tweak kernel config for i7 flavour
- Tweak Makefile for optimizing
- Build
- Optionally install xorg x-swat ppa and upgrade
- Reboot and Test
I will try to explain each step in this article
Install build dependencies
Execute these apt-get commands as a sudo user from terminal
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
Optional: GCC 4.7 in Ubuntu 12.04 or Mint 13
If you want to build using gcc 4.7 then follow these steps to install gcc 4.7 in Ubuntu 12.04 from PPA
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-4.7
sudo apt-get install g++-4.7
Download Kernel sources and Ubuntu patches
You could download the kernel 3.4.4 sources from kernel.org and Ubuntu patches for kernel 3.4.4 from kernel ppa directoryIf you prefer not to worry downloading individually, you could just copy and paste these commands in command line and let wget do the downloading job for you
mkdir Builds
cd Builds
wget -c http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.4.4.tar.bz2
wget -c http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.4.4-quantal/0001-base-packaging.patch
wget -c http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.4.4-quantal/0002-debian-changelog.patch
wget -c http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.4.4-quantal/0003-default-configs.patch
Here is a screenshot of wget downloading kernel source in command line
Here is a screenshot showing how I got the download links of ppa for wget, you would not need this if you just use wget given above
Here is a screenshot showing efficient wget completion of sources and ubuntu patches
Extract and Apply Ubuntu patches
You could use gui to unzip the bz2 kernel tarball, but if you prefer command line, use the following commandExtract
tar xjvf linux-3.4.4.tar.bz2
A screenshot showing the same in action
Soft Link linux folder
Create a soft link for the extracted folder and change to the linux folder using cd
ln -s linux-3.4.4 linux
cd linux
Apply the patches
From the terminal do the following from inside the linux folder, see previous step to know what I mean as linux folder
patch -p1 < ../0001-base-packaging.patch
patch -p1 < ../0002-debian-changelog.patch
patch -p1 < ../0003-default-configs.patch
Create i7 flavour
Before creating a new kernel flavor, we give execute permissions for the build scripts
chmod -Rv +x debian/rules
chmod -Rv +x debian/scripts/
Clone existing flavor
cp debian.master/config/amd64/config.flavour.generic debian.master/config/amd64/config.flavour.i7
Prepare
first clean and update the new flavor
fakeroot debian/rules clean
fakeroot debian/rules updateconfigs
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
Run editconfigs
Give yes to i7 config and no to all other configs
fakeroot debian/rules editconfigs
Load alternate config and choose stableconfig which is untouched by editconfigs, save alternate config and save .config after changing processor type and kernel frequency
Here is a screenshot showing loading of stable config
Change processor and processor frequency
Screenshot showing chaning processor type
Screenshot after processor type change
Screenshot with default frequency
Screenshot with frequency modification
After processor frequency modification
Before exiting, save the config as .config by selecting save alternate config
Adjust abi
cp debian.master/abi/3.5.0-0.0/amd64/generic debian.master/abi/3.5.0-0.0/amd64/i7
cp debian.master/abi/3.5.0-0.0/amd64/generic.modules debian.master/abi/3.5.0-0.0/amd64/i7.modules
sed -i s/getall\ amd64\ generic/getall\ amd64\ generic\ i7/g debian.master/etc/getabis
sed -i s/\=\ generic/\=\ generic\ 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
Tweak Makefile
You can change makefile manually to update the processor arch to corei7 (corei7 is target instructions for i3, i5 and i7 intel processors)
sed -i s/\=\ gcc/\=\ gcc\ \-march\=corei7\ \-mtune\=corei7\ \-pipe/g Makefile
sed -i s/\=\ g++/\=\ g++\ \-march\=corei7\ \-mtune\=corei7\ \-pipe/g Makefile
sed -i s/core2/corei7/g arch/x86/Makefile
sed -i s/core2/corei7/g arch/x86/Makefile_32.cpu
Optional: If you want to use gcc4.7 for building then use the following instead of the above
This changes gcc to gcc-4.7 and g++ to g++-4.7, also mtune is changed to core-avx-i to optimize for the latest i7 processors with avx instructions
sed -i s/\=\ gcc/\=\ gcc\-4\.7\ \-march\=corei7\ \-mtune\=core\-avx\-i\ \-pipe/g Makefile
sed -i s/\=\ g++/\=\ g++\-4\.7\ \-march\=corei7\ \-mtune\=core\-avx\-i\ \-pipe/g Makefile
sed -i s/core2/corei7/g arch/x86/Makefile
sed -i s/core2/corei7/g arch/x86/Makefile_32.cpu
Build and install
We do a clean build of headers and kernel image with newly created i7 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-i7
Install the newly built packages from previous directory by using cd
cd ..
sync
sudo dpkg -i linux-headers-3.4.4-030404_3.4.4-030404.201206221555_all.deb linux-headers-3.4.4-030404-i7_3.4.4-030404.201206221555_amd64.deb linux-image-3.4.4-030404-i7_3.4.4-030404.201206221555_amd64.deb
sync
Optionally install xorg ppa for nvidia latest drivers
if you face problem in building dkms modules of nvidia, here is how I resolved it
Rebooted into new kernel, I added xorg x-swat ppa, updated through synaptic and upgraded all nvidia packages
sudo apt-add-repository ppa:ubuntu-x-swat/x-updates
sudo apt-get update
sudo apt-get upgrade
Reboot and Enjoy
After installing newly built kernel, reboot into kernelHere are the,
Download Links
SHA256SUM of above in order
- ba18d38b88a621b8758a2293365b6750da298e262946a635044d81eed1cf501c linux-headers-3.4.4-030404_3.4.4-030404.201206221555_all.deb
- 8c050642b90de73d9b3a8cfad3e072d63406d6b49a89422e4c8f616d8520a77a linux-headers-3.4.4-030404-i7_3.4.4-030404.201206221555_amd64.deb
- c48586472892897c2ee4362976708f8bcbdd4f10369b82943b053eab99f611f0 linux-image-3.4.4-030404-i7_3.4.4-030404.201206221555_amd64.deb
- d85d8f0ef88627633c519d5ba197a19216815644c00185f674052d772a59d0cc Kernel3.4.4Compilation
Below are the download links of kernel and headers built using gcc-4.7
- Kernel Headers All
- Kernel Headers
- Kernel Image
- Script to Build (save this file and give it execute permissions using chmod +x or you can execute all the instructions one by one after reviewing :) )
SHA256SUM of above in order
- 49e25d90ddabcbc56e8c43bc1702791e36ef74b80c5f72542ad6afbb9939e8f9 linux-headers-3.4.4-030404_3.4.4-030404.201206221555_all.deb
- d18401bc72902f559fac2153b4568d634e4b4863addcba139a997f56feb32bd3 linux-headers-3.4.4-030404-i357_3.4.4-030404.201206221555_amd64.deb
- 400864ae46f3f898e567b0d77097ee0c46861d9d0537bf21440005749c2810e7 linux-image-3.4.4-030404-i357_3.4.4-030404.201206221555_amd64.deb
- bf2baa2cedd9ee9e194e35ad4ef56f511f2fa557a4ce56305a8bb7f32d1789e9 KernelCompilation344UsingGCC47
Kernel 3.4.6 optimized for i7 (64 bit)
SHA256SUM of the above in order
- c7870ec1a3e3e9bd30a46fd9816feb9f4c574fb063865b13aca4ea977ae53f57 buildkernel3.4.6.sh
- c10441220d94221155a50d13ba7ef448052e385ff897837b48ec0f7f9b552ab0 linux-headers-3.4.6-030406_3.4.6-030406.201207191609_all.deb
- 87758a8b1c2b93e025be041a2eb0fbbd1bc4f2e7d6411d16f8535ef71aba660e linux-headers-3.4.6-030406-i7_3.4.6-030406.201207191609_amd64.deb
- 1f801329bf41e53fc0b43526ad0d6f7827a4f752ff4bce49c0c6f037b8180879 linux-image-3.4.6-030406-i7_3.4.6-030406.201207191609_amd64.deb
- c6a3f6996242af24e719f3c6e029749a052954328efb4daa2cca87ead81977d7 buildkernel352.sh
- 47a8dbc136af8ff1331ddcd5841a226242ba3ae635534bb0c3f0b9dcead1ef5f linux-headers-3.5.2-030502_3.5.2-030502.201208151151_all.deb
- 6965992662a3a4db3b7c02bcb9f0c4dd60f61dbb7c930485f6b5fc806b41e101 linux-headers-3.5.2-030502-i7_3.5.2-030502.201208151151_amd64.deb
- 25807da234187423ff746edc2976bf2aa4c81a6832f9dc1b725ca63410022350 linux-image-3.5.2-030502-i7_3.5.2-030502.201208151151_amd64.deb