Vagrantfile. Set memory and CPU
To set virtual machine memory size use:
config.vm.customize ["modifyvm", :id, "--memory", 2048]
To set virtual machine CPU's count use:
config.vm.customize ["modifyvm", :id, "--cpus", 2]
or to set half of available CPU's count:
config.vm.customize ["modifyvm", :id, "--cpus", `awk "/^processor/ {++n} END {print n}" /proc/cpuinfo 2> /dev/null || sh -c 'sysctl hw.logicalcpu 2> /dev/null || echo ": 2"' | awk \'{print \2ドル}\' `.chomp ]
Written by Andrew [8xx8] Kulakov
Related protips
7 Responses
Add your response
Add your response
This works on Mac & Linux:
config.vm.customize ["modifyvm", :id, "--cpus", `#{RbConfig::CONFIG['host_os'] =~ /darwin/ ? 'sysctl -n hw.ncpu' : 'nproc'}`.chomp]
over 1 year ago
·
what's wrong with the setting from vagrant documentation?
v.customize ["modifyvm", :id, "--cpuexecutioncap", "50"]
over 1 year ago
·
Like benjamine said, but a more complete example. This is valid for version 2 of Vagrantfile configuration:
config.vm.provider "virtualbox" do |vb|
vb.memory = "2048"
vb.cpus = "2"
end
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Memory
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#