66

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.

mattwise
  • 1,464
  • 1
  • 10
  • 20
  • 1
    Just open Virtual Box, click on the instance, and click the big Show green arrow icon. – Chloe Mar 29 '18 at 01:49

5 Answers5

47

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.

ankostis
  • 8,579
  • 3
  • 47
  • 61
Victor Roetman
  • 2,216
  • 2
  • 19
  • 14
7

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.

Terry Wang
  • 13,840
  • 3
  • 50
  • 43
  • I'm using Vagrant to manage a cluster for development/testing, and for the most part, a gui will just get in the way. Now and again I need a local web browser to test some http end points that should only be available internal. – mattwise Nov 27 '13 at 15:25
  • @mattwise If you only need to test if the page is accessible, you can do that from the shell with `curl`, `wget`, something similar. http://stackoverflow.com/a/2924444/873263 – Aaron Blenkush Nov 27 '13 at 18:55
  • 1
    @mattwise, you can access ports bound internal only with ssh port forwarding, for example `ssh -L8888:127.0.0.1:80 vagrant@127.0.0.1:2222`, changing the port numbers to what is appropriate for you, where 2222 is the ssh forward port to the vagrant machine, 8888 is the local port you point your web browser to, and 80 is the port only visible inside the virtual machine. – Victor Roetman Sep 05 '14 at 13:33
1

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.

DrCord
  • 3,917
  • 3
  • 34
  • 47
1

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

childno͡.de
  • 4,679
  • 4
  • 31
  • 57
0

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.

Huy
  • 104
  • 5