When I run sudo apt-get upgrade or sudo apt-get autoremove, it returns:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 linux-image-amd64 : Depends: linux-image-5.10.0-16-amd64 (= 5.10.127-2) but it is not installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

Then, when I run sudo apt --fix-broken install, it returns:

Preparing to unpack .../linux-image-5.10.0-16-amd64_5.10.127-2_amd64.deb ...
Unpacking linux-image-5.10.0-16-amd64 (5.10.127-2) ...
dpkg: error processing archive /var/cache/apt/archives/linux-image-5.10.0-16-amd64_5.10.127-2_amd64.deb (--unpack):
 cannot copy extracted data for './boot/vmlinuz-5.10.0-16-amd64' to '/boot/vmlinuz-5.10.0-16-amd64.dpkg-new': failed to write (No space left on device)
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:

I had nearly the same error on a second Debian11/KDE computer with the same error message.

There I could solve it using these two commands from here to free disk space on the boot partition. However, the command to remove unneeded kernel images doesn't work on this computer: when I run

dpkg -l linux-{image,headers}-"[0-9]*" | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e '[0-9]'

it shows a number of kernel image filenames but when I run the full command

dpkg -l linux-{image,headers}-"[0-9]*" | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e '[0-9]' | xargs sudo apt -y purge

it doesn't remove them. The same filenames still show when I run the former command and no disk space is freed so my problem remains. The output of the above is:

The following packages have unmet dependencies:
linux-headers-amd64 : Depends: linux-headers-5.10.0-14-amd64 (= 5.10.113-1) but it is not going to be installed
linux-image-amd64 : Depends: linux-image-5.10.0-16-amd64 (= 5.10.127-2) but it is not going to be installed E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

  • First of all, all of this shouldn't be needed as upgrades should run smoothly and be so easy to do that basically most grandmas could do it. If there are issues with available disk space, it should prompt the user (in the console as well as in GUIs like Apper if that's used for upgrading) to do things like clearing old kernel images (maybe using the command above) or running sudo rm -rf /var/cache/apt/archives/* or clearing /tmp or running sudo apt-get autoremove/autoclean or other things depending how much disk space is needed and where. It should calculate how much disk space is needed and check if sufficient is available. Alternatively, if insufficient space is available, it could run the upgrades one at a time and clean up after each, or notify the user about it and abort the upgrade until enough disk space is available to prevent any issues. This is probably a separate question/issue. It's very inconvenient, outdated, insecure and user-unfriendly.
  • How to remove those old kernel images to free up the required disk space? If that wouldn't be the recommended route to solving this problem (again, it worked on another computer where I also had this problem), then please (also?) add how you'd solve it instead.
  • IIRC apt-get prints an estimate of the disk space consumed by the packages it has identified to be downloaded/installed. It's an easy message to ignore, and I've filled up my disk a number of times by ignoring it. There are MANY parts of Linux that will give only weak warning you may shoot yourself in the foot and then allow you to proceed. Caveat Sysadmintor
    – Sotto Voce
    Aug 17 at 15:01

1 Answer 1


I can’t help you with your first bullet point. To resolve your second one, you’ll have to temporarily remove linux-headers-amd64 and linux-image-amd64:

sudo apt remove linux-{headers,image}-amd64

Then explicitly remove any installed kernel package other than the package corresponding to the running kernel:

dpkg -l linux-{image,headers}-"[0-9]*" | awk "NR>5 && \!/^un/ && \!/$(uname -r | cut -d- -f-2)/ { print \$2 }" | xargs sudo apt -y purge

Finally, install the latest kernel:

sudo apt install linux-{headers,image}-amd64

If you install unattended-upgrades, it will take care of removing automatically-installed kernels for you when they are no longer needed.

  • Already had unattended-upgrades installed. Output of first command: cat: write error: No space left on device update-initramfs: failed for /boot/initrd.img-5.10.0-13-amd64 with 1. dpkg: error processing package initramfs-tools (--configure): installed initramfs-tools package post-installation script subprocess returned error exit status 1 Errors were encountered while processing: initramfs-tools [...] E: Sub-process /usr/bin/dpkg returned an error code (1) This solved it anyway.
    – mYnDstrEAm
    Aug 11 at 10:42
  • The three commands didn't work on another machine. You also have to remove the unneeded kernel images. Edited your answer ("Before doing this...") to add the two needed commands. This should be fixed by Debian so people can upgrade properly.
    – mYnDstrEAm
    Aug 17 at 14:11
  • In a default setup, unattended-upgrades does remove older kernels (it keeps the running kernel and the second-last kernel). If you think something needs to be fixed in Debian, please file a bug report. Aug 17 at 14:19
  • Without unattended-upgrades, things get more complicated since kernels are explicitly protected from auto-removal. Aug 17 at 15:04
  • 1
    I didn't manually install them. The bug report is here: bugs.debian.org/cgi-bin/bugreport.cgi?bug=1017617
    – mYnDstrEAm
    Aug 18 at 14:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.