Every time a Vagrant
box fails to install, it leaves some mess behind in VirtualBox
. Forwarded ports that were set up in the Vagrantfile
do not get cleaned up. vagrant halt
does not work because the box is not up, and vagrant destroy
sometimes work, depending on how far the installation of a box went before hanging.
So every time I test a new setup, vagrant says that the port to be forwarded is already in use. I need to change the port to forward, and then the install continues, only to hang at a later point and take the port hostage into oblivion. Now I don't have any ports that I can use (that are accessible remotely), so I just want to quit having those ports constipated.
I could probably fix this with a reboot, but the machine cannot be rebooted right now.
Issuing the "just delete the damn thing" command does not work:
$ VBoxManage list vms
"<inaccessible>" {aaaa-aa-aa-aa-aaaa}
"<inaccessible>" {bbbb-bb-bb-bb-bbbb}
"vagrant_default_cccc_cc" {cccc-cc-cc-cc-cccc}
$ VBoxManage unregistervm aaaa-aa-aa-aa-aaaa –delete
VBoxManage: error: The object is not ready
VBoxManage: error: Details: code E_ACCESSDENIED (0x80070005), component Machine, interface IMachine, callee nsISupports
VBoxManage: error: Context: "Delete(ComSafeArrayAsInParam(aMedia), pProgress.asOutParam())" at line 165 of file VBoxManageMisc.cpp
$ VBoxManage unregistervm bbbb-bb-bb-bb-bbbb –delete
VBoxManage: error: The object is not ready
VBoxManage: error: Details: code E_ACCESSDENIED (0x80070005), component Machine, interface IMachine, callee nsISupports
VBoxManage: error: Context: "Delete(ComSafeArrayAsInParam(aMedia), pProgress.asOutParam())" at line 165 of file VBoxManageMisc.cpp
$ VBoxManage unregistervm cccc-cc-cc-cc-cccc –delete
VBoxManage: error: Cannot unregister the machine 'vagrant_default_cccc_cc' while it is locked
VBoxManage: error: Details: code VBOX_E_INVALID_OBJECT_STATE (0x80bb0007), component Machine, interface IMachine, callee nsISupports
VBoxManage: error: Context: "Unregister(fDelete ? (CleanupMode_T)CleanupMode_DetachAllReturnHardDisksOnly : (CleanupMode_T)CleanupMode_DetachAllReturnNone, ComSafeArrayAsOutParam(aMedia))" at line 160 of file VBoxManageMisc.cpp
$
(Nope, sudo
doesn't do the trick either.)
How can I totally eradicate and destroy the machines as easily as possible without having to reboot? Or, at least (or better) stop VirtualBox
from keeping port forwards to broken boxes? I probably should not remove and -rf
just everything because there are also some boxes that run fine.
The server running Vagrant and VirtualBox runs on Ubuntu 13.10
. The guest, although probably irrelevant, tries to run Ubuntu 12.10
.
Best Answer
The "startvm" ones are the processes that hang around and can't be stopped with normal vagrant commands. issue a
kill -TERM
command to the processes and they should stop If that doesn't work escalate to akill -KILL