How do I remove Kernel 3.1 that I added via a PPA?

Solution 1:

First boot into a kernel that you DONT want to remove i.e. boot into 3.0.x not 3.1.x.

To remove the packages you have just installed, you will need to find out their names. Run the following in a terminal:

dpkg -l | grep "linux\-[a-z]*\-"

For example - in my case:

enter image description here

What you are looking for are similarly named kernel 3.1 packages -

For my example - I've highlighted similar packages I want to remove - the command syntax would be:

sudo apt-get remove linux-headers-2.6.38-11
sudo apt-get remove linux-headers-2.6.38-11-generic
sudo apt-get remove linux-image-2.6.38-11-generic

To make it easier, just copy and paste the package names after typing sudo apt-get remove

Finish off by running:

sudo update-grub

Solution 2:

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.