Start Virtual Machine from command-line

Discussions related to using VirtualBox on Linux hosts.
Post Reply
GingerCup
Posts: 2
Joined: 9. Nov 2016, 14:42

Start Virtual Machine from command-line

Post by GingerCup »

Hi!
I am new to the Forum. I have the following configuration:

Host OS: Ubuntu 14.04.5 LTS
VirtualBox version: 4.3.36_Ubuntur105129 (output of vboxmanage --version)

I would like to start a Virtual Machine without using the GUI. For example, I would like to connect to the host system through ssh and be able to run a headless VM. I know that the command should be

Code: Select all

vboxmanage startvm <machinename> -type headless
If I try this, according to the text output the machine has successfully started. But if I try to ping the machine it doesn't respond; if I try with

Code: Select all

vboxmanage showvminfo "machinename" | grep -c "running (since"
the result is 0 (the machine is not running). Of course, if I load VirtualBox with the graphical interface and I start from that the VM, it correctly starts and I can verify it.
Did I use the wrong command? What can be the problem and how to debug it?
Thank you anyway,

Luke
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Start Virtual Machine from command-line

Post by socratis »

First and foremost, you're running the Ubuntu fork or VirtualBox, as evident by the "_Ubuntu" of the version. You should uninstall that one and install the one from https://www.virtualbox.org/wiki/Downloads
GingerCup wrote:
vboxmanage startvm <machinename> -type headless
This shouldn't even run, because there is no "vboxmanage" command, only "VBoxManage", unless you've setup an alias. Even in that case there are two dashes before the "type", not one. So the proper command should be:
  • VBoxManage startvm <machinename> --type headless
That's assuming that you've connected as the same user as the user that created the VM in the first place, or the VM that you see if you log on as that user. VMs are not meant to be shared.

The weird thing is that you didn't get a warning/error either because you mistyped the command, or because you don't have the right to start the VM.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
BelJoost
Posts: 37
Joined: 12. Nov 2016, 18:35

Re: Start Virtual Machine from command-line

Post by BelJoost »

Instead of:
GingerCup wrote:
vboxmanage startvm <machinename> -type headless
try:
VBoxHeadless --startvm <machinename> &
GingerCup
Posts: 2
Joined: 9. Nov 2016, 14:42

Re: Start Virtual Machine from command-line

Post by GingerCup »

socratis wrote:First and foremost, you're running the Ubuntu fork or VirtualBox, as evident by the "_Ubuntu" of the version. You should uninstall that one and install the one from https://www.virtualbox.org/wiki/Downloads
Yes, I am. But I hoped that, even if it is not an optimized and fully-updated version, this one would work anyway.
socratis wrote:here is no "vboxmanage" command, only "VBoxManage", unless you've setup an alias.
Oh, you're right!!
socratis wrote:The weird thing is that you didn't get a warning/error either because you mistyped the command, or because you don't have the right to start the VM.
Maybe the reason is the following:

Code: Select all

$ ls -l /usr/bin/vbox*
lrwxrwxrwx 1 root root 27 lug 12 09:13 /usr/bin/vboxballoonctrl -> ../share/virtualbox/VBox.sh
lrwxrwxrwx 1 root root 27 lug 12 09:13 /usr/bin/vboxheadless -> ../share/virtualbox/VBox.sh
lrwxrwxrwx 1 root root 26 lug 12 09:13 /usr/bin/vbox-img -> ../lib/virtualbox/vbox-img
lrwxrwxrwx 1 root root 27 lug 12 09:13 /usr/bin/vboxmanage -> ../share/virtualbox/VBox.sh
lrwxrwxrwx 1 root root 27 lug 12 09:13 /usr/bin/vboxsdl -> ../share/virtualbox/VBox.sh
lrwxrwxrwx 1 root root 27 lug 12 09:13 /usr/bin/vboxwebsrv -> ../share/virtualbox/VBox.sh
and

Code: Select all

$ ls -l /usr/bin/VBox*
lrwxrwxrwx 1 root root 27 lug 12 09:13 /usr/bin/VBoxBalloonCtrl -> ../share/virtualbox/VBox.sh
lrwxrwxrwx 1 root root 27 lug 12 09:13 /usr/bin/VBoxHeadless -> ../share/virtualbox/VBox.sh
lrwxrwxrwx 1 root root 27 lug 12 09:13 /usr/bin/VBoxManage -> ../share/virtualbox/VBox.sh
lrwxrwxrwx 1 root root 27 lug 12 09:13 /usr/bin/VBoxSDL -> ../share/virtualbox/VBox.sh
Symlinks make the commands actually case-insensitive. Anyway, my problem was not solved. As usefully suggested by BelJoost:
BelJoost wrote:Instead of:
GingerCup wrote:
vboxmanage startvm <machinename> -type headless
try:
VBoxHeadless --startvm <machinename> &
I got the following error:

Code: Select all

Oracle VM VirtualBox Headless Interface 4.3.36_Ubuntu
(C) 2008-2016 Oracle Corporation
All rights reserved.

VRDE server is listening on port 3389.
Error: failed to start machine. Error message: This VM was configured to use 3D acceleration. However, the 3D support of the host is not working properly and the VM cannot be started. To fix this problem, either fix the host 3D support (update the host graphics driver?) or disable 3D acceleration in the VM settings (VERR_NOT_AVAILABLE)
After disabling 3D acceleration, the machine started. This issue was signalled here: https://www.virtualbox.org/ticket/15005.
My question now is: is there a way to ignore, or to automatically disable the 3D acceleration when running headless? Or is the only way to disable it manually?
socratis wrote:That's assuming that you've connected as the same user as the user that created the VM in the first place, or the VM that you see if you log on as that user. VMs are not meant to be shared.
Yes, the user is the same.
Thank you for your help,

Luke
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Start Virtual Machine from command-line

Post by socratis »

GingerCup wrote:Yes, I am. But I hoped that, even if it is not an optimized and fully-updated version, this one would work anyway.
Yes, but neither you or I can tell if it could. It's not non-optimized, non-updated version of VirtualBox. It's modified. Heavily. Case in point; the aliases. They do not exist in the official version. Of course that's a minor thing, but I have no clue where it starts or where it ends.
GingerCup wrote:After disabling 3D acceleration, the machine started. This issue was signalled here: https://www.virtualbox.org/ticket/15005.
That is not the same issue. This was a VM in a saved state. Quite different.
GingerCup wrote:My question now is: is there a way to ignore, or to automatically disable the 3D acceleration when running headless? Or is the only way to disable it manually?
Well, there is no VM that is configured with 3D enabled. You have to specifically enable it. And it doesn't get re-enabled again, so as long as you disabled it, you should be all set.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
Post Reply