How to remove a newer kernel while booted with the older kernel?

14,546

Solution 1

You can remove kernels the same way you remove other packages, as long as you are not booted in that kernel.

To get a list of the kernels you have installed, use dpkg -l with a grep as in:

dpkg -l | grep linux

There you will see the list of packages that got installed.

Then use the remove command of apt-get

sudo apt-get remove linux-...<name as shown by dpkg -l>

The headers do not need to be removed, the linux-image-... are the actual binaries that need removal.

Note that apt-get should automatically re-run the necessary commands to update grub and the startup RAM disk.

Of course, if you use apt-get update + apt-get upgrade (or the auto-upgrade which does the same), the newer kernel will get re-installed...

I think you can prevent re-installation, but I do not know the command for that.

Solution 2

This is very simple. First you need to know a few things about the kernel you want to remove. You gotta have its full name (For example, 3.19.0-15-generic). You can find this by booting with 3.19 kernel, opening Terminal (Ctrl+Alt+T) and running the command

uname -r

Take note of the output. Reboot with 3.16 kernel and open Terminal again, running the commands

sudo apt-get remove linux-headers-$(uname -r)
sudo apt-get remove linux-image-$(uname -r)
sudo update-initramfs -d -k $(uname -r)
sudo update-initramfs -u
sudo update-grub

And it is done! The next time you see GRUB, 3.19 kernel will not be there anymore.

Share:
14,546

Related videos on Youtube

Wes Haq
Author by

Wes Haq

Updated on September 18, 2022

Comments

  • Wes Haq
    Wes Haq over 1 year

    I have two kernels installed on my system. 3.16... and 3.19.3...I'm running Ubuntu 14.10 and it came with the 3.16...kernel. I decided to try the latest possible kernel (3.19.3...), but I sometimes get errors and the system feels unstable. I see no reason to keep this new kernel. Is there any issue I might run into if I choose to boot into the older kernel, and then remove the newer one using say, Synaptic? Will I run into issues once I reboot, or will Ubuntu just boot automatically into the older kernel with no fuss?

    Any advice on the proper procedure and what methods to best achieve my goal would be appreciated. Thanks.

  • Wes Haq
    Wes Haq about 9 years
    Thanks! I cannot seem to upvote your answer without 15 reputation points (which I unfortunately don't have at the moment). I appreciate the answer though.
  • Wes Haq
    Wes Haq about 9 years
    Thanks! I cannot seem to upvote your answer without 15 reputation points (which I unfortunately don't have at the moment). I appreciate the answer though.
  • Eduardo Cola
    Eduardo Cola about 9 years
    No trouble, I'm here to help you!
  • mchid
    mchid over 6 years
    @WesHaq Hello Wes! You can select this as the solution by clicking the icon to the left.
  • Cerin
    Cerin almost 6 years
    Running sudo apt-get remove linux-headers-$(uname -r) will uninstall the currently running kernel. Do not do this.