How to downgrade kernel after bad update (16.04)

87,936

Solution 1

Remove the latest kernel by

sudo apt remove linux-image-4.4.0-91-generic linux-headers-4.4.0-91-generic

That will uninstall meta packages linux-generic, linux-image-generic and linux-headers-generic. Kernels will never be upgraded.

To revert it you can run

sudo apt install linux-generic

That will install the latest kernel and kernels will get upgrades.

linux-generic is a meta package. It is empty, but depends on two other meta packages: linux-image-generic and linux-headers-generic.

The last two point to the latest kernel image and headers.

If you remove meta packages, nothing will be removed from the Linux, but kernel image and headers won't get updates. You can always install them later. They will pull the latest "real" kernel packages.

So the solution is to manually remove the kernel packages you don't want and also the meta packages.

Solution 2

Although Pilot6's solution may be the best solution, you can do less drastic measures.

I would personally remove the kernels you do not want from software center and then put those packages on hold - see How to prevent updating of a specific package?

This is a trivial change and you can over ride or revert the change rather easily.

Share:
87,936

Related videos on Youtube

Alan De Smet
Author by

Alan De Smet

Geek. he/him

Updated on September 18, 2022

Comments

  • Alan De Smet
    Alan De Smet over 1 year

    Recent upgrades to the Ubuntu 16.04 kernel (4.4.0-89 and -91) failed badly on my laptop. Happily, I've got the previous, working version still installed (4.4.0-57). For now I've got Grub configured to show me a menu, and I'm manually selecting -57 on boot, but this seems fragile, likely to break on a future sudo apt upgrade.

    I think I want:

    • To remove -89 and -91, as they're not doing me any good.
    • To make -57 the default for Grub, in a way that will persist through upgrades.
    • To ensure the -57 stays installed, even if I install later kernel upgrade
    • To be able to easily try later kernel updates, but revert back to -57 if it fails. My primary concern is -57 being automatically removed.
    • If I find a functioning later update, an easy path to return to undo all of this and return to following kernel updates.

    Trying to remove -91 with sudo apt remove linux-image-4.4.0-91-genericrequires me to remove linux-generic and linux-headers-generic. That seems Bad, so I haven't tried it.

    I can find a variety of questions about the general problem, but none seem to address all of my goals, and most are old enough that I don't think they apply any more.

    What's the best way to do this?

    Addendum: This was flagged as a duplicate of How to prevent updating of a specific package? . That answer might address a portion of my question, but does not address the bigger picture.

    Broadly, the issue is that the kernel is handled in an unusual way. It's installed via linux-generic, which is nothing but a dependency on linux-image-generic and linux-image-headers. Those in turn are only dependencies on linux-linux-image-VERSION-generic and headers-VERSION-generic, packages noteworthy for baking the version number into the package name (presumably to make it easy to install multiple in parallel).

    Specifically not addressed in that answer are:

    • Does not address how to remove -89 and -91.
    • Does not address how to make -57 the default for Grub, even if I install later updates.
    • Does not address how to ensure that -57 stays installed, even if I install later updates. Even if the answer is to hold one or more packages, given the several packages involved, which ones would I hold? If it's a matter of holding linux-generic, how do I downgrade it first?
    • Pilot6
      Pilot6 over 6 years
      It is very unlikely that the kernels "failed" on your laptop. Probably you installed some driver a wrong way and it "failed" after a kernel upgrade. Did you install any graphics driver?
    • Pilot6
      Pilot6 over 6 years
      If you remove the latest kernel and linux-generic with headers, you will achieve your goal. But as I said the problem is different.
    • Alan De Smet
      Alan De Smet over 6 years
      "failed" was no wifi and X unhappy about my graphics. Both are Intel integrated and used stock drivers. Problem had persisted through multiple reboots, including a full shutdown/power on. So I my goal was a stopgap until I could seriously investigate. Naturally, I start to collect some information for serious investigation and -91 starts working as expected. sigh I'll cross my fingers for now.
    • Pilot6
      Pilot6 over 6 years
      This is not a duplicate. It is not about just freezing some package. Maybe it is a duplicate but not of the proposed question.
  • Pilot6
    Pilot6 over 6 years
    Which package you suggest to hold?
  • Panther
    Panther over 6 years
    linux-generic is probably sufficient, I am not certain. May need to add in the others and may need to specify the exact kernel, but I doubt it.
  • Panther
    Panther over 6 years
    sudo apt-mark hold linux-image-generic linux-headers-generic will do
  • Pilot6
    Pilot6 over 6 years
    Thar's correct. It is another way to do it. There is no much difference. But anyway you need to remove the latest kernel, that will remove the meta packages.
  • Panther
    Panther over 6 years
    I only suggested it as the OP suggested s/he did not want to remove the packages.
  • Pilot6
    Pilot6 over 6 years
    The latest kernel must be removed, or OP needs to do a lot more complicated action to change grub default.
  • Panther
    Panther over 6 years
    @Pilot6 - No you can keep the old kernels and mark grub which kernel to boot. askubuntu.com/questions/216398/…
  • Pilot6
    Pilot6 over 6 years
    Yes, you can. But it is too complicated and makes no practical sense.
  • Ufos
    Ufos over 2 years
    I was debugging a hardware issue and downgraded using your solution (I still had previous versions installed, but just wanted to make sure). However, sudo apt install linux-generic didn't bring me back on track. It installs kernel 5.4, while the ubuntu is on 5.11 right now, also what I had before, and since I only downgraded one minor version back, I still have 5.11, so it's kinda hilarious when apt install linux-generic gets me 5.4
  • Pilot6
    Pilot6 over 2 years
    You need to boot with the 5.4 kernel using grub menu.
  • Ufos
    Ufos over 2 years
    yeah, I can do that, but it's not an upgrade. I am still on 5.4 then, and before I was on 5.11 and downgraded just minor version. So, that's not "reverting".
  • Ufos
    Ufos over 2 years
    So, anyways, I figured out how to return to the mainline: sudo apt reinstall --install-recommends linux-generic-hwe-20.04