home Home library_books Notes style Projects photos Photos Table Of Contents Related Articles BetaFlight Micro Brushless Aurora 100 Converting a Soldering Station from 220v to 110v BlHeli CleanFlight ESC Calibration Falcon 120 The Ultimate Micro Quadcopter Guide Airbot F3S AIO Flight Controller and Typhoon 4-in-1 ESC Cleaning up the Ubuntu boot volume Nt 48

If you've been using an apt update && apt upgrade-ing a linux system for a while, at some you've probably seen this error:

Purging configuration files for linux-image-extra-3.13.0-96-generic (3.13.0-96.143) ...
(Reading database ... 520779 files and directories currently installed.)
Preparing to unpack .../linux-image-3.13.0-117-generic_3.13.0-117.164_amd64.deb ...
Done.
Unpacking linux-image-3.13.0-117-generic (3.13.0-117.164) ...
dpkg: error processing archive /var/cache/apt/archives/linux-image-3.13.0-117-generic_3.13.0-117.164_amd64.deb (--unpack):
 cannot copy extracted data for './boot/vmlinuz-3.13.0-117-generic' to '/boot/vmlinuz-3.13.0-117-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 3.13.0-117-generic /boot/vmlinuz-3.13.0-117-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 3.13.0-117-generic /boot/vmlinuz-3.13.0-117-generic
Errors were encountered while processing:
 /var/cache/apt/archives/linux-image-3.13.0-117-generic_3.13.0-117.164_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

That's right, the boot volume is full. What do we do?

We'll if you're also getting an unmet dependency error, like:

You might want to run 'apt-get -f install' to correct these.
The following packages have unmet dependencies:
 linux-generic : Depends: linux-headers-generic (= 3.13.0.117.127) but 3.13.0.96.104 is installed
 linux-image-extra-3.13.0-117-generic : Depends: linux-image-3.13.0-117-generic but it is not installed
 linux-image-extra-3.13.0-96-generic : Depends: linux-image-3.13.0-96-generic but it is not installed
 linux-image-generic : Depends: linux-image-3.13.0-117-generic but it is not installed
E: Unmet dependencies. Try using -f.

You'll need to delete some stuff off your boot volume before apt will run.

Start by figuring out what kernels you have installed (run all as sudo):

dpkg --list 'linux-image-[^e]*' | grep ^ii | awk '{print $2}' | sort | egrep "[0-9]-generic"; echo ""

Now find the range for all but the two most recent:

dpkg --list 'linux-image-[^e]*' | grep ^ii | awk '{print $2}' | sort | egrep "[0-9]-generic" | tail -n +3 |tr '\n' ' '; echo ""

And delete all but the two most recent kernels off your boot volume, where 60..93 is the range of kernel versions you have installed (except for the two most recent). This will free up the space we need on /boot to run apt.

rm -rf /boot/*-3.13.0-{60..93}-*

Then use apt to remove them:

apt remove -y $(dpkg --list 'linux-image-[^e]*' | grep ^ii | awk '{print $2}' | sort | egrep "[0-9]-generic" | tail -n +3 |tr '\n' ' '; echo "")

Finally, just in case you accidentally removed the current kernel in one of the above steps, make sure it's installed with:

apt install -y linux-image-$(uname -r)

Now you should be able to apt update && apt upgrade again!

Hope this was helpful. If so, feel free to checkout my YouTube channel, get updates when a new article is posted by following on Feedly and read the the other guides at nathan.vertile.com/blog