Vagrant: Unable to destroy orphaned vagrant boxes

Created on 12 Aug 2015  路  3Comments  路  Source: hashicorp/vagrant

Running this:

vagrant global-status | grep 'virtualbox running' | awk '{ print $1 }' | xargs vagrant destroy

fails to clean up orphaned boxes on this laptop.
Four months into this job, working with this client's laptop,
I seem to have accumulated a number of orphaned vagrant boxes
made visible by running global-status.

But repeated attempts seem unable to clean out the cruft.

How do I regain control of the machine and clean up after the
inadvertent power losses, etc.

I am in the habit these days of suspending, but usually destroying the running vagrant boxes
in each live shell when I put the host machine to sleep for the night. Even so global-status lists seven vagrant boxes with status 'running'. My theories of how the cruft accumulated relate to shells which died or were exited inadvertently. Or perhaps when I put the machine to sleep across a lunch break or a meeting. But I have not tested these theories.

Would it be safe to rm -rf ~/vagrant.d/data and trust that vagrant will rebuild what I need?
It appears that the data is derived from: ~/.vagrant.d/data/machine-index/index

-- Hugh Esco

Most helpful comment

HI @hesco

I am sorry you are having issues. As indicated in the global status docs, the status is a cache. You probably need to run vagrant global-status --prune. Does that help?

All 3 comments

HI @hesco

I am sorry you are having issues. As indicated in the global status docs, the status is a cache. You probably need to run vagrant global-status --prune. Does that help?

Nice tip. I have the same problem.

Hi there,

I am going to close this issue due to lack of response. As I said above, the global-status is a cache; it does not mean the machine still exists, just that it _once_ existed. You can use the --prune command to clear the cache.

Was this page helpful?
0 / 5 - 0 ratings