How to start virtualmachine from terminal?
16,987
Here is a way to start a virtual machine from terminal :
Open Virtual Box, right-click on the virtual machine. Then click on Create shortcut on desktop.
Go to the desktop, right-click on the shortcut and edit it.
Then copy the command and paste it into the terminal.
/usr/lib/virtualbox/VirtualBox --comment "Ubuntu" --startvm "cea829eb-85fe-4842-b98e-e98603094be0"
or you can start in terminal like this.
Get your UUID of VM
cd "VirtualBox VMs"
cd your-virtualpc-name
cat your-virtualpc-name.vbox-prev |grep Machine
output should look like this.
neil@ASUS:~/VirtualBox VMs/Ubuntu$ cat Ubuntu.vbox-prev |grep Machine
<Machine uuid="{cea829eb-85fe-4842-b98e-e98603094be0}" name="Ubuntu" OSType="Ubuntu" snapshotFolder="Snapshots" lastStateChange="2015-11-22T08:47:08Z">
<ExtraDataItem name="GUI/RestrictedRuntimeMachineMenuActions" value="SaveState,PowerOff"/>
</Machine>
neil@ASUS:~/VirtualBox VMs/Ubuntu$
Copy the Machine uuid
and run it in the command like so. With the quote marks
VBoxHeadless --startvm "cea829eb-85fe-4842-b98e-e98603094be0"
Related videos on Youtube
Author by
emrecnl
Updated on September 18, 2022Comments
-
emrecnl over 1 year
I can not run a Virtualbox Machine from command line what do I exactly need? I did a bit research first but this command did not work for me:
vboxmanage startvm win7 --type headless
Result is:
VBoxManage: error: Could not find a registered machine named 'win7' VBoxManage: error: Details: code VBOX_E_OBJECT_NOT_FOUND (0x80bb0001), component VirtualBox, interface IVirtualBox, callee nsISupports VBoxManage: error: Context: "FindMachine(Bstr(pszVM).raw(), machine.asOutParam())" at line 575 of file VBoxManageMisc.cpp
- "win7" is the VM I'm trying to run.
- I can run this VM via phpVirtualBox addon perfectly fine.
- After launching this vm via phpVirtualBox I can perfectly RDM from Linux or Windows.
- I'm running this VM on Ubuntu Server 14.04.03 amd64 headless installation.
- Virtualbox version is: 4.3.34r104062
- I don't know how to register this VM from terminal as its files located in a USB hdd using the NTFS partition.
My aim was to run this vm on system boot, preferably a bit delayed.
I'm ready to provide any other information needed.
-
Arronical over 8 yearsI think switching between phpVirtualBox and the virtualbox command line is probably causing the issue, though I'm not sure how. I'll delete my answer as I don't think it's helpful in this case. Sorry not to be of more help, good luck!
-
Javier Rivera over 8 yearsVirtual Machines are defined by user. Could it be that phpVirtualBox is running as a different user and the win7 machine is registered only to that user?.
-
emrecnl over 8 years@Javier Rivera probably this is the issue. It's using
vbuser
which isn't my own account. However, shouldn't it be worked with sudo command? -
Javier Rivera over 8 yearsYes, it should work with sudo.
-
emrecnl over 8 yearsAs I stated in my question, there's no GUI to perform these actions. For the terminal part:
/usr/lib/virtualbox/VirtualBox --comment "win7" --startvm "43c6cdfe-5175-4a16-80f3-7699234dac6b" Failed to open the X11 display!
-
Neil over 8 years@emrecnl then you want to do something like this
VBoxHeadless --startvm "43c6cdfe-5175-4a16-80f3-7699234dac6b" --vrdp=off
-
emrecnl over 8 years
Oracle VM VirtualBox Headless Interface 4.3.34 (C) 2008-2015 Oracle Corporation All rights reserved. Invalid machine name or UUID!
This is ridiculous. -
Neil over 8 years@emrecnl you got to have the virtual machine UUID or it won't work.
-
emrecnl over 8 yearsI'm using correct UUID.
-
Neil over 8 years@emrecnl made a edit. give that a try
-
emrecnl over 8 yearsI tried many other VMs none of them launching by CLI but they can with phpVirtualBox. This is the guide I followed to install VB probably my setup is missing something. liberiangeek.net/2014/09/…