Advertisement
Guest User

Untitled

a guest
Nov 28th, 2015
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. config.vm.provider "virtualbox" do |v|
  2. host = RbConfig::CONFIG['host_os']
  3.  
  4. # Give VM 1/4 system memory & access to all cpu cores on the host
  5. if host =~ /darwin/
  6. cpus = `sysctl -n hw.ncpu`.to_i
  7. # sysctl returns Bytes and we need to convert to MB
  8. mem = `sysctl -n hw.memsize`.to_i / 1024 / 1024 / 4
  9. elsif host =~ /linux/
  10. cpus = `nproc`.to_i
  11. # meminfo shows KB and we need to convert to MB
  12. mem = `grep 'MemTotal' /proc/meminfo | sed -e 's/MemTotal://' -e 's/ kB//'`.to_i / 1024 / 4
  13. else # sorry Windows folks, I can't help you
  14. cpus = 2
  15. mem = 1024
  16. end
  17.  
  18. v.customize ["modifyvm", :id, "--memory", mem]
  19. v.customize ["modifyvm", :id, "--cpus", cpus]
  20. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement