1

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?

1
  • it is definitely possible if you do not use automatic updates
    – Andra
    Jan 21, 2022 at 17:44

1 Answer 1

1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .