0

My virtualbox VM (Ubuntu 16.04) is running out of disk space. Found there are old kernels. I've reached a standstill, because I cannot delete them due to unmet dependencies. Even if I try to --ignore-missing, it still errors out.

My current kernel is 4.4.0-193-generic.

All the other kernels are:

linux-headers-4.4.0-169
linux-headers-4.4.0-169-generic
linux-headers-4.4.0-170
linux-headers-4.4.0-170-generic
linux-headers-4.4.0-171
linux-headers-4.4.0-171-generic
linux-headers-4.4.0-173
linux-headers-4.4.0-173-generic
linux-headers-4.4.0-174
linux-headers-4.4.0-174-generic
linux-headers-4.4.0-176
linux-headers-4.4.0-176-generic
linux-headers-4.4.0-177
linux-headers-4.4.0-177-generic
linux-headers-4.4.0-178
linux-headers-4.4.0-178-generic
linux-headers-4.4.0-179
linux-headers-4.4.0-179-generic
linux-headers-4.4.0-184
linux-headers-4.4.0-184-generic
linux-headers-4.4.0-185
linux-headers-4.4.0-185-generic
linux-headers-4.4.0-186
linux-headers-4.4.0-186-generic
linux-headers-4.4.0-187
linux-headers-4.4.0-187-generic
linux-headers-4.4.0-189
linux-headers-4.4.0-189-generic
linux-headers-4.4.0-190
linux-headers-4.4.0-190-generic
linux-headers-4.4.0-31
linux-headers-4.4.0-31-generic
linux-image-4.4.0-169-generic
linux-image-4.4.0-170-generic
linux-image-4.4.0-171-generic
linux-image-4.4.0-173-generic
linux-image-4.4.0-174-generic
linux-image-4.4.0-176-generic
linux-image-4.4.0-177-generic
linux-image-4.4.0-178-generic
linux-image-4.4.0-179-generic
linux-image-4.4.0-184-generic
linux-image-4.4.0-185-generic
linux-image-4.4.0-186-generic
linux-image-4.4.0-187-generic
linux-image-4.4.0-189-generic
linux-image-4.4.0-190-generic
linux-image-4.4.0-31-generic

Here is what happens when I try to remove them:

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 apt -y --ignore-missing 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-headers-generic : Depends: linux-headers-4.4.0-194-generic but it is not going to be installed
 linux-image-extra-4.4.0-31-generic : Depends: linux-image-4.4.0-31-generic but it is not going to be installed
 linux-image-generic : Depends: linux-modules-extra-4.4.0-194-generic but it is not going to be installed
                       Recommends: thermald but it is not going to be installed

I don't have enough space to install linux-headers-4.4.0-194-generic. How can I remove these???

6
  • 1
    Don't use wildcards. Simply choose one installed (but unused) set of kernel packages that has no problems. Uninstall those. Now you have space. Rinse and repeat. Next, fix the reason that old kernels are accumulating.
    – user535733
    Jan 8 at 21:10
  • I cannot uninstall, install, or anything at all. I get the same error no matter what I do. Jan 8 at 21:12
  • 1
    Use dpkg instead of apt to remove the single set of packages. Your output seems to show a version conflict, not an out-of-space error. Your question should explain your troubleshooting process a bit more clearly.
    – user535733
    Jan 8 at 21:16
  • Using dpkg instead of apt worked. Just gotta get that unmet dependency fixed. Thanks for that suggestion. Jan 8 at 21:30
  • 1
    I would suggest detailing exactly what you did as an answer to your own question, while it's fresh in your mind (and your shell history).
    – user535733
    Jan 8 at 21:52
0

Alright, using apt was not working when trying to remove old kernels. I had to use dpkg instead, like so:

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 dpkg --remove

I attempted to run apt autoremove, however, I got the same unmet dependencies message. So I ran apt -f install, and then apt autoremove again, this time successfully.

Now I can install/uninstall packages just fine, and I gave myself a lot more disk space in the process.

2
  • It's also pretty trivial to add more disk space with VBox - assuming there's space left on the host OS. First, you make the virtual disk image larger in the media section of VBox. Then, you start the VM but you press F12, select a live .iso of your choosing, boot to that image and then grow the disk (with gparted) to use the now-larger disk. It's fairly straightforward.
    – KGIII
    Jan 9 at 0:47
  • My concern at the moment was to fix the initial problem of not being able to install anything (which was htop). I did not need all of those kernels. I don't require much space, because it's just a little NTP server. I have no intention of increasing the disk size. But I will take note of your suggestion if I ever need to. Thanks. Jan 9 at 20:46

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.