If apt-get isn’t functioning because your /boot is at 100%, you’ll need to clean out /boot first. This likely has caught a kernel upgrade in a partial install which means apt has pretty much froze up entirely and will keep telling you to run apt-get -f install even though that command keeps failing.
With a small boot partition and UnAttended upgrades on; a
Warning: only use this way of cleaning the boot partition when you tried to solve it first with apt-get itself: e.g.
Then delete unneeded kernels with:
replacing VERSION with the linux kernel versions you want to remove. If that yields an error like:
Then this solution is for you.
Get the list of kernel images and determine what you can do without. The next command will list all installed kernels .
Craft a command to delete all files in /boot for kernels that don’t matter to you using brace expansion to keep you sane. Remember to exclude the current and two newest kernel images. Example:
to clean up what’s making apt grumpy about a partial install:
If you run into an error that includes a line like “Internal Error: Could not find image (/boot/vmlinuz-3.13.0-68-generic)”, then run the command
(with your appropriate version).
Finally, sudo apt-get autoremove to clear out the old kernel image packages that have been orphaned by the manual boot clean.
to take care of any upgrades that may have backed up while waiting for you to discover the full /boot partition.
You can turn on autoremoval of unneeded software after you unattended
security updates by uncommentng an option in
/etc/apt/apt.conf.d/50unattended-upgrades: Look for this line:
// Do automatic removal of new unused dependencies after the upgrade // (equivalent to apt-get autoremove) Unattended-Upgrade::Remove-Unused-Dependencies "true";
Then apt-get autoremove is executed after each unattended upgrade.
Someone wrote a small python program that does this for you: https://github.com/EvanK/ubuntu-purge-kernels Use at your own risk.