I have read a lot of threads with similar questions, but after reading the answers, I am very confused. I have found in them lots of url's with repositories but people discusses about which repositories are made for one or two versions of ubuntu, but I have found nothing about 11.10 version. Is too soon to ask for that? Should I downgrade my ubuntu to have a realtime kernel?

  • 3
    Are you sure you want a realtime vs. low-latency kernel? What are your requirements?
    – belacqua
    Commented Oct 30, 2011 at 18:24

4 Answers 4


The long term goal of the RT kernel project is to end up having all the RT functionality in the standard kernel, and this is progressing nicely. The RT patch has had irregular releases in the past, and the hacking of kernel.org in August 2011 made the 3.0 version inaccessible for months, but now things are looking good: there's a patch for 3.0, another for 3.2 (coinciding with the kernel versions in Ubuntu 11.10 and 12.04), and another for 3.4, see here.

If you are using Precise, you can use Alessio Bogani's Realtime PPA, who has kindly packaged the vanilla kernel with the RT patch applied and is keeping it in sync with the version numbers in Precise.

If you prefer to build the RT kernel by hand, first install the required software packages:

sudo apt-get install kernel-package fakeroot build-essential libncurses5-dev

Then fetch the vanilla kernel and RT patch (the version numbers are somewhat old, tweak as necessary):

mkdir -p ~/tmp/linux-rt
cd ~/tmp/linux-rt
wget http://www.kernel.org/pub/linux/kernel/v3.x/linux-3.4.tar.bz2
# Alternatively, try http://mirror.be.gbxs.net/pub/linux/kernel/projects/rt/3.4/patch-3.4-rt7.patch.bz2
# if the following is not available:
wget http://www.kernel.org/pub/linux/kernel/projects/rt/3.4/patch-3.4-rt7.patch.bz2
tar xjvf linux-3.4.tar.bz2
cd linux-3.4
patch -p1 < <(bunzip2 -c ../patch-3.4-rt7.patch.bz2)

Then configure the kernel using:

cp /boot/config-$(uname -r) .config && make oldconfig

where you should select "full preemption" (option 5) when prompted, and leave everything else at its default value by pressing enter at every prompt. The config from the -lowlatency kernel might be a better starting point than that of the -generic kernel.

Then build the kernel with:

sed -rie 's/echo "\+"/#echo "\+"/' scripts/setlocalversion
make-kpkg clean
CONCURRENCY_LEVEL=$(getconf _NPROCESSORS_ONLN) fakeroot make-kpkg --initrd --revision=0 kernel_image kernel_headers

And finally install your new kernel with:

sudo dpkg -i ../linux-{headers,image}-3.4.0-rt7_0_*.deb

You should be able to reboot into your RT kernel at this point. If your kernel fails to boot make sure you double-check the boot parameters, and edit them accordingly in your bootloader. For example, ACPI functions may affect your real time system (as stated on rt.wiki.kernel.org). Adding acpi=off may be a solution in such case.

Notice though that the RT patch is incompatible with the Nvidia binary driver (but see the post by user "rt-kernel" below, and this question for a workaround), and that the Ubuntu kernel patches will not be present, so you may have hardware problems that you did not have before. This is true of both the PPA packages and the compiled kernel. You can always boot into your -generic kernel and uninstall the realtime kernel packages if they give you trouble, of course.

  • 1
    Great instructions! I recommend installing a 3.4 mainline kernel before following them, to get a config file that matches best. Also, unofficial precompiled 3.4.29 binaries for AMD64 are available here as DEB packages (following these instructions to the letter
    – cmc
    Commented Feb 11, 2013 at 2:13
  • I could not run the compiled kernel following these instructions. So instead of the vanilla kernel from kernel.org, I downloaded Ubuntu's linux-source package using apt and it worked successfully then.
    – Melebius
    Commented Mar 18, 2014 at 10:18

Another option is to install the RTKernel from KXStudio's repos. He keeps a set of packages aimed to audio and music productions and he has a real time and a low latency packages.

http://kxstudio.sourceforge.net/Main_Page https://launchpad.net/~kxstudio-team/+archive/kernel


As far as I know, the development of the realtime kernel has not keep pace with the Ubuntu release cycle. If you must run a realtime kernel, you probably will have to run an older version.

For some more information, see https://help.ubuntu.com/community/UbuntuStudio/RealTimeKernel.

Note that there appears to be at least some current work on the low-latency kernel: https://launchpad.net/~abogani/+archive/ppa?field.series_filter=oneiric .


If you depend on using the nvidia binary driver you can patch the original driver with this patch (for 3.4+ kernels with rt-patches only) This patch comes with no garantee or warranty! Use it on your own risk.->

Index: kernel/conftest.sh
--- kernel/conftest.sh.orig
+++ kernel/conftest.sh
@@ -95,7 +95,7 @@



@@ -126,7 +126,7 @@

     if [ "$ARCH" = "i386" -o "$ARCH" = "x86_64" ]; then
-        CFLAGS="$CFLAGS -I$SOURCES/arch/x86/include -I$SOURCES/arch/x86/include/generated"
+        CFLAGS="$CFLAGS -I$SOURCES/arch/x86/include -I$OUTPUT/arch/x86/include/generated"
 elif [ "$ARCH" = "ARMv7" ]; then
     CFLAGS="$CFLAGS -I$SOURCES/arch/arm/include -I$SOURCES/arch/arm/include/generated"
@@ -512,7 +512,12 @@
             # and if it as an 'event' member.
             echo "$CONFTEST_PREAMBLE
-            #include <asm/system.h>
+            #include <linux/version.h>
+         #include <asm/switch_to.h>
+       #else
+         #include <asm/system.h>
+       #endif
             #include <linux/pm.h>
             void conftest_pm_message_t(pm_message_t state) {
                 pm_message_t *p = &state;
@@ -965,11 +970,12 @@
             echo "$CONFTEST_PREAMBLE
             #include <linux/acpi.h>
+            #include <acpi/acpixf.h>
             void conftest_acpi_walk_namespace(void) {
             }" > conftest$$.c

-            $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
+            #CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
             rm -f conftest$$.c

             if [ -f conftest$$.o ]; then
@@ -980,6 +986,7 @@

             echo "$CONFTEST_PREAMBLE
             #include <linux/acpi.h>
+       #include <acpi/acpixf.h>
             void conftest_acpi_walk_namespace(void) {
                 acpi_walk_namespace(0, NULL, 0, NULL, NULL, NULL, NULL);
             }" > conftest$$.c
@@ -996,6 +1003,7 @@

             echo "$CONFTEST_PREAMBLE
             #include <linux/acpi.h>
+            #include <acpi/acpixf.h>
             void conftest_acpi_walk_namespace(void) {
                 acpi_walk_namespace(0, NULL, 0, NULL, NULL, NULL);
             }" > conftest$$.c
@@ -1603,6 +1611,9 @@
+   RET=0
+   SELECTED_MAKEFILE=Makefile.kbuild

         if [ "$RET" = "0" ]; then
             ln -s $SELECTED_MAKEFILE Makefile
Index: kernel/nv-linux.h
--- kernel/nv-linux.h.orig
+++ kernel/nv-linux.h
@@ -111,7 +111,11 @@
 #include <linux/timer.h>

 #include <asm/div64.h>              /* do_div()                         */
+#include <asm/switch_to.h>
 #include <asm/system.h>             /* cli, sli, save_flags             */
 #include <asm/io.h>                 /* ioremap, virt_to_phys            */
 #include <asm/uaccess.h>            /* access_ok                        */
 #include <asm/page.h>               /* PAGE_OFFSET                      */
@@ -291,17 +295,17 @@

-#if defined(CONFIG_PREEMPT_RT)
-typedef atomic_spinlock_t         nv_spinlock_t;
-#define NV_SPIN_LOCK_INIT(lock)   atomic_spin_lock_init(lock)
-#define NV_SPIN_LOCK_IRQ(lock)    atomic_spin_lock_irq(lock)
-#define NV_SPIN_UNLOCK_IRQ(lock)  atomic_spin_unlock_irq(lock)
-#define NV_SPIN_LOCK_IRQSAVE(lock,flags) atomic_spin_lock_irqsave(lock,flags)
+typedef raw_spinlock_t            nv_spinlock_t;
+#define NV_SPIN_LOCK_INIT(lock)   raw_spin_lock_init(lock)
+#define NV_SPIN_LOCK_IRQ(lock)    raw_spin_lock_irq(lock)
+#define NV_SPIN_UNLOCK_IRQ(lock)  raw_spin_unlock_irq(lock)
+#define NV_SPIN_LOCK_IRQSAVE(lock,flags) raw_spin_lock_irqsave(lock,flags)
 #define NV_SPIN_UNLOCK_IRQRESTORE(lock,flags) \
-  atomic_spin_unlock_irqrestore(lock,flags)
-#define NV_SPIN_LOCK(lock)        atomic_spin_lock(lock)
-#define NV_SPIN_UNLOCK(lock)      atomic_spin_unlock(lock)
-#define NV_SPIN_UNLOCK_WAIT(lock) atomic_spin_unlock_wait(lock)
+  raw_spin_unlock_irqrestore(lock,flags)
+#define NV_SPIN_LOCK(lock)        raw_spin_lock(lock)
+#define NV_SPIN_UNLOCK(lock)      raw_spin_unlock(lock)
+#define NV_SPIN_UNLOCK_WAIT(lock) raw_spin_unlock_wait(lock)
 typedef spinlock_t                nv_spinlock_t;
 #define NV_SPIN_LOCK_INIT(lock)   spin_lock_init(lock)
@@ -956,8 +960,8 @@
     return ret;

-#if defined(CONFIG_PREEMPT_RT)
-#define NV_INIT_MUTEX(mutex) semaphore_init(mutex)
+#define NV_INIT_MUTEX(mutex) sema_init(mutex,1)

Save the patch as "nv295.33_for 3.3+_rt.patch". Apply the patch->

sh NVIDIA-Linux-x86_64-295.33.run --apply-patch nv295.33_for 3.3+_rt.patch

This will build a new nvidia binary installer called "NVIDIA-Linux-x86_64-295.33-custom.run".

Run the installer with

sh NVIDIA-Linux-x86_64-295.33-custom.run

This patch comes with no garantee or warranty! Use it on your own risk.

Reboot and have fun.

You'll find more information in the nv forum. There you can find a solution for the 295.40 series, too.


  • Neat. Does the patched nvidia driver work with -generic too? It'd be useful to know how to produce a .deb instead of using the installer.
    – pablomme
    Commented Apr 16, 2012 at 15:18
  • 1
    Your patch is missing four spaces at the start of the line elif [ "$ARCH" = "ARMv7" ]; then and the one after -- it won't apply if this is not fixed. Also, you might want to mention that the nvidia driver version 295.33 can be downloaded from nvidia.com/object/linux-display-amd64-295.33-driver.html (it's not the latest any more, but judging by a report at phoronix.org from earlier today it may be better not to use 295.40 for the time being).
    – pablomme
    Commented Apr 17, 2012 at 0:17
  • sudo is missing from the installation command, as well as indication that you need to switch to a VT and do sudo killall Xorg && sudo stop lightdm before executing it because it insists that X must not be running. Other than that, everything works nicely -- now I can avoid bug bugs.launchpad.net/bugs/920120 and run dual-screen Ardour \o/ Thanks for the patch!
    – pablomme
    Commented Apr 17, 2012 at 2:14
  • This has nothing to do with the question, am I wrong? Commented Nov 27, 2012 at 15:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .