How can I create a VM in Vagrant with VirtualBox with two CPUs?

nikhil picture nikhil · Jun 14, 2013 · Viewed 47k times · Source

On Windows 7 64 bit trying to start up a VM (Ubuntu 32 bit). I'm having trouble getting my VM to show two cores despite adding the modify vm command in my Vagrantfile. My Vagrant version is 1.2.2.

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "precise32"
  config.vm.box_url = "http://files.vagrantup.com/precise32.box"

  config.vm.provider :virtualbox do |vb|
    vb.customize ["modifyvm", :id, "--memory", "2048"]
    vb.customize ["modifyvm", :id, "--cpus", "2"]   
  end  
end

With this Vagrantfile I issue the vagrant up command. Then I issue vagrant ssh followed by lscpu which yields:

Architecture:          i686
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                1
On-line CPU(s) list:   0
Thread(s) per core:    1
Core(s) per socket:    1
Socket(s):             1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 58
Stepping:              9
CPU MHz:               2565.513
BogoMIPS:              5131.02
L1d cache:             32K
L1d cache:             32K
L2d cache:             6144K

I think CPU(s) should show 2, so my VM only has one CPU right now. How can I get 2 CPUs to show up when I run lscpu?

Answer

nikhil picture nikhil · Jun 15, 2013

Add vb.customize ["modifyvm", :id, "--ioapic", "on"] to the config.vm.provider block inside your Vagrantfile.

Looking at the VirtualBox documentation it mentions:

"Note Enabling the I/O APIC is required for 64-bit guest operating systems, especially Windows Vista; it is also required if you want to use more than one virtual CPU in a virtual machine."