Tuesday, May 8, 2012

Compilation Kernel 3.3.1 On Ubuntu X64




This is a small guide for compilation and optimization of the kernel on Ubuntu 64-bit and derivatives. The optimization is limited only to select the type of processor inside the configuration files, additional optimizations can be performed within those files related to its hardware configuration.

The result of the work is a kernel compatible with all Intel belonging to the family Core2 , Corei3, i5, i7 etc.

This guide is not suitable for compiling the kernel on machines with AMD CPUs, soon I'll post one devoted to these processors.

The optimization provides better speed in the execution of tasks that absorb a lot of processor resources, eg encoding/decoding, compression/decompression, etc. files.

If we use our computer only to surf the net and write a few lines of text will notice big differences.

Before you start the real work just thank all those in network publishing every day their experiences improve our skills and enhance our culture. A special thanks goes to Sankaran Raman whose work I have drawn freely.

Start the "Terminal" and type at the prompt, just as there are in the order, the commands that will gradually during the reading. Each command is preceded by a brief explanation.

- Install libraries, compilers and everything needed. At each date command "Enter", type in your password and wait for the system do the rest.
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


- Create the folder containing the kernel source and patches within our home (at the end of all operations, it will also feature our beautiful kernel and compiled into individual packages).
mkdir ~/Kernel_3.3.1


cd ~/Kernel_3.3.1


- Download the kernel and patches.
wget -c http://www.kernel.org/pub/linux/kernel/v3.x/linux-3.3.1.tar.bz2


Wait for the end of the download before giving the next command (for each individual command).
wget -c http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.3.1-precise/0001-base-packaging.patch


wget -c http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.3.1-precise/0002-debian-changelog.patch


wget -c http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.3.1-precise/0003-default-configs.patch


- Unpacking kernel, creating symbolic link, access to the folder.
tar xjvf linux-3.3.1.tar.bz2


ln -s linux-3.3.1 linux


cd linux


- Patch Application to Kernel
patch -p1 < ../0001-base-packaging.patch


patch -p1 < ../0002-debian-changelog.patch


patch -p1 < ../0003-default-configs.patch


- Assignment rights access  to various scripts and execution
chmod -Rv +x debian/rules


chmod -Rv +x debian/scripts/


- Creating new profile to build Corei7
cp debian.master/config/amd64/config.flavour.generic  debian.master/config/amd64/config.flavour.i7


- Cleaning and updating the configuration file
fakeroot debian/rules clean


fakeroot debian/rules updateconfigs
- Edit the configuration file to adapt the kernel to our requirements: it is a fundamental step to be performed with extreme caution. Execution of the command, the terminal will display a series of questions, ONLY THE SECOND REQUEST YOU MUST  ANSWER AFFIRMATIVE.


fakeroot debian/rules editconfigs
  • Answer "No" to the first question, "Y" to the second. Now you came into the kernel configuration, proceed as follows (to select intend to move up and down with the cursor keys and then to enter):
  • 1 - Select "Processor type and features"
  • 2 - Select "Processor family (Generic-x86-64)"
  • 3 - Select "Core 2/newer Xeon
  • 4 - Scroll all the entries down to find "Preemption Model ..."
  • (This item determines how your cpu will "dedicate" to the management of various tasks/programs running on your system along with the item "Timer frequency ...". And 'possible to favor a faster system response times at the expense of actual execution of the various processes. I highly recommend leaving the "Desktop").
  • 5 - Scroll all the entries down to find "Timer frequency ..."
  • (Now if you can select a fixed 1000Hz, the laptop does not exceed the threshold 300Hz . On the web I found endless different explanations and tips on using this parameter, unless you use on your system of professional applications for managing Audio and video septate the value of 300Hz).
  • 6 - Go back to the previous menu, selecting "Exit" option on the bottom of the screen
  • 7 - Select "Networking support ..."
  • 8 - Select "Networking options ..."
  • 9 - Scroll all the entries down to find "The IPv6 protocol", pressed on your keyboard the letter "M"
  • (At compile time will create a kernel module for IPv6 that you can ban to prevent the use by the system in a definitive manner).
  • 10 - Return to the previous menu, selecting "Exit" option on the bottom of the screen
  • 11 - Return to the previous menu, selecting "Exit" option on the bottom of the screen
  • 12 - We leave the menu always selecting "Exit" option on the bottom of the screen
  • 13 - answer "Yes" to the question that will be placed at the exit, we will save your changes to the basic configuration.
  • Answer "No" to the next question present on your screen.


- Copy of generic and our configuration as the default setting in the build process
cp debian.master/abi/3.2.0-20.33/amd64/generic  debian.master/abi/3.2.0-20.33/amd64/i7


cp debian.master/abi/3.2.0-20.33/amd64/generic.modules debian.master/abi/3.2.0-20.33/amd64/i7.modules


sed -i s/getall\ amd64\ generic\ virtual/getall\ amd64\ generic\ virtual\ i7/g debian.master/etc/getabis


sed -i s/\=\ generic\ virtual/\=\ generic\ 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/supported\=\"Generic\"/supported\=\"Nehalem\"/g debian.master/control.d/vars.i7


sed -i s/target\=\"Geared\ toward\ x86_64/target\=\"Geared\ toward\ i7/g debian.master/control.d/vars.i7


- Optimization of the kernel through the variable-mtune and -march, the compiler will produce a kernel optimized for Intel Dual Core / Corei-xx
sed -i s/\=\ gcc/\=\ gcc\ -march\=corei7\ -mtune\=corei7/g Makefile


sed -i s/\=\ g++/\=\ g++\ -march\=corei7\ -mtune\=corei7/g Makefile


sed -i s/core2/corei7/g arch/x86/Makefile


sed -i s/core2/corei7/g arch/x86/Makefile_32.cpu


- Writing of all changes to disk


sync


- Cleaning before the actual compilation


fakeroot debian/rules clean


- Compilation of dependencies, the source and header


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


- Start the process of compiling the kernel


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


finally, give the command to install the new kernel.
cd ..
rm linux


rm -rf linux-3.3.1


sudo dpkg -i linux-image-3.3.1-030301-i7_3.3.1-030301.201204021435_amd64.deb linux-headers-3.3.1-030301-i7_3.3.1-030301.201204021435_amd64.deb linux-headers-3.3.1-030301_3.3.1-030301.201204021435_all.deb


Reboot to use the new kernel.

System used Kubuntu 12.04 x64 - Cpu Corei3 2°Gen. - 6GB Ram.
The only problem: my network card to return from hibernation (being resolved) can not hang up the same wireless network.

No comments:

Post a Comment

Please Stop Spamming , Swearing And Abusing.

Recommended Post Slide Out For Blogger