46

I realize this is essentially OSCeption (Operating System Inception), but I think it might make the most sense for me (please tell me if there's a better option, this seems really awful).

Here's the situation: I have a windows 8 machine. I like it - it works great for everything but development. For development, I've been using a VMWare virtual machine running Ubuntu. I've dabbled with using Cygwin, but it just didn't feel right.

I'm now joining a project where they've been using Vagrant to manage development environments so I need to be able to use Vagrant. But, from what I've seen, Vagrant is mainly used to run code within a consistent environment, but not necessarily to write it. And if I wanted to write code by SSH'ing into my vagrant boxes, then I would have to re-configure my preferences like my .vimrc file and what not for every machine.

Does it then make sense to install Vagrant within my Ubuntu VirtualMachine? I feel like at some point VMs within VMs will get out of hand and cause problems. Is there any better way to do this?

Edit: So I tried it out - as I expected I hit some errors. When I try and boot the machine, I get the following error message:

Failed to open a session for the virtual machine vagranttest_1371583212.

VT-x is not available. (VERR_VMX_NO_VMX).

Result Code: NS_ERROR_FAILURE (0x80004005)
Component: Console
Interface: IConsole {db7ab4ca-2a3f-4183-9243-c1208da92392}

Looks like my vmware virtual machine can't run another virtual machine. Any ideas on the best way to go about doing this?

4

4 回答 4

55

我今天遇到了同样的问题。解决方案非常简单。

  1. 关闭vmware虚拟机。
  2. 转到“编辑虚拟机设置”
  3. 转到处理器。那里有三个复选框。
  4. 选中第二个复选框(启用 VT-x/AMD-V)
  5. 开机。

在这个 virtualbox 应该在 vmware 中工作之后。

于 2014-04-08T08:45:45.490 回答
4

为了回答原始问题以及@blong 的 Vagrant 论坛帖子,这就是我为完成这项工作所做的工作。

我正在尝试自己做类似的事情(实际上是 Vagrant/VMware 托管 Vagrant/Vbox),并且我已经执行了我能想到的所有优化,为我的“主机”VM 提供大量 RAM(24GB)和 6 个内核,禁用交换通过设置“将所有 VM 内存放入保留的主机内存”并允许每个 VM 页面文件(否则它们位于系统页面文件中,这限制了您可以运行的 VM 数量),将 VM 写入磁盘(这会在 Windows 上杀死事情)一次)。

我所做的工作一直很完美,我遇到的网络问题是由于我落后的公司代理造成的。一旦我配置了我的虚拟机可以访问互联网并且世界上一切正常。

除了在我的示例(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 中,您应该拥有与我一直在使用的系统等效的工作系统。

于 2015-06-17T15:51:47.233 回答
2

如果您在 vsphere 中的 VM 中运行 virualbox,则必须通过 ssh 连接到 ESXi 以更新配置。

脚步:

  1. SSH 到 ESXi 服务器。
  2. 找到属于你的虚拟机的 vmx 文件find / -name *.vmx
  3. 关闭您的虚拟机。(非常重要,否则您的更改将被覆盖)
  4. 编辑该 vmx,在文件底部附加一个新配置:vhv.enable = "TRUE"
  5. 打开你的虚拟机
  6. 享受流浪者。:)
于 2015-12-11T05:17:26.533 回答
1

我已经在两个 VMware 产品中尝试过这个。右键单击虚拟机:

  • 在硬件选项卡上的 vCloud Director 5.5 虚拟机属性中,有一个“向来宾操作系统公开硬件辅助 CPU 虚拟化”复选框,但它对我来说是灰色的。YMMV。
  • 在 vSphere 版本 5.5.0 编辑设置 > 虚拟硬件 > CPU 中,该复选框称为“向来宾操作系统公开硬件辅助虚拟化”,这对我有用。
于 2016-11-04T21:35:01.590 回答