Downgrade linux kernel without GRUB

16,329

Solution 1

If I understood your question correctly, your problem is that you cannot successfully access the BIOS setup nor the GRUB prompt at boot time because of other problems, and you need to downgrade your kernel version.

Since the package management tools usually won't let you uninstall the kernel version you're currently running, you'll need to somehow first boot an older kernel without interacting with GRUB at boot time.

That's easy.

First look at /etc/default/grub in your system and find the GRUB_DEFAULT= setting. If it says:

GRUB_DEFAULT=saved

then you can use the sudo grub-set-default <number> to change which of the configured boot options GRUB will pick by default. Normally, it will be the topmost entry, or entry number 0. So if you want to backtrack one kernel update, you'd usually just say sudo grub-set-default 1 and reboot, and then you'll be free to remove the latest kernel package you had problems with.

But if the /etc/default/grub instead says:

GRUB_DEFAULT=0

then you can edit that file to say GRUB_DEFAULT=1 instead, and then run sudo update-grub to make the change effective. Then reboot, and again, you should be able to remove the newest kernel you have currently installed since you'll no longer be running on it.

After removing the problematic kernel version, you should undo your bootloader change, or you'll forever be one step behind in kernel updates :-)

So, either run sudo grub-set-default 0 or edit /etc/default/grub again to undo your change + run sudo update-grub, depending on which you originally did.

Solution 2

If you can boot into your system at all, you can uninstall the latest kernel version. Kernels are packages. The following command will give you the list of the ones installed on your system:

dpkg -l | grep linux-image

The latest one will be the one of the form linux-image-<version number>-generic, with the highest version number. To remove it, issue the following as root:

apt remove linux-image-<version number>-generic

Finally, to update grub so it knows which kernel versions are available for booting, run the following as root:

update-grub

Solution 3

Grub 2 keeps a list of all installed kernels, unless you have disabled or removed the previous kernel(s). Use that list of previous kernels to boot into a working system, and then remove the kernel, as the other answer instructs. See How can I boot with an older kernel version?

Share:
16,329

Related videos on Youtube

Mad Tata
Author by

Mad Tata

Updated on September 18, 2022

Comments

  • Mad Tata
    Mad Tata over 1 year

    I recently encountered some problems with my Dell XPS 13 running Ubuntu 17.10. I updated the linux kernel to the latest version. With the new kernel running, my wifi adapter wasn't working anymore. Also Virtualbox doesn't work anymore. I searched a lot on the internet but couldn't find any solution. I was told my only option would be to downgrade the kernel to the previous working version.

    Now the problem with this is, I'll have to use GRUB. My laptop has been showing difficulties since some weeks, and one of them is that my laptop won't boot most of the times. The times it does boot, it goes straight to the disk encryption password prompt, meaning I can not boot from USB, enter bios or enter the GRUB.

    Now my question is, is there any other way of downgrading the kernel without using GRUB? I have figured I might take out the SSD and try to fix it from another computer, but I don't have the necessary tools to open it up, and even if I did, I wouldn't know where to plug in a M.2 ssd.

  • jcollum
    jcollum over 2 years
    what do you do if you get a big warning about attempting to remove the kernel you are running?
  • jcollum
    jcollum over 2 years
    I think the answer to my question is that you should only do this from a terminal started via boot disk