how to compile kernel with RT patch

# we will be working here
cd /usr/src/

# download all required files
axel -a http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.6.6.tar.bz2
tar xjvf linux-3.6.6.tar.bz2 && cd linux-3.6.6/
axel -a http://www.kernel.org/pub/linux/kernel/projects/rt/3.6/patch-3.6.6-rt17.patch.bz2

# test the RT patch before actually patch it ( make sure you are now in /usr/src/linux-3.6.6/ )
bzcat patch-3.6.6-rt17.patch.bz2|patch -p1 –dry-run

# if everything seem ok, lets really patch it
bzcat patch-3.6.6-rt17.patch.bz2|patch -p1

# remove the -rt17 prefix local kernel version. this seem to cause problem when running make-kpkg later
echo > localversion-rt

# copy current kernel configuration
make clean && make mrproper && cp /boot/config-`uname -r` ./.config

# configure our kernel
make menuconfig

# below is the setting that use, please find the menu by browsing the menu config console
# note: please choose processor family accordingly
Processor Type and Features
[ ] Enable MPS table
Processor family (Core 2/newer Xeon) —>
[ ] IBM Calgary IOMMU support
Preemption Model (Fully Preemptible Kernel (RT)) —>
Timer frequency (1000 HZ) —>
[ ] kernel crash dumps

Kernel Hacking
[ ] Enable unused/obsolete exported symbols
[ ] Kernel debugging
[ ] Compile the kernel with frame pointers
RCU Implementation (Preemptible tree-based hierarchical RCU) —>

# below is the setting to enable general support for (most) webcams
Device Drivers —>
[*] Multimedia Support —>
[*] Cameras/video grabbers support
.
.
[*] Video capture adapters (NEW) —>
[*] V4L USB devices —>
<M> USB Video Class (UVC)

[ ] = untick
[*] = tick

# [optional] this is gcc option tuned for my machine
# i’m using Intel(R) Core(TM)2 Duo CPU E4500, yours may differ
export CFLAGS=”-O2 -pipe -march=native –param l1-cache-size=32 –param l1-cache-line-size=64 –param l2-cache-size=2048 -mtune=native -mfpmath=sse -m64″
export CXXFLAGS=”$CFLAGS”

# lets compile our kernel and build the .deb package (you may choose your own append_to_version= )
CONCURRENCY_LEVEL=$(getconf _NPROCESSORS_ONLN) fakeroot make-kpkg –initrd –append_to_version=-zxr –revision=0 kernel_image kernel_headers

cd ..
dpkg -i linux-*3.6.6*.deb
# reboot to and select your new kernel

# check your kernel and you should see something like below
┌─[novatech][~]
└──╼ uname -a
Linux ZX10R 3.6.6-zxr #1 SMP PREEMPT RT Fri Nov 16 01:45:28 MYT 2012 x86_64 GNU/Linux

# that’s it… kernel compilation is not a rocket science after all isn’t ?
# have fun with your blazing fast responsive desktop ~

foot notes:
1. this guide can use to compile normal kernel without RT patch
2. if you would like recompile the kernel after enable some modules in menuconfig, below is tips/tricks on how to make make-kpkg faster
export CLEAN_SOURCE=no
CONCURRENCY_LEVEL=$(getconf _NPROCESSORS_ONLN) fakeroot make-kpkg –initrd –append_to_version=-zxr –revision=0 kernel_image kernel_headers

Tagged with: , , ,
Posted in tips & tricks

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>