9

I got the following output when removing a kernel by dpkg --purge :

Removing linux-headers-3.13.0-112-generic (3.13.0-112.159) ...
Removing linux-image-extra-3.13.0-112-generic (3.13.0-112.159) ...
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 3.13.0-112-generic /boot/vmlinuz-3.13.0-112-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 3.13.0-112-generic /boot/vmlinuz-3.13.0-112-generic
update-initramfs: Generating /boot/initrd.img-3.13.0-112-generic
W: TMPDIR is mounted noexec, will not cache run scripts.

gzip: stdout: No space left on device
E: mkinitramfs failure cpio 141 gzip 1
update-initramfs: failed for /boot/initrd.img-3.13.0-112-generic with 1.
run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1
dpkg: error processing package linux-image-extra-3.13.0-112-generic (--purge):
 subprocess installed post-removal script returned error exit status 1
Removing linux-image-3.13.0-112-generic (3.13.0-112.159) ...
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 3.13.0-112-generic /boot/vmlinuz-3.13.0-112-generic
update-initramfs: Deleting /boot/initrd.img-3.13.0-112-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 3.13.0-112-generic /boot/vmlinuz-3.13.0-112-generic
Generating grub configuration file ...
Warning: Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.
Found linux image: /boot/vmlinuz-4.4.0-71-generic
Found initrd image: /boot/initrd.img-4.4.0-71-generic
Found linux image: /boot/vmlinuz-4.4.0-67-generic
Found initrd image: /boot/initrd.img-4.4.0-67-generic
Found linux image: /boot/vmlinuz-4.4.0-66-generic
Found initrd image: /boot/initrd.img-4.4.0-66-generic
Found linux image: /boot/vmlinuz-4.4.0-64-generic
Found initrd image: /boot/initrd.img-4.4.0-64-generic
Found linux image: /boot/vmlinuz-3.13.0-115-generic
Found initrd image: /boot/initrd.img-3.13.0-115-generic
Found linux image: /boot/vmlinuz-3.13.0-113-generic
Found initrd image: /boot/initrd.img-3.13.0-113-generic
Found memtest86+ image: /memtest86+.elf
Found memtest86+ image: /memtest86+.bin
  No volume groups found
done
Purging configuration files for linux-image-3.13.0-112-generic (3.13.0-112.159) ...
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 3.13.0-112-generic /boot/vmlinuz-3.13.0-112-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 3.13.0-112-generic /boot/vmlinuz-3.13.0-112-generic
Errors were encountered while processing:
 linux-image-extra-3.13.0-112-generic

Why does it run out of space even when purging? It is not an inode issue in this case.

Note: There are other questions where error happens during dpkg --configure or when installing a kernel. It is more understandable that system runs out of disk space then, but in this case I am purging a kernel - a linux-image-extra package to be specific - by dpkg. There is no dependency problem in this case. For example in this one a solution could be to purge kernel packages directly by dpkg, but the issue of this question produces an error when doing so.

jarno
  • 5,600
  • 1
    @ElderGeek this happens when purging by dpkg, not by configuring. – jarno Mar 30 '17 at 14:38
  • @ElderGeek : I agree with jarno, and don't think it is a duplicate, at least of the referenced dup. Readers should also know that jarno is very experienced with kernel removal / purging. – Doug Smythies Mar 30 '17 at 14:41
  • Dpkg should be using / for work files and not /boot as per discussion we had in AU General Chat room as I was defining rmkernels project scope. This is an interesting problem presented by @jarno. – WinEunuuchs2Unix Mar 30 '17 at 14:57
  • @WinEunuuchs2Unix or it could use "/tmp" or whatever mktemp uses by default. I actually modified update-initramfs locally so that it works in this case. – jarno Mar 30 '17 at 23:35
  • @jarno The thing is when I first started planning the project I was thinking I read of problem where people couldn't purge because of no space left in /boot so the initial idea was to set file size of kernels images to 1 and then reclaim space in /boot before running apt-get purge but the idea was shot down by someone else as unnecessary. Now I'm thinking I should have stuck to the initial design.... – WinEunuuchs2Unix Mar 30 '17 at 23:39
  • Yes, it is a duplicate of all those questions. – fkraiem Mar 31 '17 at 09:10
  • 1
    @fkraiem I claim my answer is useful for this question. Not that useful for the other questions you refer to. – jarno Mar 31 '17 at 09:51
  • @karel Thank you for your edit. This question is much improved due to your efforts. – Elder Geek Mar 31 '17 at 12:17
  • 1
    @jarno Regarding this comment Do you have swap enabled? AFAIK, tmpfs should be able to move pages to swap to free up space. The output of df -h and free might shed some light on the issue as well. – Elder Geek Mar 31 '17 at 13:33
  • @ElderGeek I have swap enabled and /tmp mounted as tmpfs. The main thing is that /boot is not mounted in same point. The usual case when /boot is full is when /boot is in a separate partition. – jarno Mar 31 '17 at 14:10
  • @jarno Hence the duplicate flag – Elder Geek Mar 31 '17 at 14:14
  • @ElderGeek I don't see what you mean. – jarno Mar 31 '17 at 15:22

1 Answers1

6

When purging a linux-image-extra package, post installation scripts are run, since the main linux-image package of that kernel release may be left remaining in system: The respective initrd.img will be altered not to contain the extra's stuff; its size will decrease as a result of this process. However, the old initrd.img file is not removed in "/boot" and the new one is created beside it in "/boot" during this process, so there is a risk of running out of space.

The fix could be to create the new initrg.img file in different partition before replacing the old one by it in update-initramfs. So the update-initramfs script should be fixed.

A workaround would be to remove the respective versioned /boot/initrd.img file before running dpkg --purge for the linux-image-extra package. That could also be done by sudo update-initramfs -d -k 3.13.0-112-generic in this case, as the kernel I was removing was "3.13.0-112-generic".

jarno
  • 5,600