How do I delete a virtualbox machine in the GURU_MEDITATION error state?

46,835

Solution 1

Kill the VBoxHeadless process and run "vagrant destroy"

Destroying vagrant and sending the kill signal with the "killall" command looks like:

killall -9 VBoxHeadless && vagrant destroy

Solution 2

If you can't power off the machine from VirtualBox GUI, then try from the command line using vboxmanage command (VBoxManage on OS X), e.g.:

vboxmanage controlvm NAMEOFVM poweroff

Change NAMEOFVM with the name from vboxmanage list vms command.

then unregister and delete the VM:

vboxmanage unregistervm NAMEOFVM --delete

Or delete it manually:

rm -fr ~/"VirtualBox VMs/NAMEOFVM"

Solution 3

I hit this problem. Eveything I read recommend that you should always manage the boxes via Virtual Box, not directly access files. But when I had an invalid box, the unregistervm command refused to delete it and vagrant destroy did not work. In the end the following process worked.

  1. Kill all running VBox* processes
  2. Delete the folder "boxname" from the folder "VirtualBox VMs"
  3. Edit the file "VirtualBox.xml" and remove the tag corresponding to the invalid box.

I then ran this command the verify the box was gone.

VBoxManage list vms

After that I was able to create a new vm with the same name.

Solution 4

I had a VM that got in a similar state

$ vagrant up

Bringing machine 'tempu' up with 'virtualbox' provider...
==> mms: Checking if box 'hashicorp/precise64' is up to date...
==> mms: Resuming suspended VM...
==> mms: Booting VM...
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["startvm", "9fcf2203-d4b3-47a1-a307-61bfa580bd28", "--type", "headless"]

Stderr: VBoxManage: error: The machine 'temp-ubuntu' is already locked by a session (or being locked or unlocked)
VBoxManage: error: Details: code VBOX_E_INVALID_OBJECT_STATE (0x80bb0007), component Machine, interface IMachine, callee nsISupports
VBoxManage: error: Context: "LaunchVMProcess(a->session, sessionType.raw(), env.raw(), progress.asOutParam())" at line 592 of file VBoxManageMisc.cpp

I looked for a process called VBoxHeadless, but it wasn't running.

I then ran ps and found this process with the same vm id:

$ ps aux | grep -i virtualbox
user      63466   0.0  0.1  2523608   8396   ??  S     9:36am   0:02.67 /Applications/VirtualBox.app/Contents/MacOS/VBoxManage showvminfo 9fcf2203-d4b3-47a1-a307-61bfa580bd28 --machinereadable

Killing that process fixed the problem and VM started correctly after running vagrant up

Solution 5

This is a script I use when I get desperate. It wipes as much trace of any VM from the machine as I can find:

VBoxManage list runningvms | awk '{print $2}'  | xargs --no-run-if-empty -t -n1 -IXXX VBoxManage controlvm XXX poweroff                                                           
VBoxManage list vms | awk '{print $2}'  | xargs --no-run-if-empty -t -n1 VBoxManage unregistervm                                                                                  
killall -9 VBoxHeadless                                                                                                                                                           
rm -rf ~/Virtualbox\ VMs/* 
Share:
46,835
Matthew Flaschen
Author by

Matthew Flaschen

Updated on October 23, 2020

Comments

  • Matthew Flaschen
    Matthew Flaschen over 3 years

    How do I delete a VirtualBox machine in the GURU_MEDITATION error state? Is it enough just to delete the directory while VirtualBox is not running?

    EDIT: After posting, I deleted the entire directory that "Show in File Manager" navigates to.

    It looks like:

    Screenshot of Virtualbox Guru Meditation

    Note that there is no power off, and even remove is greyed out. I believe this is the exact same as it looked even before I deleted the directory.

    EDIT 2: I tried the command line poweroff after deleting the files. It hangs:

    vboxmanage controlvm wmf-vagrant_1354733432 poweroff 0%...10%...20%...

    EDIT 3: It also fails to unregister it from the command-line:

    VBoxManage unregistervm wmf-vagrant_1354733432 --delete VBoxManage: error: Cannot unregister the machine 'wmf-vagrant_1354733432' while it is locked VBoxManage: error: Details: code VBOX_E_INVALID_OBJECT_STATE (0x80bb0007), component Machine, interface IMachine, callee nsISupports Context: "Unregister(fDelete ? (CleanupMode_T)CleanupMode_DetachAllReturnHardDisksOnly : (CleanupMode_T)CleanupMode_DetachAllReturnNone, ComSafeArrayAsOutParam(aMedia))" at line 160 of file VBoxManageMisc.cpp

  • steve cook
    steve cook over 10 years
    +1 Using the API or VBoxManage will often fail with lock exceptions etc. This is (unfortunately) the only 100% reliable way that I've found of terminating VBox VMs.
  • Andrew Miner
    Andrew Miner about 10 years
    If you're running multiple machines, you only need to kill the one process associated with the machine you wish to destroy.
  • andilabs
    andilabs about 10 years
    how to kill it? Which port is it running?
  • andilabs
    andilabs about 10 years
    To kill it on OS X: ps aux | grep -i virtualbox then kill -9 <PID> and after that run vagrant destroy
  • electblake
    electblake over 9 years
    on osx killall -9 VBoxHeadless then vagrant destroy worked nicely for me
  • roosevelt
    roosevelt about 9 years
    As @electblake pointed out. killall worked fine for me as well!
  • azbarcea
    azbarcea almost 8 years
    (+1) on linux you have also vboxmanage (lowercase) so, I use: vboxmanage unregistervm --delete <vm-name> (a little bit of cosmetics)
  • Quentin Merlin
    Quentin Merlin over 2 years
    you are the best