Ubuntu – Keep old kernels

aptkernel

I am doing experiments with few Linux kernels, also I want to keep all the kernels on my system; I don't want then to be removed automatically. how do I achieve that?

(NOTE: I have mounted /boot on separate 4GB partition so space is not an issue)

Best Answer

/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$";
};
Related Question