Skip to content

Instantly share code, notes, and snippets.

@duggan
Forked from wizardishungry/Gemfile
Last active December 18, 2015 11:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save duggan/5773356 to your computer and use it in GitHub Desktop.
Save duggan/5773356 to your computer and use it in GitHub Desktop.
Vagrant (v1.1+) snippet to set VirtualBox guest CPU count to the number of host cores on Linux or OS X
# -*- mode: ruby -*-
# vi: set ft=ruby :
if not RUBY_PLATFORM.downcase.include?("mswin")
config.vm.provider "virtualbox" do |v|
v.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}\' | cut -d' ' -f2 `.chomp ]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment