Score:4

How do I uninstall a problematic kernel?

in flag

Running Ubuntu 18.04 LTS I got a notice that an upgrade was needed and I consented. The upgrade updated my kernel from 5.4.0-91-generic to ...-92 and broke things. I can still boot to ...91 from GRUB.

I'm unable to spend any more time trying to resolve the upgrade problem at this time and would like to just uninstall it. However, I realize uninstalling is not the same a reverting and I am reluctant to just uninstall the ...92 upgrade as other things may be lost.

What can I do to remove the ...92 upgrade and get my machine back without damaging the OS?

The machine boots and I can SSH into it.

Someone avatar
my flag
Would you mind telling, why did you post the duplicate of your previous post again?
in flag
My reply to @Someone: It was rather late last night and I might have inadvertently posted twice. But I see no duplicate post to remove. What have I missed?
Someone avatar
my flag
I saw your [previous question](https://askubuntu.com/questions/1385287/lost-my-mouse-and-keyboard-on-upgrade) addressing the same problem with the kernel, which IMO is similar to this. But now, let's forget that... You already got 2 answers, so it doesn't matter. I took my downvote back and upvoted :D
in flag
Thank you,@Someone and thanks for the insight. I'll try to be more careful in the future
Someone avatar
my flag
No problem :D.... Have you tried the provided answers?
in flag
I was researching the grub-customizer and only found it available for 18.04 from a private repository. i wasn't sure which approach and wanted to look at it. But, I'm not much into using private repositories. Hence, I'm now stepping through the answer from nobody.
Someone avatar
my flag
You can install Grub customizer using `sudo apt install grub-customiser`. My answer also provides a CLI solution. It's your choice both the answers are correct :D BTW there is nothing wrong with that PPA. As its tested and trusted.
in flag
I took the non-GUI approach and am back in business. Thanks for your help and up-votes
Score:4
gh flag

It is better to do that without a GUI. GRUB is too important for me to trust a program which hides what it is doing exactly behind a GUI.

  1. First, create a backup of the /etc/default/grub file:

    cp /etc/default/grub $HOME
    
  2. Now, open /etc/default/grub with a text editor and add:

    GRUB_DEFAULT=saved
    GRUB_SAVEDEFAULT=true
    
  3. Update GRUB to save the changes:

    sudo update-grub
    
  4. Reboot to your working kernel, so that GRUB can save your choice for the next reboot.

  5. Now, list all the kernel packages:

    dpkg -l | egrep linux-'[g|i|m|h]'
    
  6. Once identified, you can remove any kernel package with 5.4.0-92 in its name (e.g. linux-image-5.4.0-92-generic, linux-headers-5.4.0-92, linux-modules-extra-5.4.0-92-generic, linux-modules-5.4.0-92-generic) via apt remove.

  7. If you want to avoid the problematic kernel coming with a future update, then run:

    sudo apt-mark hold linux-image-generic linux-headers-generic
    

    This will put a hold on the current linux-image-generic package and stop it from being updated.

    You can undo it with:

    sudo apt-mark unhold linux-image-generic linux-headers-generic
    

    but you may not want to do this, as it's possible that the following kernel update will boot without problems, and this stops the kernel from being updated to a newer version.

  8. To avoid that your running kernel gets uninstalled by apt autoremove, you can mark the kernel and header versions you want to keep on your system as manual. In your case the version you want to keep using is 5.4.0-91, so:

    sudo apt-mark manual linux-image-5.4.0-91-generic linux-headers-5.4.0-91-generic
    
in flag
Thanks for the advice. Your help is greatly appreciated
in flag
I took this non-GUI approach and everything seems to be fine. My thanks to all for your help. I'm back in business
Score:2
my flag

Graphical User Interface

You can do that using the grub-customizer Package. You can install it using:

sudo apt install grub-customizer

After installing the package you can launch the application using:

grub-customizer

You'll get an interface like:

enter image description here

Right-click on the kernel causing errors( 5.4.0-92-generic), and select remove:

enter image description here

Now, right-click on the working kernel ( 5.4.0-91-generic) and select move up:

enter image description here

Click on the save button to save the changes:

enter image description here

After doing the above run this in a terminal:

sudo update-grub
sudo apt autoremove

That's it!

Reference

Note: To get support and correct drivers for the device I'm using Ubuntu 21.10 with a custom kernel. Don't mind the kernel versions in the image, they're just for reference.

in flag
Thanks for the replies. Your help is most appreciated
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.