[Pkg-raspi-maintainers] Bug#1032186: raspi-firmware: Can make removing a kernel image fail and causing "apt upgrade" to fail early, too

Axel Beckert abe at debian.org
Wed Mar 1 11:48:49 GMT 2023


Package: raspi-firmware
Severity: serious
Tags: patch

Hi,

if /boot/firmware is (nearly) full, raspi-firmware prevents (!)
uninstalling a kernel image, because it still insists on copying stuff
to /boot/firmware upon kernel image removal.

An additional condition might be that another kernel image is present
and not fully configured for the same reason (not enough
diskspace). It's unlcear for me, if this additional condition is
required for this issue to reproduce.

In general you can run into such an issue within months if you have
automatic updates enabled and don't clear up old kernels
automatically. (And yes, in my case the VFAT partition is rather small
as this is a very old installation.

  # df -h /boot/firmware/
  Filesystem      Size  Used Avail Use% Mounted on
  /dev/mmcblk0p1  121M  121M  2.0K 100% /boot/firmware
  # dpkg --purge linux-image-6.1.0-1-armmp-lpae
  (Reading database ... 350731 files and directories currently installed.)
  Removing linux-image-6.1.0-1-armmp-lpae (6.1.4-1) ...
  /etc/kernel/postrm.d/initramfs-tools:
  update-initramfs: Deleting /boot/initrd.img-6.1.0-1-armmp-lpae
  /etc/kernel/postrm.d/z50-raspi-firmware:
  cp: error writing '/boot/firmware/vmlinuz-6.1.0-2-armmp-lpae': No space left on device
  run-parts: /etc/kernel/postrm.d/z50-raspi-firmware exited with return code 1
  dpkg: error processing package linux-image-6.1.0-1-armmp-lpae (--purge):
   installed linux-image-6.1.0-1-armmp-lpae package post-removal script subprocess returned error exit status 1
  Errors were encountered while processing:
   linux-image-6.1.0-1-armmp-lpae
  # ls -l /boot/firmware/{initrd.img,vmlinuz}-*
  -rwxr-xr-x 1 root root 25319457 Oct 13 08:32 /boot/firmware/initrd.img-5.19.0-2-armmp-lpae
  -rwxr-xr-x 1 root root 25268327 Dec  7 08:29 /boot/firmware/initrd.img-6.0.0-5-armmp-lpae
  -rwxr-xr-x 1 root root 25266000 Jan 18 08:21 /boot/firmware/initrd.img-6.0.0-6-armmp-lpae
  -rwxr-xr-x 1 root root  5210624 Oct 24 00:52 /boot/firmware/vmlinuz-5.19.0-2-armmp-lpae
  -rwxr-xr-x 1 root root  5267968 Dec  7 08:29 /boot/firmware/vmlinuz-6.0.0-5-armmp-lpae
  -rwxr-xr-x 1 root root  5267968 Dec 27 08:05 /boot/firmware/vmlinuz-6.0.0-6-armmp-lpae
  -rwxr-xr-x 1 root root  5370368 Jan 18 08:21 /boot/firmware/vmlinuz-6.1.0-1-armmp-lpae
  -rwxr-xr-x 1 root root  3817472 Mar  1 05:31 /boot/firmware/vmlinuz-6.1.0-2-armmp-lpae
  # dpkg --audit
  The following packages have been unpacked but not yet configured.
  They must be configured using dpkg --configure or the configure
  menu option in dselect for them to work:
   linux-headers-armmp-lpae Header files for Linux armmp-lpae configuration (meta
   linux-image-armmp-lpae Linux for ARMv7 multiplatform compatible SoCs supportin
  
  The following packages are only half configured, probably due to problems
  configuring them the first time.  The configuration should be retried using
  dpkg --configure <package> or the configure menu option in dselect:
   initramfs-tools      generic modular initramfs generator (automation)
   linux-headers-6.1.0-2-armmp-lpae Header files for Linux 6.1.0-2-armmp-lpae
   linux-image-6.1.0-2-armmp-lpae Linux 6.1 for ARMv7 multiplatform compatible So
   raspi-firmware       Raspberry Pi family GPU firmware and bootloaders
  
  The following packages are only half installed, due to problems during
  installation.  The installation can probably be completed by retrying it;
  the packages can be removed using dselect or dpkg --remove:
   linux-image-6.1.0-1-armmp-lpae Linux 6.1 for ARMv7 multiplatform compatible So

In the end, this also causes apt to abort rather early and not upgrade
or install anything anymore since then. This is also the reason why only
outdated kernel are (partially) installed.

So please stop copying stuff to /boot/firmware on kernel image removal
or purging. There will be an occasion for that at a later time anyway.

A patch (without the proper indentation probably wanted for readability)
which seems to have helped for me:

diff --git a/kernel/postinst.d/z50-raspi-firmware b/kernel/postinst.d/z50-raspi-firmware
index 1d3ae16..d898847 100755
--- a/kernel/postinst.d/z50-raspi-firmware
+++ b/kernel/postinst.d/z50-raspi-firmware
@@ -115,6 +115,7 @@ else
   dtb_path="/usr/lib/linux-image-${latest_kernel#/boot/vmlinuz-}"
 fi
 
+if [ "$1" != "remove" ]; then
 if [ "$KERNEL" = "auto" ] ; then
   for dtb in "${dtb_path}"/bcm*.dtb; do
     [ -e "${dtb}" ] || continue
@@ -128,6 +129,7 @@ if [ "$KERNEL" = "auto" ] ; then
   cp "$latest_kernel" /boot/firmware/
   cp "$latest_initrd" /boot/firmware/
 fi
+fi
 
 
 

-- System Information:
Debian Release: bookworm/sid
  APT prefers unstable
  APT policy: (990, 'unstable'), (600, 'testing'), (500, 'unstable-debug'), (500, 'buildd-unstable'), (110, 'experimental'), (1, 'experimental-debug'), (1, 'buildd-experimental')
merged-usr: no
Architecture: armhf

Kernel: Linux 6.0.0-5-armmp-lpae (SMP)
Locale: LANG=C.UTF-8, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)
LSM: AppArmor: enabled



More information about the Pkg-raspi-maintainers mailing list