9

How do I install a Vagrant Linux box that has a Desktop GUI (gnome, kde, ...).

Is there a Vagrant box distribution that already has a Desktop environment?

After I do a "vagrant up" how do I log into this virtual box and with the GUI active?

Blorgbeard
  • 101,031
  • 48
  • 228
  • 272
Ken
  • 2,849
  • 8
  • 24
  • 23
  • I use the GUI on the host machine to work (edit and handle version control) on the guest VM through the share/sync drive. The VM runs the site/application. You can add vm.gui=true to use the VirtualBox GUI, or you can just vagrant ssh in. – user2182349 Aug 06 '15 at 01:47

2 Answers2

12

This question is a duplicate with an extensive answer here: Using vagrant to run virtual machines with desktop environment

Yes, you need to enable the GUI in your vagrant file, but first you need to:

  • Install Virtual Box Guest additions
  • Install your desktop environment

From one of the answer in the link above (https://stackoverflow.com/a/33138627/1412348), you can use the following vagrant file:

Vagrant.configure(2) do |config|
  # Ubuntu 15.10
  config.vm.box = "ubuntu/wily64"

  config.vm.provider "virtualbox" do |vb|
    # Display the VirtualBox GUI when booting the machine
    vb.gui = true
  end

  # Install xfce and virtualbox additions
  config.vm.provision "shell", inline: "sudo apt-get update"
  config.vm.provision "shell", inline: "sudo apt-get install -y xfce4 virtualbox-guest-dkms virtualbox-guest-utils virtualbox-guest-x11"
  # Permit anyone to start the GUI
  config.vm.provision "shell", inline: "sudo sed -i 's/allowed_users=.*$/allowed_users=anybody/' /etc/X11/Xwrapper.config"
end
Community
  • 1
  • 1
AntonyG
  • 861
  • 9
  • 22
  • This worked for me. To get desktop to start - login to virtualbox instance and type "startx" –  Nov 25 '17 at 06:54
  • when I tried this, I got a 404 error for wily64 An error occurred while downloading the remote file. The requested URL returned error: 404 Not Found when I tried to use this in its place config.vm.box = "ubuntu/xenial64" I got an x11 error. default: Running: inline script default: sed: can't read /etc/X11/Xwrapper.config: No such file or directory – openCivilisation Feb 19 '19 at 11:47
5

If you want to enter the Desktop GUI, you can modify the Vagrantfile to add vb.gui = true. For example:

config.vm.provider "virtualbox" do |vb|
    # Display the VirtualBox GUI when booting the machine
    vb.gui = true

    # Customize the amount of memory on the VM:
    # vb.memory = "1024"
end

Then you can vagrant up and enter it from virtualbox.

Alan W. Smith
  • 24,647
  • 4
  • 70
  • 96
haofly
  • 829
  • 12
  • 15
  • Please show me your full Vagrantfile that does this. If I am using ubuntu 64 bit then I do NOT have to add any GUI system files? That is, VirtualBox will be the GUI separate from the ubuntu? – Ken Aug 06 '15 at 15:19
  • 4
    e, I thought you just want to enter it through virtualbox, if you want it to show the desktop, the ubuntu must install the desktop using `sudo apt-get install ubuntu-desktop` – haofly Aug 07 '15 at 01:43