0
uname -r

5.15.0-60-generic

My apt upgrade is failing with:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
Get more security updates through Ubuntu Pro with 'esm-apps' enabled:
  mc libmagickcore-6.q16-6-extra node-hosted-git-info imagemagick libzmq5
  python2.7-minimal libmagickwand-6.q16-6 python2.7 python3-rsa mc-data
  node-tar imagemagick-6.q16 libeditorconfig0 libjs-jquery-ui libopenexr24
  libsdl2-2.0-0 libmysofa1 libmagickcore-6.q16-6 glances libpython2.7-minimal
  libpython2.7-stdlib imagemagick-6-common
Learn more about Ubuntu Pro at https://ubuntu.com/pro
0 to upgrade, 0 to newly install, 0 to remove and 0 not to upgrade.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up linux-firmware (1.187.36) ...
update-initramfs: Generating /boot/initrd.img-5.15.0-60-generic
I: The initramfs will attempt to resume from /dev/dm-2
I: (/dev/mapper/vgubuntu-swap_1)
I: Set the RESUME variable to override this.
Error 24 : Write error : cannot write compressed block 
E: mkinitramfs failure cpio 141 lz4 -9 -l 24
update-initramfs: failed for /boot/initrd.img-5.15.0-60-generic with 1.
dpkg: error processing package linux-firmware (--configure):
 installed linux-firmware package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 linux-firmware
E: Sub-process /usr/bin/dpkg returned an error code (1)

  1. First of all, I'm a little confused by this. I seem to be ON 5.15.0-60-generic already, why is it trying to
update-initramfs: failed for /boot/initrd.img-5.15.0-60-generic with 1.

?

  1. I presume this is due to low disk space:
df -H

Filesystem Size Used Avail Use% Mounted on udev 135G 0 135G 0% /dev tmpfs 28G 3.0M 28G 1% /run /dev/mapper/vgubuntu-root 982G 838G 94G 90% / tmpfs 136G 296M 135G 1% /dev/shm tmpfs 5.3M 4.1k 5.3M 1% /run/lock tmpfs 136G 0 136G 0% /sys/fs/cgroup /dev/nvme0n1p2 738M 588M 97M 86% /boot /dev/nvme0n1p1 536M 6.4M 530M 2% /boot/efi /dev/sda2 7.0T 1.5T 5.2T 23% /mnt/usb-8tb tmpfs 28G 25k 28G 1% /run/user/125 tmpfs 28G 70k 28G 1% /run/user/1000

So I'm trying to remove old linux kernels, which seems to be taking space:

dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n  | grep linux-image
20      linux-image-generic-hwe-20.04
9520    linux-image-5.8.0-43-generic
9927    linux-image-5.11.0-36-generic
9928    linux-image-5.11.0-37-generic
9933    linux-image-5.11.0-38-generic
9956    linux-image-5.13.0-25-generic
9956    linux-image-5.13.0-27-generic
9965    linux-image-5.13.0-28-generic
9965    linux-image-5.13.0-30-generic
9965    linux-image-5.13.0-35-generic
9968    linux-image-5.13.0-37-generic
9968    linux-image-5.13.0-39-generic
9971    linux-image-5.13.0-40-generic
9971    linux-image-5.13.0-41-generic
9971    linux-image-5.13.0-44-generic
9972    linux-image-5.13.0-48-generic
9973    linux-image-5.13.0-51-generic
9973    linux-image-5.13.0-52-generic
10775   linux-image-5.15.0-41-generic
10778   linux-image-5.15.0-43-generic
11196   linux-image-5.15.0-46-generic
11207   linux-image-5.15.0-52-generic
11208   linux-image-5.15.0-50-generic
11209   linux-image-5.15.0-48-generic
11210   linux-image-5.15.0-53-generic
11212   linux-image-5.15.0-56-generic
11214   linux-image-5.15.0-57-generic
11215   linux-image-5.15.0-58-generic
11223   linux-image-5.15.0-60-generic
11499   linux-image-5.11.0-40-generic
11502   linux-image-5.11.0-41-generic
11502   linux-image-5.11.0-43-generic
11504   linux-image-5.11.0-44-generic
11504   linux-image-5.11.0-46-generic
  1. But when trying to remove any of the older ones, it says it will only free up 0 bytes.

Appreciate some guidance here on those questions - many thanks.

Nik
  • 467

1 Answers1

0

Assumption: fsck is ok, i.e. not complaining.

Now,

Leave linux-image-generic-hwe-20.04 in place as that is a meta-package that is used for coming updates of your ubuntu.

The other ones are just taking up space, except the one printed by uname -r and maybe one prior to it (as a backup, for safety in case of malfunction in the latest).

These other-ones SHOULD be removable with e.g.
sudo apt purge linux-image-5.8.0-43-generic (for the first in your list (above)
you may also add more of them after the first one, just make sure there is at least one space in between each of them.

... or even do
dpkg-query -Wf '${Installed-Size}\t${Package}\n' | grep linux-image >~/kernels

Then make sure there is just names of ones to remove in that file...
(edit with e.g. nano ~/kernels, leave only packages to remove in there, save the file)
then do:

sudo apt purge $(cat ~/kernels)
... or similar.

Hannu
  • 10,568