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.
It is advisable, though not strictly necessary, to reboot and select an older kernel first. You can remove a kernel "under" the system that is running it--it will continue to stick around in memory and function OK. But just in case some problem has developed preventing your older kernels from working, you should try booting to one of them first. (Also, some installation processes might assume that the running kernel is actually installed.)
To use an older kernel, reboot and hold down Shift while your computer is starting up. You should see different options for booting, like a recovery mode and an option to check your memory/RAM. If you see any options for a kernel that is not version 3.1, select the latest such kernel (don't select "recovery mode"). That is, select the 3.0-series kernel with the highest version number, but do not select a 3.1-series kernel. If you don't see any such option, then select the option to view older kernels, and select it there.
In the unlikely event that you attempt to boot from an older kernel but cannot, you should not proceed with the uninstallation, as that might be the only kernel you have (if no others are listed) or the only kernel that is properly functioning. (In that case, you should post a comment to this question detailing what happened, and I'll add information about how to solve this problem to my question...or request more information if necessary. However, given the information you have provided, this situation is extremely unlikely.)
After booting from an 3.0-series kernel (or not, if you decided to forego that), you can remove the 3.1-series kernel you installed by running this command:
sudo apt-get purge linux-headers-3.1.0-030100 linux-headers-3.1.0-030100-generic linux-image-3.1.0-030100-generic
Using remove
instead of purge
(as suggested in the other answers so far) will work too but may leave some left-over global configuration files; purge
is probably preferable.
It's not necessary to search for the packages to remove using something like dpkg -l | grep "linux\-[a-z]*\-"
(as this answer suggests) or sudo aptitude search ~i | grep linux-image
(as this one suggests) because we know exactly what packages you installed (since you provided the instructions used to install them, which includes the exact package names). Your older (i.e., 3.0-series) kernels would not have been removed automatically, and the version for this kernel would not have changed since you installed it by manually downloading and installing the .deb
files rather than by actually enabling the PPA. (If you'd installed it from the PPA, then you still wouldn't have to search--you could just ppa-purge
the PPA.) We also do not have to worry about virtual packages being installed that would result in the 3.1-series kernel coming back automatically; installing those virtual packages would give you the newer kernel, but installing the newer kernel as you did above would not install those virtual packages.
Thus the steps described above should be quite sufficient.
Best Answer
There are 3 files you will need to remove, more if you are using a virtual machine too. But these are the main ones.
Open synaptic, use the search to find the installed kernels
linux-headers-3.2.x.x
linux-headers-3.2.x.x-generic
(possibly generic-pae or i686)linux-image-3.2.x.x
Should be easy enough to remove. Afterward run