Package: apt Followup-For: Bug #1085184 X-Debbugs-Cc: tj.iam...@proton.me I helped diagnose this same issue last evening in the Debian Matrix room and independently found the same causes as JAK reports.
To my mind the entire approach of trying to guess ahead of time how much space will be required is brittle and prone to unexplained corner-case failures such as this. I've recently been working on a feature extension for the kernel overlayfs and so it was a small step to wondering if apt could make use of overlayfs (either the kernel module or fuse) here ? On discovering a separate /boot/ : 1. record its free space 2. create an overlay (possibly using tmpfs for the upperdir) 3. let packages install as normal (with any triggering of update-initramfs) 4. after all changes are done unmount the overlay 5. review upperdir and if files exist 5a. check how much space they require 5b. if they will fit in /boot/ 5b1. copy files to /boot/ 5b. else 5b2. report difference, offer remedial actions (could be helper scripts) 6. conditionally remove upperdir files, unmount any tmpfs If not using a tmpfs the files could be left in place so the administrator has the ability to manually fix up the issue. The files being added aren't limited to the kernel image itself - for non x86 architectures there could be device-tree or other firmware related files installed by other packages. This space consideration should not be limited to just /boot/ itself. One such example is the Raspberry Pi where, since Bookworm, the FAT file-system containing the actual booted files is mounted at /boot/firmware/, kernel packages and update-initramfs write to /boot/ as normal but there is an additional hook script that then copies and renames the kernel image and initrd into /boot/firmware/ so there are potentially two -ENOSPACE file-systems in play. Rough PoC: df /boot mkdir --parents /var/tmp/apt/boot mount -t tmpfs apt_tmp /var/tmp/apt/boot mkdir /var/tmp/apt/boot/{upper,work} mount -t overlay apt_boot -o lowerdir=/boot,upperdir=/var/tmp/apt/boot/upper,workdir=/var/tmp/apt/boot/work /boot # all apt package operations would occur here update-initramfs -u # all packages are now installed/upgraded umount /boot find /var/tmp/apt/boot/upper -type f -ls cp -a /var/tmp/apt/boot/upper/* /boot/ rm -rf /var/tmp/apt/boot/* umount /var/tmp/apt/boot