apt-get fails, and terminates with a partially installed package. You’ll know that has happened when you get a message like this when you run an apt command:E: Unmet dependencies. Try using -f.
apt command.There’s lots of advice out there about what to do, but the pages I’ve found always seem to leave something out, or assume knowledge of
apt or dpkg that I don’t have.So based on the last time this happened, here’s how I plan to recover the next time I run out of space. Warning: lots of Terminal commands coming up. I do everything in the Terminal for a few reasons:
- The happens to me most often with servers, as I’m trying to save space, especially for virtual machines. My servers don’t have a GUI
- Terminal works for both desktop and server machines
- It’s easier to document commands for the Terminal
$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       3.7G  3.7G     0 100% /
...
$ uname -a
Linux ixmucane 3.13.0-24-generic #47-Ubuntu SMP Fri May 2 23:30:00 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
$ dpkg --list | grep linux-image
$  sudo dpkg --purge linux-headers-n.nn.n-nn-generic 
$  sudo dpkg --purge linux-headers-n.nn.n-nn
$  sudo dpkg --purge linux-image-extra-n.nn.n-nn-generic 
$  sudo dpkg --purge linux-image-n.nn.n-nn-generic 
df -h. Then run:$ sudo apt-get -f install
df -h, then I go ahead and finish the install. To be safe, I also do:$ sudo apt-get update
dpkg until I have enough space to finish the install.The above is the happy path. If I didn’t have two versions older than the current running kernel, I would try to remove the partially installed packages. Looking again at the output of:
$ dpkg --list | grep linux-image
dpkg commands to remove the partially installed packages. Some of them won’t work, of course, since the package isn’t installed, But once all the installed packages are removed, presumably there would more space and I could try:$ sudo apt-get -f install