25

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?
4
  • 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
    Aug 11, 2017 at 18:49
  • If you remove the latest kernel and linux-generic with headers, you will achieve your goal. But as I said the problem is different.
    – Pilot6
    Aug 11, 2017 at 18:51
  • 1
    "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. Aug 11, 2017 at 19:06
  • 1
    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
    Aug 13, 2017 at 14:31

2 Answers 2

27

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.

4
  • 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
    – Ufos
    Nov 5, 2021 at 20:03
  • You need to boot with the 5.4 kernel using grub menu.
    – Pilot6
    Nov 6, 2021 at 8:15
  • 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
    Nov 6, 2021 at 19:40
  • So, anyways, I figured out how to return to the mainline: sudo apt reinstall --install-recommends linux-generic-hwe-20.04
    – Ufos
    Nov 21, 2021 at 19:42
3

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.

8
  • Which package you suggest to hold?
    – Pilot6
    Aug 11, 2017 at 19:18
  • 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
    Aug 11, 2017 at 19:20
  • 3
    sudo apt-mark hold linux-image-generic linux-headers-generic will do
    – Panther
    Aug 11, 2017 at 19:21
  • 1
    @Pilot6 - No you can keep the old kernels and mark grub which kernel to boot. askubuntu.com/questions/216398/…
    – Panther
    Aug 14, 2017 at 15:42
  • 1
    Yes, you can. But it is too complicated and makes no practical sense.
    – Pilot6
    Aug 14, 2017 at 16:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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