@rbalint about your test case: I wonder why linux-image-4.8.0-53-generic
was not removed by u-u? Was it the booted kernel? You also did not run
'sudo /etc/kernel/postinst.d/apt-auto-removal' before running u-u. Your
test case does not show how the kernels were installed.

In the following, I show the extraction of terminal output of a more
complete test case for u-u. It installs linux-image-
extra-4.4.0-141-generic by apt. Output of 'apt autoremove --simulate'
shows it would remove the kernel, and one unneeded package that is not a
kernel related. Whereas u-u just removes the kernel (which may be the
expected behavior).

$ set -x; sudo apt install -y unattended-upgrades/xenial-proposed 
linux-image-extra-4.4.0-141-generic;  sudo apt-mark auto 
linux-image-extra-4.4.0-141-generic;  sudo 
/etc/kernel/postinst.d/apt-auto-removal;  apt autoremove --simulate;  sudo 
unattended-upgrade -v;  set +x
+ sudo apt install -y unattended-upgrades/xenial-proposed 
linux-image-extra-4.4.0-141-generic
Reading package lists... Done
Building dependency tree       
Reading state information... Done
unattended-upgrades is already the newest version (1.1ubuntu1.18.04.7~16.04.2).
Selected version '1.1ubuntu1.18.04.7~16.04.2' (Ubuntu:16.04/xenial-proposed 
[all]) for 'unattended-upgrades'
The following package was automatically installed and is no longer required:
  xscreensaver-data
Use 'sudo apt autoremove' to remove it.
Suggested packages:
  fdutils linux-doc-4.4.0 | linux-source-4.4.0 linux-tools 
linux-headers-4.4.0-141-generic
The following NEW packages will be installed:
  linux-image-4.4.0-141-generic linux-image-extra-4.4.0-141-generic
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 58,7 MB of archives.
After this operation, 224 MB of additional disk space will be used.
Get:1 http://ubuntu.mirror.true.nl/ubuntu xenial-updates/main amd64 
linux-image-4.4.0-141-generic amd64 4.4.0-141.167 [22,2 MB]
Get:2 http://ubuntu.mirror.true.nl/ubuntu xenial-updates/main amd64 
linux-image-extra-4.4.0-141-generic amd64 4.4.0-141.167 [36,5 MB]
Fetched 58,7 MB in 26s (2 233 kB/s)                                             
                                             
Selecting previously unselected package linux-image-4.4.0-141-generic.
(Reading database ... 332942 files and directories currently installed.)
Preparing to unpack .../linux-image-4.4.0-141-generic_4.4.0-141.167_amd64.deb 
...
Examining /etc/kernel/preinst.d/
run-parts: executing /etc/kernel/preinst.d/intel-microcode 4.4.0-141-generic 
/boot/vmlinuz-4.4.0-141-generic
Done.
Unpacking linux-image-4.4.0-141-generic (4.4.0-141.167) ...
Selecting previously unselected package linux-image-extra-4.4.0-141-generic.
Preparing to unpack 
.../linux-image-extra-4.4.0-141-generic_4.4.0-141.167_amd64.deb ...
Unpacking linux-image-extra-4.4.0-141-generic (4.4.0-141.167) ...
Setting up linux-image-4.4.0-141-generic (4.4.0-141.167) ...
Running depmod.
update-initramfs: deferring update (hook will be called later)
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.4.0-141-generic 
/boot/vmlinuz-4.4.0-141-generic
run-parts: executing /etc/kernel/postinst.d/dkms 4.4.0-141-generic 
/boot/vmlinuz-4.4.0-141-generic
Error! Your kernel headers for kernel 4.4.0-141-generic cannot be found.
Please install the linux-headers-4.4.0-141-generic package,
or use the --kernelsourcedir option to tell DKMS where it's located
Error! Your kernel headers for kernel 4.4.0-141-generic cannot be found.
Please install the linux-headers-4.4.0-141-generic package,
or use the --kernelsourcedir option to tell DKMS where it's located
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.4.0-141-generic 
/boot/vmlinuz-4.4.0-141-generic
update-initramfs: Generating /boot/initrd.img-4.4.0-141-generic
run-parts: executing /etc/kernel/postinst.d/pm-utils 4.4.0-141-generic 
/boot/vmlinuz-4.4.0-141-generic
run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 
4.4.0-141-generic /boot/vmlinuz-4.4.0-141-generic
run-parts: executing /etc/kernel/postinst.d/update-notifier 4.4.0-141-generic 
/boot/vmlinuz-4.4.0-141-generic
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 4.4.0-141-generic 
/boot/vmlinuz-4.4.0-141-generic
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.15.0-46-generic
Found initrd image: /boot/initrd.img-4.15.0-46-generic
Found linux image: /boot/vmlinuz-4.4.0-143-generic
Found initrd image: /boot/initrd.img-4.4.0-143-generic
Found linux image: /boot/vmlinuz-4.4.0-141-generic
Found initrd image: /boot/initrd.img-4.4.0-141-generic
Found memtest86+ image: /memtest86+.elf
Found memtest86+ image: /memtest86+.bin
Found Ubuntu 16.04.1 LTS (16.04) on /dev/sdc2
done
Setting up linux-image-extra-4.4.0-141-generic (4.4.0-141.167) ...
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.4.0-141-generic 
/boot/vmlinuz-4.4.0-141-generic
run-parts: executing /etc/kernel/postinst.d/dkms 4.4.0-141-generic 
/boot/vmlinuz-4.4.0-141-generic
Error! Your kernel headers for kernel 4.4.0-141-generic cannot be found.
Please install the linux-headers-4.4.0-141-generic package,
or use the --kernelsourcedir option to tell DKMS where it's located
Error! Your kernel headers for kernel 4.4.0-141-generic cannot be found.
Please install the linux-headers-4.4.0-141-generic package,
or use the --kernelsourcedir option to tell DKMS where it's located
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.4.0-141-generic 
/boot/vmlinuz-4.4.0-141-generic
update-initramfs: Generating /boot/initrd.img-4.4.0-141-generic
run-parts: executing /etc/kernel/postinst.d/pm-utils 4.4.0-141-generic 
/boot/vmlinuz-4.4.0-141-generic
run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 
4.4.0-141-generic /boot/vmlinuz-4.4.0-141-generic
run-parts: executing /etc/kernel/postinst.d/update-notifier 4.4.0-141-generic 
/boot/vmlinuz-4.4.0-141-generic
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 4.4.0-141-generic 
/boot/vmlinuz-4.4.0-141-generic
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.15.0-46-generic
Found initrd image: /boot/initrd.img-4.15.0-46-generic
Found linux image: /boot/vmlinuz-4.4.0-143-generic
Found initrd image: /boot/initrd.img-4.4.0-143-generic
Found linux image: /boot/vmlinuz-4.4.0-141-generic
Found initrd image: /boot/initrd.img-4.4.0-141-generic
Found memtest86+ image: /memtest86+.elf
Found memtest86+ image: /memtest86+.bin
Found Ubuntu 16.04.1 LTS (16.04) on /dev/sdc2
done
+ sudo apt-mark auto linux-image-extra-4.4.0-141-generic
linux-image-extra-4.4.0-141-generic set to automatically installed.
+ sudo /etc/kernel/postinst.d/apt-auto-removal
+ apt autoremove --simulate
NOTE: This is only a simulation!
      apt-get needs root privileges for real execution.
      Keep also in mind that locking is deactivated,
      so don't depend on the relevance to the real current situation!
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  linux-image-4.4.0-141-generic linux-image-extra-4.4.0-141-generic 
xscreensaver-data
0 upgraded, 0 newly installed, 3 to remove and 1 not upgraded.
Remv linux-image-extra-4.4.0-141-generic [4.4.0-141.167]
Remv linux-image-4.4.0-141-generic [4.4.0-141.167]
Remv xscreensaver-data [5.34-2ubuntu1]
+ sudo unattended-upgrade -v
Initial blacklisted packages: 
Initial whitelisted packages: 
Starting unattended upgrades script
Allowed origins are: o=Ubuntu,a=xenial, o=Ubuntu,a=xenial-security, 
o=UbuntuESM,a=xenial
Removing unused kernel packages: linux-image-4.4.0-141-generic 
linux-image-extra-4.4.0-141-generic
(Reading database ... 338562 files and directories currently installed.)
Removing linux-image-extra-4.4.0-141-generic (4.4.0-141.167) ...
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.4.0-141-generic 
/boot/vmlinuz-4.4.0-141-generic
run-parts: executing /etc/kernel/postinst.d/dkms 4.4.0-141-generic 
/boot/vmlinuz-4.4.0-141-generic
Error! Your kernel headers for kernel 4.4.0-141-generic cannot be found.
Please install the linux-headers-4.4.0-141-generic package,
or use the --kernelsourcedir option to tell DKMS where it's located
Error! Your kernel headers for kernel 4.4.0-141-generic cannot be found.
Please install the linux-headers-4.4.0-141-generic package,
or use the --kernelsourcedir option to tell DKMS where it's located
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.4.0-141-generic 
/boot/vmlinuz-4.4.0-141-generic
update-initramfs: Generating /boot/initrd.img-4.4.0-141-generic
run-parts: executing /etc/kernel/postinst.d/pm-utils 4.4.0-141-generic 
/boot/vmlinuz-4.4.0-141-generic
run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 
4.4.0-141-generic /boot/vmlinuz-4.4.0-141-generic
run-parts: executing /etc/kernel/postinst.d/update-notifier 4.4.0-141-generic 
/boot/vmlinuz-4.4.0-141-generic
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 4.4.0-141-generic 
/boot/vmlinuz-4.4.0-141-generic
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.15.0-46-generic
Found initrd image: /boot/initrd.img-4.15.0-46-generic
Found linux image: /boot/vmlinuz-4.4.0-143-generic
Found initrd image: /boot/initrd.img-4.4.0-143-generic
Found linux image: /boot/vmlinuz-4.4.0-141-generic
Found initrd image: /boot/initrd.img-4.4.0-141-generic
Found memtest86+ image: /memtest86+.elf
Found memtest86+ image: /memtest86+.bin
Found Ubuntu 16.04.1 LTS (16.04) on /dev/sdc2
done
Removing linux-image-4.4.0-141-generic (4.4.0-141.167) ...
Examining /etc/kernel/prerm.d.
run-parts: executing /etc/kernel/prerm.d/dkms 4.4.0-141-generic 
/boot/vmlinuz-4.4.0-141-generic
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 4.4.0-141-generic 
/boot/vmlinuz-4.4.0-141-generic
update-initramfs: Deleting /boot/initrd.img-4.4.0-141-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 4.4.0-141-generic 
/boot/vmlinuz-4.4.0-141-generic
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.15.0-46-generic
Found initrd image: /boot/initrd.img-4.15.0-46-generic
Found linux image: /boot/vmlinuz-4.4.0-143-generic
Found initrd image: /boot/initrd.img-4.4.0-143-generic
Found memtest86+ image: /memtest86+.elf
Found memtest86+ image: /memtest86+.bin
Found Ubuntu 16.04.1 LTS (16.04) on /dev/sdc2
done
The link /vmlinuz is a damaged link
Removing symbolic link vmlinuz 
 you may need to re-run your boot loader[grub]
The link /initrd.img is a damaged link
Removing symbolic link initrd.img 
 you may need to re-run your boot loader[grub]
Packages that were successfully auto-removed: linux-image-4.4.0-141-generic 
linux-image-extra-4.4.0-141-generic
Packages that are kept back: 
No packages found that can be upgraded unattended and no pending auto-removals
+ set +x

-- 
You received this bug notification because you are a member of Ubuntu
Touch seeded packages, which is subscribed to unattended-upgrades in
Ubuntu.
https://bugs.launchpad.net/bugs/1624644

Title:
  By default settings unattended-upgrade does not automatically remove
  kernel packages that become unused in conjunction with updating by
  other software

Status in unattended-upgrades package in Ubuntu:
  Fix Released
Status in update-manager package in Ubuntu:
  Fix Released
Status in unattended-upgrades source package in Xenial:
  Fix Committed
Status in update-manager source package in Xenial:
  Fix Released
Status in unattended-upgrades source package in Artful:
  Won't Fix
Status in update-manager source package in Artful:
  Fix Released

Bug description:
  [Impact]

   * Update-manager and unattended-upgrades install many kernel packages during 
the lifetime of a release but does not remove them automatically leading to 
those packages filling disk space potentially completely filling /boot and 
making the system unable to install updates or even boot.
   * Stable release users are impacted by this bug for years and their systems 
already collected many autoremovable unused kernel packages, thus they would 
benefit from backporting the fix greatly.
   * The bug is fixed by removing autoremovable (not currently booted) kernel 
packages when running unattended-upgrades or update-manager. Update manager 
offers the kernel removals when there are other updates to be installed.

  [Test Case]

   1. Install kernel packages to be removed, mark them auto-installed
  and run apt's kernel hook script to make apt consider them
  autoremovable:

    sudo apt install -y linux-image-extra-4.4.0-92-generic 
linux-image-extra-4.4.0-93-generic
    sudo apt-mark auto linux-image-extra-4.4.0-92-generic 
linux-image-extra-4.4.0-93-generic
    sudo /etc/kernel/postinst.d/apt-auto-removal

   2. Also downgrade a package to be upgraded:

     sudo apt-get install -y --allow-downgrades ca-
  certificates=20160104ubuntu1

   3. (update-manager). Run update-manager and observe that kernel
  packages are offered for removal in Details of updates.

    sudo update-manager

   4. (update-manager) Click on Install Now and observe that the kernel
  packages are removed.

   3. (unattended-upgrades, the fix comes in an update of u-u) Run
  unattended-upgrades manually and observe the removal of the
  autoremovable kernel packages:

    sudo unattended-upgrade -v

  [Regression Potential]

   The change may cause update-manager or unattanded-upgrades to remove
  used kernel packages or fail to install other package updates.

  [Other Info]

  The unattended-upgrades fix is uploaded with many other fixes and
  those may cause regressions in other areas in unattended-upgrades.

  [Original bug text]

  When using default settings for unattended-upgrade i.e.
  Unattended-Upgrade::Remove-Unused-Dependencies "false";
  # default "false"
  Unattended-Upgrade::Remove-New-Unused-Dependencies "true";
  # default "true"
  in configuration file /etc/apt/apt.conf.d/50unattended-upgrades,
  unattended-upgrade is unable to remove packages that become unused in 
conjunction with updating by other software such as update-manager or apt 
full-upgrade. This is because unattended-upgrade compares the list of unneeded 
packages before and after it upgrades packages to detect which packages are new 
unused ones.

  Consequently, if user installs new kernels using e.g. update-manager,
  the excessive kernels will not be removed by unattended-upgrade, and
  eventually (small) /boot will become full.

  Expected behavior: handle removing of unused packages differently at
  least until other package management software installed by default can
  handle removing of new unused packages.

  ProblemType: Bug
  DistroRelease: Ubuntu 16.04
  Package: unattended-upgrades 0.90
  ProcVersionSignature: Ubuntu 4.4.0-36.55-generic 4.4.16
  Uname: Linux 4.4.0-36-generic i686
  ApportVersion: 2.20.1-0ubuntu2.1
  Architecture: i386
  CurrentDesktop: XFCE
  Date: Sat Sep 17 11:28:44 2016
  InstallationDate: Installed on 2016-09-05 (11 days ago)
  InstallationMedia: Mythbuntu 16.04.1 LTS "Xenial Xerus" - Release i386 
(20160719)
  PackageArchitecture: all
  SourcePackage: unattended-upgrades
  UpgradeStatus: No upgrade log present (probably fresh install)

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/unattended-upgrades/+bug/1624644/+subscriptions

-- 
Mailing list: https://launchpad.net/~touch-packages
Post to     : touch-packages@lists.launchpad.net
Unsubscribe : https://launchpad.net/~touch-packages
More help   : https://help.launchpad.net/ListHelp

Reply via email to