Can I bring up the GUI for a Vagrant managed Virtual box while the box is running? - virtualbox

I know that I can configure my Vagrantfile to boot my machine with a GUI according to http://docs.vagrantup.com/v2/virtualbox/configuration.html with:
config.vm.provider "virtualbox" do |v|
v.gui = true
end
But if I've started a box headless, is there any way to bring up a GUI while the machine is running? Virtualbox provides the small preview, so I suspect it is possible but I haven't found any documentation on how to do this.
Edit: Terry pointed out that I can vagrant reload after changing the setting above to get a gui, but that reboots the box. I'm still hoping there's a easy way to enable the gui without a reboot.

There are 3 ways I've found to get a gui on a running headless machine if you can see it in the VirtualBox Manager:
You can suspend the machine (Close|Save State or vagrant suspend) and then start it again. When you restart it, you will see the GUI.
or, if you don't want to stop the machine at all:
You can go to display settings and enable the Remote Display Server while it's running (you may want to change the default port), and then use an RDP viewer (On Windows use Remote Desktop Connection) to access the GUI.
[Edit July 2015] With VirtualBox 5.0, click on the headless VM, choose "Show", and it will bring up the gui.

You'll have to do vagrant reload after enabling gui.
But there is a trick (a bit risky in my opinion)
1. save the state of the VM VBoxManage controlvm NAME_OR_UUID savestate
2. star vbox gui and resume
BTW: BTW: Why do you need GUI for Vagrant managed (headless) running VMs? If you prefer GUI to manage headless VMs, try phpVirtualBox.

From my experience with vagrant once you start completely headless there is no way to boot the GUI, you have to boot it on start with the line you mention above.

If it's running on VirtualBox (what vagrant typically uses) :
preface: you can't without (shortly) interrupting the VM! So you can't just open it for a running instance in VirtualBox.
You may find http://www.toptensoftware.com/VBoxHeadlessTray/ helpful, it has minor bugs if you ask me but nice to have to save what you can do ...
... On console: you might simply do what #terry-wang wrote:
suspend machine by VBoxManage controlvm <NAME_OR_UUID> savestate
restart with gui option VBoxManage startvm <NAME_OR_UUID> --type gui
alternative: start gui manager yourself as terry wrote
revert / make headless from gui: VBoxManage startvm <NAME_OR_UUID> --type headless
Update on VirtualBox 5: VirtualBox GUI has the function to start in Background nativly included now, so still the tool is a shortcut but not even more needed to not be forced using the console

I use:
VBoxManage startvm <NAME_OR_UUID> --type separate
The type separate is experimental according to the documents, but it seems to work in bringing up the GUI after the VM has already been started headless.

Related

cannot connect to X server error showed up in GCP

I create a python GUI by PyQt4, and now I'm trying to save this program into Google Cloud Platform(Compute engine) so that I can remotely execute it. But after I execute my python program, there's a problem showed up, the console showed the message :"cannot connect to X server". I also try to run with "xvfb-run python GUI.py", although it started to run but the graphical user interface didn't showed up, is there any suggestion? Thanks in advance!
In order to run a GUI application remotely on a Linux/Unix box, you need to have a X server running on your local machine and ready to accept a connection. Easiest way to do this is to SSH in and enable X11Forwarding either in your client config, your personal version of the client config, or on the command line (ie, the -X or -Y options).
Us Linux folks already have an X server, as do them BSD folks. Mac users can install it and it integrates quite nicely on OS X. Windows users need to either pay some $ and buy a license for a commercial product, or use cygwin-x.

Vagrant Box with Trellis/Bedrock

I recently set up a Trellis/Bedrock/Sage environment. I like it so far but have been running into the issue that if I step away from my computer, I can’t reconnect to my local production environment and have to start up my wordpress install from scratch. Is there a way to “save” a vagrant box so I can close my computer and not have to vagrant destroy, then vagrant up each time?
Thanks,
You could probably Save State directly in VirtualBox to accomplish what you want:
Also, I was able to find this comment to help answer your question here which also may do the trick:
In order to keep the same VM around and not loose its state, use the
vagrant suspend and vagrant resume commands. This will make your VM
survive a host machine reboot with its state intact.
https://serverfault.com/users/210885/

VMWare Workstation won't suspend from command line

I'm trying to automate VMWare Desktop on Windows 7 to suspend all vm's before I do a backup job each night. I used to have a script that did this but I've noticed now that it won't suspend anymore with the same command that used to work.
If I do vmrun list I get a list of the running vms with no issue.
If I do vmrun suspend "V:\Virtual Machines\RICHARD-DEV\RICHARD-DEV.vmx" it just hangs and I have to kill the command with CTRL+C.
I've even tried a newer command using -T to specify it's workstation, ie vmrun -T ws suspend "V:\Virtual Machines\RICHARD-DEV\RICHARD-DEV.vmx" and still no love.
If I have the vm already stopped, I can issue vmrun start "V:\Virtual Machines\RICHARD-DEV\RICHARD-DEV.vmx" and it starts fine.
As well as the suspend command, the stop command also does not work. I'm running VMWare Workstation 11.1.3 build-3206955 on Windows 7.
Any ideas?
Update:
I installed latest VMWare Tools on the guest, as well as the latest Vix on the Host so everything should be up to date.
I can start a vm using vmrun with no problem using vmrun -T ws start <path to vmx> but the command doesn't come back to the command prompt, so I'm assuming it's not getting confirmation from the vm that it is now running.
If I cancel the 'start' command and now try and suspend I'm getting the same lack of communication from the guest. If I manually suspend the vm, once it's suspended I get an 'Error: vm is not running' and the 'suspend' command finally times out and comes back.
So, it looks to me like there is no communication from vmrun to the guest about what state it's in etc. Is there a way to debug the communication from the host to the guest using vmrun or other means? Are there ports I need open in the guest OS?
So, I never did get vmrun to work properly on my main system, although I did get it behave ok on my laptop so there is something weird happening on this machine. I also installed a trial of the latest VMWare 12 and the same thing happens.
As a workaround, I ended up changing the power management settings in my guest OS so that it would 'sleep' after 1 hr of inactivity. When this happens VMWare detects it and automatically suspends the guest which is really what I'm looking for. Not the most slick solution but it does manage to unlock the files I need to be backed up in a nightly backup.

Virtualbox remote display updates remote as well as local screen

Folks,
I am running Virtualbox on Windows 7. The guest OS also is Windows 7.
I configured rdp connection at port 5000 (as stated in the documentation) and am able to connect to ip:5000 using Microsoft Remote Desktop client.
However, the problem is that the screen of the guest VM is simultaneously being shown on both, local as well as remote, windows.
Is there a way to just close the local window without shutting down the VM itself? Perhaps something similar to headless virtualbox on Linux.
Thank you in advance for your help.
Regards,
Peter
You can start a Virtualbox VM without GUI from the command line using:
VBoxHeadless --startvm [vmname]
There is also a section about running headless VMs in the Virtualbox manual: http://www.virtualbox.org/manual/ch07.html
Using the VBoxManage startvm command with the --type option is superior to VBoxHeadless as the former doesn't require the command prompt window to remain open (which largely defeats the purpose I think).
Below is and example of its output:
C:\>"C:\Program Files\Oracle\VirtualBox\VBoxManage" startvm "My Virtual Machine" --type headless
Waiting for VM "My Virtual Machine" to power on...
VM "My Virtual Machine" has been successfully started.
C:\>
Note that control is returned to the common prompt, allowing it to be closed without terminating the instance. The VM's status will also still be reported by the VirtualBox GUI.
The VBoxManage startvm command is documented in chapter 8 of the VirtualBox manual.

How to make a VM instance running sneakily as if it is a remote server?

Both host and vm are xubuntu 12.04.
I know that VBoxManage startvm "name" will start a VM from command line but the GUI will pop up anyway. Is there a way to start this vm and make it running sneakily at the background? Thus I can access it as if it is a server. Previously I let the GUI up and do my job via the console of the host.
Thanks
I think you're looking for VBoxManage startvm "VM name" --type headless