apt: after reboot, still wants to keep 3 kernels when it should only keep 2

Bug #1757529 reported by Steve Langasek on 2018-03-21
This bug affects 1 person
Affects Status Importance Assigned to Milestone
apt (Ubuntu)

Bug Description

The apt kernel autoremoval handling should by design keep at least 2 and at most 3 kernels on the system.

However, on my 17.10 system, I currently have 3 kernels marked for retention while the kernel I have booted is the newest of these. This means that I'm not able to upgrade to 18.04 without manual intervention, because I have a /boot that's sized just large enough to fit 3 kernels, not 4, apt autoremove won't remove any of the kernels.

The sequence here is that I was running 4.13.0-36-generic; I updated, which pulled 4.13.0-37-generic onto the system; I ran apt autoremove --purge, which removed any kernels older than -36- from the system; I did *not* reboot; I installed 4.13.0-38-generic (from artful-proposed); all three kernels present are now marked for retention. I rebooted, and all three kernels are still marked for retention.

If /etc/kernel/postinst.d/apt-auto-removal were run *now*, it would mark 4.13.0-36-generic as autoremovable. But there is nothing that reruns this script on boot. Maybe there should be?

$ last
vorlon tty2 :0 Tue Mar 20 11:14 still logged in
reboot system boot 4.13.0-38-generi Tue Mar 20 10:34 still running
vorlon tty2 :0 Tue Mar 6 23:12 - down (13+10:21)
reboot system boot 4.13.0-36-generi Tue Mar 6 23:10 - 10:33 (13+10:23)

wtmp begins Tue Mar 6 23:09:27 2018

ProblemType: Bug
DistroRelease: Ubuntu 17.10
Package: apt 1.5.1
ProcVersionSignature: Ubuntu 4.13.0-38.43-generic 4.13.16
Uname: Linux 4.13.0-38-generic x86_64
NonfreeKernelModules: zfs zunicode zavl zcommon znvpair
ApportVersion: 2.20.7-0ubuntu3.7
Architecture: amd64
CurrentDesktop: ubuntu:GNOME
Date: Wed Mar 21 13:02:43 2018
InstallationDate: Installed on 2010-09-24 (2735 days ago)
InstallationMedia: Ubuntu 10.04.1 LTS "Lucid Lynx" - Release amd64 (20100816.1)
SourcePackage: apt
UpgradeStatus: Upgraded to artful on 2018-03-21 (0 days ago)

Steve Langasek (vorlon) wrote :
Steve Langasek (vorlon) wrote :
Steve Langasek (vorlon) wrote :

Attached apt term.log shows the history:
- 36 is running
- 31 is purged
- 37 is installed
- 32 is purged
- 38 is installed
- 37 is *not* purged
- rebooted to 38
- 36 and 37 are still not purged

Steve Langasek (vorlon) wrote :

As an alternative to running /etc/kernel/postinst.d/apt-auto-removal on boot, the code could be changed so that 37 is not retained once 38 is installed. I can't remember now if there was a rationale for marking second-newest kernel for retention, in the case where that kernel had never been booted.

Steve Langasek (vorlon) wrote :

Historical context (thanks, Julian): http://paste.ubuntu.com/p/qFfThVFChK/

The original design would have left 37 marked for autoremoval after 38 was installed. I think that is the correct behavior which should be restored.

Changed in apt (Ubuntu):
status: New → Triaged
importance: Undecided → Medium
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers