Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I recently upgraded to kernel 3.4 in my Ubuntu 12.04. After that the computer is not booting up. So I used a previous kernel to boot up. Actually I don't want 3.4 kernel. So how can I remove it and use the previous one itself?

share|improve this question

2 Answers 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

share|improve this answer

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).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.