Score:0

How do I prevent Ubuntu from deleting an older kernel image

ru flag

I currently have this problem. In order to work around it, I have so far configured grub to keep booting from the 5.11.0 kernel.

Next time there is a kernel upgrade, I expect Ubuntu will install the new kernel and delete my 5.11.0 kernel. I would like to prevent this, as the the 5.11.0 kernel is my last known working kernel.

I think I can prevent linux-image-5.11.0-46-generic from upgrading by apt-mark hold'ing it. But, as I understand it, this will just stick my kernel to the 5.11.0 version.

Instead I would just like to keep linux-image-5.11.0-46-generic from being deleted when a new kernel version arrives, because I would like to test if newer kernel versions solve my problem, while I still have linux-image-5.11.0-46-generic to fall back on.

Is this possible somehow?

Andra avatar
tr flag
it is definitely possible if you do not use automatic updates
Score:1
jp flag

Create configuration for apt that prevents the packages from being uninstalled.

For example,

cat <<EOF > /etc/apt/apt.conf.d/05mykernels
APT::NeverAutoRemove
{
   "^linux-.*-5\.11\.0-46-generic$";
   "^kfreebsd-.*-5\.11\.0-46-generic$";
   "^gnumach-.*-5\.11\.0-46-generic$";
   "^.*-modules-5\.11\.0-46-generic$";
   "^.*-kernel-5\.11\.0-46-generic$";
};
EOF

I am borrowing the concept and configuration configuration from the file /etc/apt/apt.conf.d/01autoremove-kernels. That file is automatically generated when a new kernel gets installed to make sure certain kernel versions are kept if autoremove happens. By using the same concept, you can keep the specific kernel you want to keep from being automatically removed when newer kernels get installed.

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.