Keep old kernels

Solution 1:

/etc/kernel/postinst.d/apt-auto-removal generates /etc/apt/apt.conf.d/01autoremove-kernels.

So you can create new file APT configuration file same way.

sudo nano /etc/apt/apt.conf.d/01autoremove-kernels-stop

contains:

APT::NeverAutoRemove
{
   "^linux-image-*-generic$";
   "^linux-headers-*-generic$";
   "^linux-image-extra-*-generic$";
   "^linux-signed-image-*-generic$";
   "^.*-kernel-*-generic$";
   "^linux-tools-*-generic$";
};