33

I have an Ubuntu Virtual machine that is configured to have VT-x enabled, 6 Processors, and 25 GB RAM.

Inside that virtual machine I am trying to start a vagrant machine with the following configuration:

master.vm.box = "precise32"
master.vm.provider "virtualbox" do |vb|
    vb.customize ["modifyvm", :id, "--cpuexecutioncap", "80"]
    vb.memory = 10000
    vb.customize ["modifyvm", :id, "--cpus", "2"]   
    vb.customize ["modifyvm", :id, "--ioapic", "on"]
end

When I start the Vagrant I get the error VT-x not enabled.

I tried both 32 bit and 64 bit versions of Vagrant but still no luck.

Any idea how can I run Vagrant machine inside the Virtualbox?

Nathan S.
  • 5,244
  • 3
  • 45
  • 55
user2230605
  • 2,390
  • 6
  • 27
  • 45

7 Answers7

55

You can only use one virtual CPU without VT-x. Thus, the error message stating that VT-x isn't enabled is caused by the following line:

vb.customize ["modifyvm", :id, "--cpus", "2"]

Replacing it with the following works (Vagrant has a shorthand for setting the CPU count):

vb.cpus = 1

NOTE: You can only run 32-bit VMs inside another VM.

Community
  • 1
  • 1
dabide
  • 996
  • 1
  • 6
  • 18
  • 1
    Good finding, can someone confirm if this works? I haven't tested this and don't intend to. Anyway, what is the point to run nested Vagrant + VirtualBox, more than double emulation overhead (performance loss) plus not 64-bit support. – Terry Wang Jul 16 '14 at 10:20
  • 1
    I'm using it right now, so it works. The point in my case is testing a setup where a physical Windows PC will run a Ubuntu VM. As I want the Windows PC, including the VM, to be configured using Puppet, running Vagrant is a practical way of doing it. To test this setup without using a physical box, I run Vagrant inside Vagrant. As you say, this doesn't seem like a good idea in production. – dabide Jul 16 '14 at 12:54
  • 5
    Just wanted to comment and say that this didn't work for me on virtualizing a CentOS 6 vagrant VM inside a Virtualbox CentOS 6 VM. I tried doing vb.cpus = 1 but had the same error persist. Switching to a 32bit VM works, but isn't ideal. – Lucas Feb 12 '15 at 22:17
  • 2
    Yes, you can only run 32-bit VMs inside another VM. Added a clarifying remark. – dabide Feb 13 '15 at 02:05
  • On a Proxmox system, I can build 64 Bit nested VMs using Virtualbox, the 32 Bit ones are not working – madduci Apr 23 '18 at 07:08
29

Vagrant in nested Virtual Box

First of all you can run definitely Vagrant inside a nested Virtual Box.

VT-X Support (related to VirtualBox)

Currently VirtualBox is not supporting nesting VT-X. There is currently a feature request pending(see.: https://www.virtualbox.org/ticket/4032) but as of now it is not expected to be in a new version of VirtualBox

Consequences from missing VT-X in nested VirtualBox

There are currently two consequences from nesting without VT-X:

  1. You cannot use multiple CPUs but you can use a single virtual cpu using vb.cpus = 1
  2. You cannot run a 64-Bit VM within a nested VirtualBox.
fyr
  • 20,227
  • 7
  • 37
  • 53
  • 1
    This is the right answer. Setting vb.cpus = 1 works without VT-x, and the limitation that remains is that a 64-bit OS won't work. Tested and confirmed. – zedix Jan 02 '15 at 19:26
  • Everyone who wants to see this functionality, please add your +1 to the support ticket https://www.virtualbox.org/ticket/4032 – Chris Snow Jul 10 '15 at 17:41
  • 1
    I have managed to run the vagrant inside virtualbox but I cant ssh to vagrant machine, do you know how to setup networking I get No route to host – v0d1ch Jul 21 '15 at 11:17
  • 3
    you can run a 64-Bit VM within a nested **VMWare Player**. – Rudolf Manusachi Oct 16 '15 at 10:28
19

UPDATED: As pointed out below, you can use nested VirtualBox + vagrant provided that only 1 virtual CPU is assigned to the nested VM, plus nested VM guest is 32-bit OS.

Terry Wang
  • 13,840
  • 3
  • 50
  • 43
  • 21
    You can run Vagrant + Virtualbox within a VirtualBox VM. The error message stating that VT-x isn't enabled is caused by the line ```vb.customize ["modifyvm", :id, "--cpus", "2"]``` You can only use one virtual CPU inside a nested VM. Replacing the aforementioned line with the following works: ```vb.cpus = 1``` – dabide Jul 16 '14 at 09:03
0

You can not use the first VM as Virtual Box one. That's sure. But what you can do is, make the first VM ( Ubuntu) based on VMware Player 7, then you can set up Vagrant on that. Tested and confirmed on my own. VMplayer version 7 and Virtual Box version 5.0.20. Thanks to the comment from Rudolf in the same page

Ashishkel
  • 953
  • 11
  • 20
  • Thanks. That solved the problem for me while evaluating various orchestration products. Nothing I want to use in production though. – Arthur Jul 21 '16 at 12:09
0

If you run vagrant + VirtualBox within a VirtualBox virtual machine and you face networking problems :

Don't forget to set the right virtual network adapter

I had to set the Adapter type to Paravirtualized Network (virtio-net)

in Settings -> Network -> Advanced to make it work

HenriTel
  • 184
  • 10
0

VirtualBox inside VirtualBox wont work. Try VMPlayer and then inside install VirtualBox and vagrant. Its works for me.

Bala
  • 913
  • 9
  • 18
0

If you're using packer and running into this error please make sure you have enough CPU's to actually stand up the image.

I had stated to build the image with two CPUs but was only running a 2 core VM myself. Changed it down to 1 cpu and build ran without any errors.