apt autoremove not removing old kernels

Bug #1779657 reported by Vasya Pupkin
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
apt (Ubuntu)
Expired
Undecided
Unassigned

Bug Description

I noticed that apt autoremove stopped removing old kernels recently. Currently I have 6 installed and apt autoremove does not try to remove old ones:

$ sudo apt autoremove --purge
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

In /etc/apt/apt.conf.d/01autoremove-kernels it is said to only keep last three versions:

# list of different kernel versions:
4.15.0-24.26~16.04.1
4.15.0-23.25~16.04.1
4.15.0-22.24~16.04.1
4.15.0-15.16~16.04.1
4.13.0-45.50~16.04.1
4.13.0-43.48~16.04.1
# Installing kernel: 4.13.0-45.50~16.04.1 (4.13.0-45-generic)
# Running kernel: 4.15.0-23.25~16.04.1 (4.15.0-23-generic)
# Last kernel: 4.15.0-24.26~16.04.1
# Previous kernel: 4.15.0-23.25~16.04.1
# Kernel versions list to keep:
4.13.0-45.50~16.04.1
4.15.0-23.25~16.04.1
4.15.0-24.26~16.04.1
# Kernel packages (version part) to protect:
4\.13\.0-45-generic
4\.15\.0-23-generic
4\.15\.0-24-generic

It was working fine previously and I didn't change anything that could break this functionality.

ProblemType: Bug
DistroRelease: Ubuntu 16.04
Package: apt 1.2.26
ProcVersionSignature: Ubuntu 4.15.0-24.26~16.04.1-generic 4.15.18
Uname: Linux 4.15.0-24-generic x86_64
ApportVersion: 2.20.1-0ubuntu2.18
Architecture: amd64
CurrentDesktop: Unity
Date: Mon Jul 2 14:12:03 2018
InstallationDate: Installed on 2018-01-19 (164 days ago)
InstallationMedia: Ubuntu 16.04.3 LTS "Xenial Xerus" - Release amd64 (20170801)
SourcePackage: apt
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Vasya Pupkin (shadowlmd) wrote :
summary: - apt autoremove not removing old 4.15 kernels
+ apt autoremove not removing old kernels
Revision history for this message
Sean Burlington (sean-practicalweb) wrote :

I was looking into the same thing

It seems like this is intentional

I'm on this version

lsb_release -a
LSB Version: core-11.1.0ubuntu2-noarch:printing-11.1.0ubuntu2-noarch:security-11.1.0ubuntu2-noarch
Distributor ID: Ubuntu
Description: Ubuntu 20.04.1 LTS
Release: 20.04
Codename: focal

It appears apt is configured to never autoremove kernels

/etc/apt/apt.conf.d/01autoremove

  NeverAutoRemove
  {
        "^firmware-linux.*";
        "^linux-firmware$";
        "^linux-image-[a-z0-9]*$";
        "^linux-image-[a-z0-9]*-[a-z0-9]*$";
  };

Revision history for this message
Julian Andres Klode (juliank) wrote :

Sean:

What you quoted is the part that tells apt to not remove kernel _meta_ packages. Individual kernels are automatically removed subject to the kernel autoremoval helper script output in /etc/apt/apt.conf.d/01autoremove-kernels; which keeps up to 3 kernels around.

Note that this stops working if you manually install a certain kernel version, as it only works for automatically installed kernel versions.

Revision history for this message
Julian Andres Klode (juliank) wrote :

Probably the kernels were manually installed for some reason, but there's certainly not enough to act on this. Needs at least /var/lib/apt/extended_states /var/lib/dpkg/status /etc/apt/apt.conf.d/01autoremove-kernels to be able to investigate what happened here.

Changed in apt (Ubuntu):
status: New → Incomplete
Revision history for this message
Vasya Pupkin (shadowlmd) wrote :

No manually installed kernels. And these were not meta packages. But since I am on 20.04 now, this is not affecting me anymore.

Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for apt (Ubuntu) because there has been no activity for 60 days.]

Changed in apt (Ubuntu):
status: Incomplete → Expired
Revision history for this message
dragonhahney (dragonhahney) wrote : Re: [Bug 1779657] Re: apt autoremove not removing old kernels

Thanks for the update!

On Mon, Mar 22, 2021, 12:25 AM Launchpad Bug Tracker <
<email address hidden>> wrote:

> [Expired for apt (Ubuntu) because there has been no activity for 60
> days.]
>
> ** Changed in: apt (Ubuntu)
> Status: Incomplete => Expired
>
> --
> You received this bug notification because you are subscribed to apt in
> Ubuntu.
> Matching subscriptions: dragonhahney
> https://bugs.launchpad.net/bugs/1779657
>
> Title:
> apt autoremove not removing old kernels
>
> Status in apt package in Ubuntu:
> Expired
>
> Bug description:
> I noticed that apt autoremove stopped removing old kernels recently.
> Currently I have 6 installed and apt autoremove does not try to remove
> old ones:
>
> $ sudo apt autoremove --purge
> Reading package lists... Done
> Building dependency tree
> Reading state information... Done
> 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
>
> In /etc/apt/apt.conf.d/01autoremove-kernels it is said to only keep
> last three versions:
>
> # list of different kernel versions:
> 4.15.0-24.26~16.04.1
> 4.15.0-23.25~16.04.1
> 4.15.0-22.24~16.04.1
> 4.15.0-15.16~16.04.1
> 4.13.0-45.50~16.04.1
> 4.13.0-43.48~16.04.1
> # Installing kernel: 4.13.0-45.50~16.04.1 (4.13.0-45-generic)
> # Running kernel: 4.15.0-23.25~16.04.1 (4.15.0-23-generic)
> # Last kernel: 4.15.0-24.26~16.04.1
> # Previous kernel: 4.15.0-23.25~16.04.1
> # Kernel versions list to keep:
> 4.13.0-45.50~16.04.1
> 4.15.0-23.25~16.04.1
> 4.15.0-24.26~16.04.1
> # Kernel packages (version part) to protect:
> 4\.13\.0-45-generic
> 4\.15\.0-23-generic
> 4\.15\.0-24-generic
>
> It was working fine previously and I didn't change anything that could
> break this functionality.
>
> ProblemType: Bug
> DistroRelease: Ubuntu 16.04
> Package: apt 1.2.26
> ProcVersionSignature: Ubuntu 4.15.0-24.26~16.04.1-generic 4.15.18
> Uname: Linux 4.15.0-24-generic x86_64
> ApportVersion: 2.20.1-0ubuntu2.18
> Architecture: amd64
> CurrentDesktop: Unity
> Date: Mon Jul 2 14:12:03 2018
> InstallationDate: Installed on 2018-01-19 (164 days ago)
> InstallationMedia: Ubuntu 16.04.3 LTS "Xenial Xerus" - Release amd64
> (20170801)
> SourcePackage: apt
> UpgradeStatus: No upgrade log present (probably fresh install)
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/ubuntu/+source/apt/+bug/1779657/+subscriptions
>

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.