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.
I would have upvoted your answer, but because I'm new on this site, I don't have the reputation to do that yet. I will try to remember to come back here later, when I can upvote your answer.
– jbang Mar 27 '15 at 11:51A second question? Do you know what the $-sign at the end of the original lines mean?
– jbang Mar 28 '15 at 21:00These lines in the 01autoremove-kernels file seem to imply the need for wildcards: "^.-modules-3.13.0-32-generic$"; "^.-modules-3.13.0-48-generic$"; "^.-kernel-3.13.0-32-generic$"; "^.-kernel-3.13.0-48-generic$";
– jbang Mar 28 '15 at 21:0201autoremove-kernels
only contains the last 2 or 3 kernel packages. When you install another one, the first one in the list is removed from the file making it prone to auto removal. – Aaron Digulla Mar 29 '15 at 12:51"^foo.*$"
is the same as"^foo"
.^
matches only the start of the string..*$
many "any character until the end of the string" but this is only necessary when the code requires a full match. Looking at other patterns in the apt config,"^foo"
should work. – Aaron Digulla Mar 29 '15 at 12:53.*
for "match any characters". Note the.
(dot) which means "any character" while*
just means "any number of the previous character". So what you wrote only matcheslinux-image-----------------generic
– Aaron Digulla May 04 '15 at 07:37