0

I'm running Kubuntu 14.04 on my private laptop. When the package system updates my Linux kernel it removes the old packages, only keeping the 2 newest versions of the kernel images (and associated packages). At the moment that would be (AFAIR) 3.13.0-32 and 3.13.0-48. How do I get the package system to stop removing the old kernel images?

I realize this will leave me with a long list of not used kernel images, but I would rather have to do the clean up myself, than risk ending up in a situation where I can't boot my laptop.

EDIT: Based on the answer from Aaron Digulla I created a file, /etc/apt/apt.conf.d/99keep-kernels, with this content:

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

But that didn't work. Ubuntu still only keeps the 2 latest kernels.

jbang
  • 15

1 Answers1

0

Pinning won't work for you since it will prevent from upgrading kernels altogether.

Look into /etc/apt/apt.conf.d/01autoremove and /etc/apt/apt.conf.d/01autoremove-kernels. These files contain lists of packages which should be purged automatically. The second file is maintained by the script /etc/kernel/postinst.d/apt-auto-removal

To solve your problem, copy the file /etc/apt/apt.conf.d/01autoremove-kernels into /etc/apt/apt.conf.d/99keep-kernels and edit the patterns to match any version of the 11 packages in there.

So

"^linux-image-3\.13\.0-45-generic$";

would become

"^linux-image-";

This pattern now matches any version of the package and prevents apt from deleting them ever. The post-install script does the same thing which doesn't create a conflict - your version of the file simply matches more packages and prevents any version to be deleted automatically.