关于"定制"

时间:2014-04-16 08:26:34

标签: vagrant

我和Vagrant有一个奇怪的问题。更改虚拟机的默认RAM必须简单,但我不知道为什么我无法做到这一点。

我的代码非常简单:

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

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.define "mimeticStack" do |v|
    v.vm.box = "precise64"
    v.vm.box_url = "http://files.vagrantup.com/precise64.box"
    v.vm.network "private_network", ip: "192.168.33.10"
    v.vm.network "forwarded_port", guest: 80, host: 8080
    v.vm.hostname = "dev.mimetic.local"
    v.vm.customize ["modifyvm", :id, "--memory", "512"]
  end
end

然后,如果我跑了"流浪汉",Vagrant返回:

vm:
* The following settings shouldn't exist: customize

2 个答案:

答案 0 :(得分:22)

问题已解决:

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

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
    config.vm.define "mimeticStack" do |v|
        v.vm.box = "precise64"
        v.vm.box_url = "http://files.vagrantup.com/precise64.box"
        v.vm.network "private_network", ip: "192.168.33.10"
        v.vm.network "forwarded_port", guest: 80, host: 8080
        v.vm.hostname = "dev.mimetic.local"
        v.vm.provider :virtualbox do |vb|
            vb.customize ['modifyvm', :id,'--memory', '512']
        end
    end 
end

我把代码留给了像我一样的流浪汉初学者。

答案 1 :(得分:3)

我已经尝试了@ MikeD的建议

config.vm.provider "virtualbox" do |vb|
    vb.memory = "<some size>"
    vb.cpus = "<some number>"
end

它按预期工作。我可以直接进入我的流浪盒并运行lscpucat /proc/meminfo,它们会给我上面指定的值。