Score:0

Exclude a kernel from grub without deleting it

ir flag

Background: (in case this serves to detect an XY problem) With a recent update to Ubuntu 22.04, an Oracle kernel showed up in my grub menu, ending up on top since its versioning uses higher numbers.

Doing some digging around, this appears to be a dependency of NVIDIA proprietary drivers, which is not meant to be booted from. The update which added this to my grub also updated the kernel, so I'm assuming the update introduced the new kernel by letting grub scan for new kernels.

Currently I am using a workaround of GRUB_DEFAULT=saved, which works great for rebooting the system, but requires me to manually select the kernel after switching systems back an forth on a dual boot setup.

The question: Can you make grub forget about a kernel, without actually removing it from the system, and without excluding an entire disk?

I do not wish to set the first grub option to a specific kernel, as this manually created link would presumably not get updated when the system's kernel does, making it easy to miss an update.

EDIT: prompted by a comment, the listing I am referring to is "Advanced options." I'm looking for a command or a config file edit that will either persistently mark a kernel not to be included in grub upon scanning for kernels with a command like update-grub, or to at least remove it from the listing until the next scan for new kernels. The goal is to make it so that the top kernel, which will automatically be booted, is not an unwanted kernel used as a dependency, but the system's newest kernel. As to my understanding, the default "Ubuntu" boot option runs the top listing in this menu.

oldfred avatar
cn flag
If you want a temporary fix, you can violate the rule that says to never edit grub.cfg. As it gets updated with every kernel, grub or perhaps some other major change. The grub config is normally then updated. You can also turn off all the scripts and manually create your own grub.cfg. But then with every major update have to manually edit in new kernel. And then you may not get some of the configuration changes that really should be included.
I sit in a Tesla and translated this thread with Ai:

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.