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

VirtualboxVagrant

Virtualbox Problem Overview


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.

Virtualbox Solutions


Solution 1 - Virtualbox

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.

Solution 2 - Virtualbox

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.

Solution 3 - Virtualbox

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.

Solution 4 - Virtualbox

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:

  1. suspend machine by VBoxManage controlvm <NAME_OR_UUID> savestate
  2. 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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionmattwiseView Question on Stackoverflow
Solution 1 - VirtualboxVictor RoetmanView Answer on Stackoverflow
Solution 2 - VirtualboxTerry WangView Answer on Stackoverflow
Solution 3 - VirtualboxDrCordView Answer on Stackoverflow
Solution 4 - Virtualboxchildno͡.deView Answer on Stackoverflow