为了回答最初的问题以及@blong 的 Vagrant 论坛帖子,这就是我为完成这项工作所做的工作。
我自己也在尝试做类似的事情(实际上是 Vagrant/VMware 托管 Vagrant/Vbox),并且我已经执行了我能想到的所有优化,为我的“主机”VM 提供大量 RAM(24GB)和 6 个内核,通过设置“将所有 VM 内存放入保留的主机内存”,并允许每个 VM 页面文件(否则它们存在于系统页面文件中,这限制了您的虚拟机数量可以立即运行)。
我所做的工作一直很完美,我遇到的网络问题是由于我落后的公司代理。一旦我配置了我的虚拟机可以访问互联网并且一切正常。
除了在我的示例(Virtualbox)Vagrantfile 中已经设置的 natdnsproxy1 和 naddnshostresolver1 之外,我还必须通过 Vagrantfile 手动设置 --natbindip1 和 --natnet1。这些设置可以在 Virtualbox 文档中找到,以便正确使用。
总结一下,在你的 VM CPU 设置中使用 VT-x passthrough/“virtualize”选项,给 VM 足够的内存,不要让内存在“root”主机上被交换,然后尝试确保您的网络范围不重叠,否则您将遇到路由问题。
这是我使用的 Vagrantfile,它几乎完全基于 andreptb 的modern.ie vagrant 设置要点。 https://gist.github.com/andreptb/57e388df5e881937e62a
# -*- mode: ruby -*-
# vi: set ft=ruby :
# box name into env var, same script can be used with different boxes. Defaults to win7-ie11.
box_name = box_name = ENV['box_name'] != nil ? ENV['box_name'].strip : 'win7-ie11'
# box repo into env var, so private repos/cache can be used. Defaults to http://aka.ms
box_repo = ENV['box_repo'] != nil ? ENV['box_repo'].strip : 'http://aka.ms'
Vagrant.configure("2") do |config|
# If the box is win7-ie11, the convention for the box name is modern.ie/win7-ie11
config.vm.box = "modern.ie/" + box_name
# If the box is win7-ie11, the convention for the box url is http://aka.ms/vagrant-win7-ie11
config.vm.box_url = box_repo + "/vagrant-" + box_name
# big timeout since windows boot is very slow
config.vm.boot_timeout = 500
# rdp forward
config.vm.network "forwarded_port", guest: 3389, host: 3389, id: "rdp", auto_correct: true
# winrm config, uses modern.ie default user/password. If other credentials are used must be changed here
config.vm.communicator = "winrm"
config.winrm.username = "IEUser"
config.winrm.password = "Passw0rd!"
config.vm.provider "virtualbox" do |vb|
# first setup requires gui to be enabled so scripts can be executed in virtualbox guest screen
#vb.gui = true
vb.customize ["modifyvm", :id, "--memory", "1024"]
vb.customize ["modifyvm", :id, "--vram", "128"]
vb.customize ["modifyvm", :id, "--cpus", "2"]
vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
vb.customize ["guestproperty", "set", :id, "/VirtualBox/GuestAdd/VBoxService/--timesync-set-threshold", 10000]
end
end
我的其他更改:
# Need the WinRM gem for managing from Linux
$ sudo gem install winrm
config.vm.communicator = "winrm"
+ config.winrm.host = "localhost"
config.winrm.username = "IEUser"
config.winrm.password = "Passw0rd!"
# This one may not be necessary, I added it for completeness
+ config.vm.guest = :windows
# In order to USE the two CPUs you need the ioapic
# Virtualbox gives an error in the GUI and only shows 1 CPU in the VM otherwise
vb.customize ["modifyvm", :id, "--cpus", "2"]
+ vb.customize ["modifyvm", :id, "--ioapic", "on"]
# We had to modify the network range because we are running Virtualbox inside VMware
+ vb.customize ["modifyvm", :id, "--natnet1", "192.168.199.0/24"]
删除 + 符号并将这些行添加到上面的 Vagrantfile 中,您应该有一个与我一直在使用的系统等效的工作系统。