Stack Exchange
Clear up space on /boot
Okay, I've tried all the typical things that every forum I've come across has suggested. Here are my /boot contents:
$ ls /boot
abi-4.4.0-101-generic     config-4.4.0-98-generic       System.map-4.4.0-104-generic
abi-4.4.0-103-generic     grub                          System.map-4.4.0-89-generic
abi-4.4.0-104-generic     initrd.img-4.4.0-101-generic  System.map-4.4.0-92-generic
abi-4.4.0-89-generic      initrd.img-4.4.0-103-generic  System.map-4.4.0-93-generic
abi-4.4.0-92-generic      initrd.img-4.4.0-104-generic  System.map-4.4.0-96-generic
abi-4.4.0-93-generic      initrd.img-4.4.0-89-generic   System.map-4.4.0-97-generic
abi-4.4.0-96-generic      initrd.img-4.4.0-92-generic   System.map-4.4.0-98-generic
abi-4.4.0-97-generic      initrd.img-4.4.0-93-generic   vmlinuz-4.4.0-101-generic
abi-4.4.0-98-generic      initrd.img-4.4.0-96-generic   vmlinuz-4.4.0-103-generic
config-4.4.0-101-generic  initrd.img-4.4.0-97-generic   vmlinuz-4.4.0-104-generic
config-4.4.0-103-generic  initrd.img-4.4.0-98-generic   vmlinuz-4.4.0-89-generic
config-4.4.0-104-generic  lost+found                    vmlinuz-4.4.0-92-generic
config-4.4.0-89-generic   memtest86+.bin                vmlinuz-4.4.0-93-generic
config-4.4.0-92-generic   memtest86+.elf                vmlinuz-4.4.0-96-generic
config-4.4.0-93-generic   memtest86+_multiboot.bin      vmlinuz-4.4.0-97-generic
config-4.4.0-96-generic   System.map-4.4.0-101-generic  vmlinuz-4.4.0-98-generic
config-4.4.0-97-generic   System.map-4.4.0-103-generic


I've tried:
$ sudo apt-get autoremove
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt-get -f install' to correct these.
The following packages have unmet dependencies:
 linux-image-extra-4.4.0-109-generic : Depends: linux-image-4.4.0-109-generic but it is not installed
 linux-image-extra-4.4.0-128-generic : Depends: linux-image-4.4.0-128-generic but it is not installed
 linux-image-generic : Depends: linux-image-4.4.0-128-generic but it is not installed
E: Unmet dependencies. Try using -f.

which leads me to:
$ sudo apt-get -f install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
  fonts-lato libllvm3.8 linux-headers-4.4.0-101 linux-headers-4.4.0-101-generic
  linux-headers-4.4.0-109 linux-headers-4.4.0-109-generic linux-headers-4.4.0-89
  linux-headers-4.4.0-89-generic linux-headers-4.4.0-92 linux-headers-4.4.0-92-generic
  linux-headers-4.4.0-93 linux-headers-4.4.0-93-generic linux-headers-4.4.0-96
  linux-headers-4.4.0-96-generic linux-headers-4.4.0-97 linux-headers-4.4.0-97-generic
  linux-headers-4.4.0-98 linux-headers-4.4.0-98-generic linux-image-4.4.0-101-generic
  linux-image-4.4.0-109-generic linux-image-4.4.0-89-generic linux-image-4.4.0-92-generic
  linux-image-4.4.0-93-generic linux-image-4.4.0-96-generic linux-image-4.4.0-97-generic
  linux-image-4.4.0-98-generic linux-image-extra-4.4.0-101-generic
  linux-image-extra-4.4.0-109-generic linux-image-extra-4.4.0-89-generic
  linux-image-extra-4.4.0-92-generic linux-image-extra-4.4.0-93-generic
  linux-image-extra-4.4.0-96-generic linux-image-extra-4.4.0-97-generic
  linux-image-extra-4.4.0-98-generic rake ruby ruby-did-you-mean ruby-minitest
  ruby-net-telnet ruby-power-assert ruby-test-unit ruby2.3
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  linux-image-4.4.0-109-generic linux-image-4.4.0-128-generic
Suggested packages:
  fdutils linux-doc-4.4.0 | linux-source-4.4.0 linux-tools
The following NEW packages will be installed:
  linux-image-4.4.0-109-generic linux-image-4.4.0-128-generic
0 upgraded, 2 newly installed, 0 to remove and 428 not upgraded.
20 not fully installed or removed.
Need to get 0 B/44.0 MB of archives.
After this operation, 135 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
(Reading database ... 583603 files and directories currently installed.)
Preparing to unpack .../linux-image-4.4.0-128-generic_4.4.0-128.154_amd64.deb ...
Examining /etc/kernel/preinst.d/
run-parts: executing /etc/kernel/preinst.d/intel-microcode 4.4.0-128-generic /boot/vmlinuz-4.4.0-128-generic
Done.
Unpacking linux-image-4.4.0-128-generic (4.4.0-128.154) ...
dpkg: error processing archive /var/cache/apt/archives/linux-image-4.4.0-128-generic_4.4.0-128.154_amd64.deb (--unpack):
 cannot copy extracted data for './boot/vmlinuz-4.4.0-128-generic' to '/boot/vmlinuz-4.4.0-128-generic.dpkg-new': failed to write (No space left on device)
No apport report written because the error message indicates a disk full error
                                                                              dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 4.4.0-128-generic /boot/vmlinuz-4.4.0-128-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 4.4.0-128-generic /boot/vmlinuz-4.4.0-128-generic
Preparing to unpack .../linux-image-4.4.0-109-generic_4.4.0-109.132_amd64.deb ...
Examining /etc/kernel/preinst.d/
run-parts: executing /etc/kernel/preinst.d/intel-microcode 4.4.0-109-generic /boot/vmlinuz-4.4.0-109-generic
Done.
Unpacking linux-image-4.4.0-109-generic (4.4.0-109.132) ...
dpkg: error processing archive /var/cache/apt/archives/linux-image-4.4.0-109-generic_4.4.0-109.132_amd64.deb (--unpack):
 cannot copy extracted data for './boot/vmlinuz-4.4.0-109-generic' to '/boot/vmlinuz-4.4.0-109-generic.dpkg-new': failed to write (No space left on device)
No apport report written because the error message indicates a disk full error
                                                                              dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 4.4.0-109-generic /boot/vmlinuz-4.4.0-109-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 4.4.0-109-generic /boot/vmlinuz-4.4.0-109-generic
Errors were encountered while processing:
 /var/cache/apt/archives/linux-image-4.4.0-128-generic_4.4.0-128.154_amd64.deb
 /var/cache/apt/archives/linux-image-4.4.0-109-generic_4.4.0-109.132_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)


I've also tried:
(How do I free up more space in /boot? )
$ sudo apt-get purge $(dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve "$(uname -r | sed -r 's/-[a-z]+//')")
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 linux-image-extra-4.4.0-101-generic : Depends: linux-image-4.4.0-101-generic but it is not going to be installed
 linux-image-extra-4.4.0-103-generic : Depends: linux-image-4.4.0-103-generic but it is not going to be installed
 linux-image-extra-4.4.0-109-generic : Depends: linux-image-4.4.0-109-generic but it is not going to be installed
 linux-image-extra-4.4.0-128-generic : Depends: linux-image-4.4.0-128-generic but it is not going to be installed
 linux-image-extra-4.4.0-89-generic : Depends: linux-image-4.4.0-89-generic but it is not going to be installed
 linux-image-extra-4.4.0-92-generic : Depends: linux-image-4.4.0-92-generic but it is not going to be installed
 linux-image-extra-4.4.0-93-generic : Depends: linux-image-4.4.0-93-generic but it is not going to be installed
 linux-image-extra-4.4.0-96-generic : Depends: linux-image-4.4.0-96-generic but it is not going to be installed
 linux-image-extra-4.4.0-97-generic : Depends: linux-image-4.4.0-97-generic but it is not going to be installed
 linux-image-extra-4.4.0-98-generic : Depends: linux-image-4.4.0-98-generic but it is not going to be installed
 linux-image-generic : Depends: linux-image-4.4.0-128-generic but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

and
$ dpkg -l linux-{image,headers}-"[0-9]*" | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e '[0-9]'
linux-headers-4.4.0-101
linux-headers-4.4.0-101-generic
linux-headers-4.4.0-103
linux-headers-4.4.0-103-generic
linux-headers-4.4.0-62
linux-headers-4.4.0-62-generic
linux-headers-4.4.0-89
linux-headers-4.4.0-89-generic
linux-headers-4.4.0-92
linux-headers-4.4.0-92-generic
linux-headers-4.4.0-93
linux-headers-4.4.0-93-generic
linux-headers-4.4.0-96
linux-headers-4.4.0-96-generic
linux-headers-4.4.0-97
linux-headers-4.4.0-97-generic
linux-headers-4.4.0-98
linux-headers-4.4.0-98-generic
linux-image-4.4.0-101-generic
linux-image-4.4.0-103-generic
linux-image-4.4.0-89-generic
linux-image-4.4.0-92-generic
linux-image-4.4.0-93-generic
linux-image-4.4.0-96-generic
linux-image-4.4.0-97-generic
linux-image-4.4.0-98-generic

$ 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-get -y purge
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 linux-image-extra-4.4.0-101-generic : Depends: linux-image-4.4.0-101-generic but it is not going to be installed
 linux-image-extra-4.4.0-103-generic : Depends: linux-image-4.4.0-103-generic but it is not going to be installed
 linux-image-extra-4.4.0-109-generic : Depends: linux-image-4.4.0-109-generic but it is not going to be installed
 linux-image-extra-4.4.0-128-generic : Depends: linux-image-4.4.0-128-generic but it is not going to be installed
 linux-image-extra-4.4.0-89-generic : Depends: linux-image-4.4.0-89-generic but it is not going to be installed
 linux-image-extra-4.4.0-92-generic : Depends: linux-image-4.4.0-92-generic but it is not going to be installed
 linux-image-extra-4.4.0-93-generic : Depends: linux-image-4.4.0-93-generic but it is not going to be installed
 linux-image-extra-4.4.0-96-generic : Depends: linux-image-4.4.0-96-generic but it is not going to be installed
 linux-image-extra-4.4.0-97-generic : Depends: linux-image-4.4.0-97-generic but it is not going to be installed
 linux-image-extra-4.4.0-98-generic : Depends: linux-image-4.4.0-98-generic but it is not going to be installed
 linux-image-generic : Depends: linux-image-4.4.0-128-generic but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).


Your case looks exactly like How do I free up more space in /boot?. While you claim to have "tried everything", you have not provided basic data like uname and df that you would have collected had you really done so. You seem to be seeking a simple incantation - if it were so easy, the system would have done it for you already. The solution is easy but tedious - use apt to remove each old kernel (solving dependencies along the way), then reinstall the kernel metapackage to pull in the latest version.

You could try these https://www.poftut.com/solve-sub-process-usr-bin-dpkg-returned-error-code-1-error/ steps first before you try my solution!

Possible duplicate of How do I remove old kernel versions to clean up the boot menu?

@user535733 obviously it looks just like that problem.. that's why I linked the issue. Look at the solution in that question and look at the things I've tried in my question. I've tried their solutions and they didn't work for me. I'm obviously having a hard time figuring out why, which is why I reached out for help. The question is already painfully long, so I figured it wouldn't be helpful to add uname output, because I didn't see what value it would add. I'm not looking for a simple incantation, I'm looking for guidance from more experienced peoople in the community.

@MK I'm unclear as to why I'd try those steps. My understanding of the true root of the issue is murky - but it seems to me that it's mainly an issue with a lack of space due to too many old kernels lying around. Can you explain why I should try what you've linked here?

You seem to understand the root of the issue quite well: When /boot runs out of space, installing new kernel image files to /boot fails. That failure causes apt to abort the entire remaining queue of package actions. The kernel install stays at the front of the apt queue, blocking most future apt actions also.

There are complicated ways to resolve, like flushing the apt queue, but it's usually easiest to simply use dpkg instead of apt: Simply pick a couple ancient kernels, and use dpkg to uninstall those kernel-image packages. That frees up enough space in /boot for apt to start working again. This method is essentially https://askubuntu.com/a/646560/19626

@JNotelddim I would have replied to you saying that you have 2 distinct issues; none of them is related to the other, although one of them could have caused the other: a broken apt, and lack of free space. Since your question was about the second, I answered rapidly not paying attention to apt errors.  But, since you are sure that a broken kernel-install is the root cause, it is no longer an egg-hen puzzle: just free your /boot like I told you in my solution, then try fixing your apt. I see no other way around it.

Do this as SuperUser
1- apt-get autoremove
2- Go to /boot and run these
rm *4.4.0-6*
rm *4.4.0-8*
rm *4.4.0-9*
rm *4.4.0-101*

3- run update-grub

While this will indeed free up space in /boot, it will also hopelessly break apt. This kind of solution should include instructions on how to fix apt afterward, else the user will wind up reinstalling anyway.

@user535733  I have been doing this for so long with apt working perfectly; no trouble! All flavors of Ubuntu.

@user535733 and I just did that same solution last week on my newly installed kubuntu 18.04; was doing it for 8 years on Ubuntu server, and 2 years on Gubuntu!

I agree with MK. Does Gubuntu mean Gnome Ubuntu?

@WinEunuuchs2Unix Yep!

Note although this frees up space on /boot it doesn't fix the existing broken dependencies.

@WinEunuuchs2Unix for the removed kernels, which are dead anyway, with their modules!

Actually the modules are stored elsewhere. Try locate /lib/modules/4.4.0-128 | wc -l and the result is 5579 files.

@WinEunuuchs2Unix I figure dependencies here are the ones update-grub complains about, and those are of removed kernels. Unless you mean something else?

@WinEunuuchs2Unix Oh my lame! I have just seen the extended output in the question. Sorry.

@MK so I take it I shouldn't try this? haha
