How can I remove a mainline kernel and move back to a supported kernel?
Solution 1:
How did you install it? If you just grabbed a load of deb files and installed them, getting rid of it is as simple as just finding the packages and running apt-get remove
for each of them.
I've just had a cup of coffee so you get to bare the full brunt of my bashfu this morning... This should tell you what kernels are installed:
dpkg -l | awk '/linux-[^ ]+-[0-9]/ {print $2}'
Go through those and note the versions you want to nuke. Take care to also note your current install (uname -a) or any new kernels you have installed since booting. You don't want to remove the newest ones.
Anyway when you've got an idea, you can bulk-remove them by adapting this command:
sudo apt-get purge linux-{headers,image,image-extra}-3.5.0-{7,8,9}.*
The words and numbers in the braces will be expanded at runtime so the packages this will actually target are:
linux-headers-3.5.0-7*
linux-headers-3.5.0-8*
linux-headers-3.5.0-9*
linux-image-3.5.0-7*
linux-image-3.5.0-8*
linux-image-3.5.0-9*
linux-image-extra-3.5.0-7*
linux-image-extra-3.5.0-8*
linux-image-extra-3.5.0-9*
You can mess around with this but for cleaning up I find this much safer than a wide-wildcard (as I currently on a 3.5.* kernel).
Either way, read what apt-get is going to do before you say yes. Removing current kernels and all kernels is a surprisingly common predicament that Ubuntu users find themselves in. It's not unfixable but yeah, don't do it!
Be especially careful with wildcards and apt-get. If you don't believe me run apt-get -s remove linux-image-3.4*
and see what it selects (yeah - all the kernels). Don't worry that command is in "simulate mode" so it won't do anything (and so doesn't need root).
Solution 2:
Uninstalling Mainline Kernels
The mainline kernels have their own ABI namespace so they install side by side with the stock Ubuntu kernels (each kernel has a separate directory under
/lib/modules/VERSION
for example). This means that you can keep several mainline and Ubuntu stock kernels installed at the same time and select the one you need from the GRUB boot menu.If you would like to uninstall a mainline kernel anyway, first use:
dpkg -l | grep "linux\-[a-z]*\-"
to find the exact name of the kernel packages you want to uninstall, and then do:
sudo apt-get remove KERNEL_PACKAGES_TO_REMOVE
Remember that several packages belong to one kernel version: common headers, architecture specific headers and the architecture specific image.
Source: https://wiki.ubuntu.com/Kernel/MainlineBuilds#Uninstalling_Mainline_Kernels