zjffdu
zjffdu

Reputation: 28824

VM in virtualbox is already locked for a session (or being unlocked)

My VM in virtualbox can not start due to this error, I don't want to destroy it and reinstall it again, anyway to recover it ?

There was an error while executing VBoxManage, a CLI used by Vagrant for controlling VirtualBox. The command and stderr is shown below.

Command: ["modifyvm", "319fcce3-e8ff-4b6f-a641-3aee1df6543f", "--natpf1", "delete", "ssh"]

Stderr: VBoxManage: error: The machine 'centos64_c6402_1454036461345_59755' is already locked for a session (or being unlocked)
VBoxManage: error: Details: code VBOX_E_INVALID_OBJECT_STATE (0x80bb0007), component MachineWrap, interface IMachine, callee nsISupports
VBoxManage: error: Context: "LockMachine(a->session, LockType_Write)" at line 493 of file VBoxManageModifyVM.cpp

Upvotes: 112

Views: 128566

Answers (13)

Gagan
Gagan

Reputation: 49

This is for Windows: The Multipass.run stores the reference Virtual Images (VDI) in the location: C:\ProgramData\Multipass\cahce\virtualbox\vault\images These files are used to create the VMs.

The most probable reason that you received an error was even though the Ubuntu core image was downloaded the VM was not created.

The VMs are kept in the location: C:\ProgramData\Multipass\data\virtualbox\vault\instances

Every VM has a folder under instance.

In order to see a list instances you can use:

  1. To get list of instannces: multipass list
  2. To get a list of images that you can create: multipass find
  3. To create a new instance: multipass launch [Image]

Once you create a new instance. You won't get that error.

Upvotes: 0

Md Asiful Haque
Md Asiful Haque

Reputation: 21

I ran into a similar issue with VirtualBox 7.0.12 and Windows 11. Every time I attempt to turn on the computer, "Result Code: E_FAIL (0X80004005)" appears. I was unsuccessful in my attempt to initiate headless **START from the GUI. But the command

VBoxHeadless --startvm <vm-uid>

Revealed more details, which ultimately revealed the underlying cause.

VBoxHeadless.exe ***Failed to open release log (could not open file 'F:\LAB\VD\KuberBaba\Kubernetes\kuberWorkerNode2\Logs\VBox.log' (fOpen=0x282), VERR_ALREADY_EXISTS)***

Created one backup of the log and file deleted the original one. 

Sucessful start in headless mode

Upvotes: 0

Obed Amoako
Obed Amoako

Reputation: 393

This is because You reallocated the memory set for Virtual Box
What you have to do to fix is: Restart The PC

Upvotes: 1

Erman
Erman

Reputation: 1603

I found this answer from @Gonzalez very interesting.

vboxmanage startvm <vm-uuid> --type emergencystop

The only problem with that it shut down the current instance of my VM, so instead of using modifyvm you can use controlvm if the current vm is running.

For example:

 VBoxManage modifyvm <vm_name> --natpf1 "guestssh,tcp,,22,,2222"
 VBoxManage modifyvm <vm_name> --natpf1 delete "guestssh"

Become:

VBoxManage controlvm <vm_name> natpf1 "guestssh,tcp,,22,,2222"
VBoxManage controlvm <vm_name> natpf1 delete "guestssh"

Full documentation Here https://www.virtualbox.org/manual/ch08.html#vboxmanage-controlvm

Upvotes: 17

zeeMonkeez
zeeMonkeez

Reputation: 5157

In my case, the apparent cause was a USB ethernet adapter that had been removed after suspending the machine. In my case,

vboxmanage startvm <vm-uuid> --type emergencystop

did not help. Instead, I received the confusing message that

VBoxManage: error: The machine 'xyzzy' is not locked by a session

The true error was revealed by running

vboxmanage startvm <vm-uuid> --type gui

which returned

VBoxManage: error: Nonexistent host networking interface, name 'en9: USBPlug' (VERR_INTERNAL_ERROR)

Changing the network configuration to a different network adapter solved the issue.

Upvotes: 0

Jana
Jana

Reputation: 5704

sudo pkill -9 VBox kills everything running related to vbox

Upvotes: 16

jreed350z
jreed350z

Reputation: 505

For me I had to kill the VboxHeadless.exe process in task manager. I also had to ensure CMD prompt was opened in Administrative mode.

Upvotes: 17

John Brandenburg
John Brandenburg

Reputation: 141

If you have a settings window open for that box in the VirtualBox GUI, you may run into this error. Just close the settings window and try again.

Upvotes: 4

Gonzalo Matheu
Gonzalo Matheu

Reputation: 10074

Running this on the command line unlocked the VM:

vboxmanage startvm <vm-uuid> --type emergencystop

Where <vm-uuid> is the number in the error message: Command: ["modifyvm", "<vm-uuid>" [...]. After that I was able to control the VM (start, halt, etc). Using Virtualbox 4.1 on Ubuntu.

Upvotes: 185

Charles Thomas
Charles Thomas

Reputation: 1005

The only option that worked for me was to kill all the processes matching ps axl|grep -i vbox.

Upvotes: 0

armyofda12mnkeys
armyofda12mnkeys

Reputation: 3442

In Windows Task Manager, I ended any tasks related to Virtual Box (you can see they start with a V in Task Manager like Vbox Headless.exe, etc). Once I did that, I was able to get this error to go away (the above 'vboxmanage startvm ...etc...' solutions here did not work for me).

Upvotes: 8

X.X
X.X

Reputation: 981

I've encounter the same error message today:

>me@myhost:~$ ps -ef | grep -i "vbox"

me  3064     1  0 08:51 ?        00:00:00 /usr/lib/virtualbox/VBoxXPCOMIPCD

me  3089     1  0 08:51 ?        00:00:00 /usr/lib/virtualbox/VBoxSVC --auto-shutdown

me  3126  3089 27 08:51 ?        00:00:39 /usr/lib/virtualbox/VBoxHeadless --comment RHEL5 64-bit desktop --startvm e5c598d8-1234-4003-a7c1-b9d8af15dfe7 --vrde config

me  3861  3415  0 08:53 pts/1    00:00:00 grep --color=auto -i vbox*

Gergely's answer solves it perfectly. It turned out that I've a crontab set at reboot to boot the virtual machine, which initiated the three VBox process shown above

me@myhost:~$ crontab -l

@reboot me /usr/bin/vboxmanage startvm "RHEL5 64-bit desktop" --type headless

Upvotes: 1

Gergely Toth
Gergely Toth

Reputation: 6977

Having the same issue I found that there was a process running actually locking the vm:

501 79419 79323   0  2:18PM ??         0:39.75 /Applications/VirtualBox.app/Contents/MacOS/VBoxHeadless --comment default --startvm 1d438a2e-68d7-4ba2-bef9-4ea162913c1b --vrde config

Make sure you don't have a process stuck trying to start the vm:

ps -ef | grep -i "vbox"

Upvotes: 39

Related Questions