Wednesday, August 03, 2011

experiences with kernel compilation in ubuntu

0. needed tools:

sudo apt-get install bin86 build-essential bzip2 fakeroot gcc kernel-package make libncurses5-dev

1. get kernel source & rt patch

main line stable kernel version:
at this time (2011/Aug), last stable kernel is 3.0:

rt kerne patch:
at this time (2011/Aug), last patch for rt kernel is:

be aware since the rt patch will be merged in the main stable kernel release.
Since kernel 2.6.39 the IRQ handlers will be threaded which is the most important part of the RT Patch.
rt kernel compilation will be considered from here.

2. uncompress, patch, configure and compile

tar xvjf linux-3.0.tar.bz2
cd linux-3.0
cp ../patch-3.0-rt6.patch.bz2 .
bunzip patch-3.0-rt6.patch.bz2
patch -p1 < patch-3.0-rt6.patch

copy for example your current kernel config file:

cp /boot/config-$(uname -r) .config

configure your kernel

make menuconfig

now you must change all the desired options for your new kernel here
when you decide to exit, all changes will be saved to .config file
more info to come here....

Config options for kernel >= 2.6.39:

$ cat config- | grep PREEMPT

Threadirqs forced option:


You must enable threadirqs at boot option. Threadirqs is a boot argument, CONFIG_IRQ_FORCED_THREADING is a kernel compilation config option which matters if you compile the kernel. The boot argument will of course only work at runtime if the config option had been turned on before compiling the kernel. You can replace the default you have, which is "quiet", by "quiet threadirqs" in the grub config file.


menuentry 'Ubuntu, with Linux 2.6.39' --class ubuntu --class gnu-linux --class gnu --class os {
insmod ext2
set root='(hd0,5)'
search --no-floppy --fs-uuid --set cff691dc-fa7f-43d4-9875-60d91180b1c6
linux /boot/vmlinuz-2.6.39 root=UUID=cff691dc-fa7f-43d4-9875-60d91180b1c6 ro quiet threadirqs splash
initrd /boot/initrd.img-2.6.39

Other config options:


clear current source kernel directories:

make-kpkg clean

build the kernel, I’m using a 2 core so concurrency will be 2.
in this machine it takes about 1 hour to complete...

CONCURRENCY_LEVEL=2 make-kpkg --rootcmd fakeroot --initrd kernel-image kernel-headers kernel-source

if by chance the compilation finish with this error:

dpkg-gencontrol: error: package linux-image-xxxxxxxxxxx not in control info

then you must follow exactly what is expressed here, it worked for me:

3. install the kernel

cd .. && sudo dpkg -i *.deb

4. create an initrd

just replace the related kernel version number....:

sudo update-initramfs -c -k 3.0

5. update grub with new initrd

sudo update-grub

6. reboot and choose your new kernel version

7. end


Realtime Scheduling Vs Realtime Preemption

Realtime Preemption Overview:

Jack and Realtime Scheduling:

Jack and Realtime Group Scheduling:

No comments: