Vagrant 在 Ubuntu 上的 VirtualBox 上
Vagrant on VirtualBox on Ubuntu
我需要构建 Vagrantfile。我需要使用 Ansible(所以,我无法使用 Windows)。
但我的主要 OS - Windows 10. 我可以在 Hyper-V 或 VirtualBox 上安装 Ubuntu。
1) 我创建了 Hyper-V 机器并在其上安装了 Ubuntu。但是 vagrantfile 不能使用 hyper-v 作为提供者并且需要 virtualbox。
2) 如果我尝试在 VirtualBox 上启动虚拟 Ubuntu,我会遇到错误
Failed to open a session for the virtual machine Ubuntu.
AMD-V is not available (VERR_SVM_NO_SVM).
Result Code: E_FAIL (0x80004005)
Component: ConsoleWrap
Interface: IConsole {872da645-4a9b-1727-bee2-5585105b9eed}
2) 如果我在 Windows 上关闭 Hyper-V,我可以在 VirtualBox 上启动 Ubuntu。
但是当我尝试 vagrant up
时,出现错误:
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.
Command: ["startvm", "4e3f95fd-2ad3-423f-a39a-ffd65cfe0d46", "--type",
"headless"]
Stderr: VBoxManage: error: AMD-V is not available (VERR_SVM_NO_SVM)
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component
ConsoleWrap, interface IConsole
在 VirtualBox 设置中 AMD-V/VT-x 已启用 screenshot
是否有机会在虚拟 Ubuntu 上与 vagrant 合作?把真正的主系统从 Windows 改成 Ubuntu.
真是太不可取了
感谢您的帮助!
更新。我可以添加我的 virtualbox 和 BIOS 截图,也许会有用。
虚拟盒子:
这是我的机器Ubuntu:
AMD-V 已启用:
BIOS:
https://s8.hostingkartinok.com/uploads/images/2017/07/4fe67600624d20d8194edc3d9224db69.jpg
https://s8.hostingkartinok.com/uploads/images/2017/07/6f05e15236404042ff929ad10280a1d1.jpg
https://s8.hostingkartinok.com/uploads/images/2017/07/23e417ab2fb13191780417030960cb82.jpg
https://s8.hostingkartinok.com/uploads/images/2017/07/fbcd47ad170ece6127592a6ca8d7dad5.jpg
https://s8.hostingkartinok.com/uploads/images/2017/07/65de25614774edc4f19506c8c10c61fe.jpg
https://s8.hostingkartinok.com/uploads/images/2017/07/ca73abc19ee7d82398f0574cf77789b4.jpg
https://s8.hostingkartinok.com/uploads/images/2017/07/8a15b5e490b285c41268cd4f6b0930c3.jpg
https://s8.hostingkartinok.com/uploads/images/2017/07/9c52e945ad8efc009b772b3e88f5672e.jpg
https://s8.hostingkartinok.com/uploads/images/2017/07/3357dd1540a2ea57e308a59ae41cf0af.jpg
https://s8.hostingkartinok.com/uploads/images/2017/07/311e96617a120ec3f22f4fe6833d3dc1.jpg
https://s8.hostingkartinok.com/uploads/images/2017/07/4963e3b283d1209e4e88a6b14d133dcd.jpg
https://s8.hostingkartinok.com/uploads/images/2017/07/628f1138d22dfc8b03a20def857e7967.jpg
https://s8.hostingkartinok.com/uploads/images/2017/07/36f8ba9c6a7806914f49b57fceaf7061.jpg
https://s8.hostingkartinok.com/uploads/images/2017/07/5a4df9d13773147f691e6ab3b244a547.jpg
结果,我成功配置了unix子系统,安装了vbox、vagrant和ansible。但是当我输入 vagrant up
我看到
VirtualBox is complaining that the installation is incomplete. Please run
VBoxManage --version to see the error message which should contain
instructions on how to fix this error.
所以,我 运行 VBoxManage --version
并且有
The character device /dev/vboxdrv does not exist. Please install the
virtualbox-dkms package and the appropriate headers, most likely linux-
headers-3.4.0+. You will not be able to start VMs until this problem is
fixed
如果我尝试 apt-get install virtualbox-dkms
它说最新版本已经安装了。
如果我对问题的理解正确,你想使用 Windows 10 作为你的主机 OS,运行 Ubuntu 作为该主机上的虚拟机 OS(使用 Hyper-V 或 VirtualBox),然后 运行 另一个 虚拟机嵌套在第一个虚拟机中(使用 Vagrant/VirtualBox)。这叫做"nested virtualization."
我认为嵌套虚拟化对于 VirtualBox 上的 64 位客户机 OSes 是不可能的,因为 VirtualBox does not expose VT-X/AMD-V within the Guest。
对于 Hyper-V,nested virtualization is supported on Windows 10,但官方仅支持客户机中的 Hyper-V 运行ning。来自文档:"Virtualization applications other than Hyper-V are not supported in Hyper-V virtual machines, and are likely to fail. This includes any software that requires hardware virtualization extensions."
您仍然可以尝试 运行在虚拟机中 运行在 Hyper-V 上使用 Vagrant 和 VirtualBox,看看它是否适合您。
从更广泛的角度看这个问题,我想知道您是否可以 运行 两个虚拟机并排...像这样:
- 在 Windows 10
上使用 VirtualBox 和 Vagrant
- 在 VirtualBox 上创建一个 Ubuntu VM 到网络 N运行 Ansible
- 使用 Vagrant 在网络 N 上创建另一个 VM
也就是说,我对 Ansible 了解不多,所以我可能遗漏了一些东西。
披露:我在 Microsoft 的 Hyper-V 团队工作。
事实上,您可以使用 Windows(有点)。至少,您不需要用于 Ansible 的完整 Linux 虚拟机。尝试查看 运行ning Windows Subsystem for Linux in Windows 10,这样您就可以从那里使用 Ansible。
您可以为 Windows 安装 Vagrant,它将支持 Hyper-V 提供商。现在从 Bash 到 windows 你可以同时使用:Linux ansible 二进制和 windows vagrant.exe (这将启动你的常规 windows 控制台),都来自 bash shell.
我以这种方式使用 Ansible 非常方便,我刚刚测试了从 bash.
启动一个 windows 进程
根据上面的截图,你的 Windows 主机上的任何逻辑驱动器都可以通过 /mnt/drive_letter/
访问,这就是你调用 vagrant 的方式。
因此,您的工作流程将是:
- 安装 WSL
- 在 WSL 中安装 Ansible
- 在 Windows
中启用 Hyper-V 组件
- 为 Windows
安装 Vagrant
- 创建一个管理 vagrantfile 的剧本(使用 Hyper-V
提供者)并调用 "vagrant.exe up"
当 ansible-playbook 为 运行 时,它应该根据您的 vagrantfile 启动 Hyper-V 虚拟机。此设置允许您在主机和 vagrant 机器之间获得任何类型的网络连接,包括使用 WSL 中的 Ansible 管理这些 VM,同时让 playbook 贴近您的 Windows 心脏,并根据需要使用 Notepad++ 编辑它们: )
这里有一个网站,可以帮助 Vagrant 和 Hyper-V 结合一些示例和详细步骤:Vagrant up on Windows 10 with Hyper-V
我需要构建 Vagrantfile。我需要使用 Ansible(所以,我无法使用 Windows)。
但我的主要 OS - Windows 10. 我可以在 Hyper-V 或 VirtualBox 上安装 Ubuntu。
1) 我创建了 Hyper-V 机器并在其上安装了 Ubuntu。但是 vagrantfile 不能使用 hyper-v 作为提供者并且需要 virtualbox。
2) 如果我尝试在 VirtualBox 上启动虚拟 Ubuntu,我会遇到错误
Failed to open a session for the virtual machine Ubuntu.
AMD-V is not available (VERR_SVM_NO_SVM).
Result Code: E_FAIL (0x80004005)
Component: ConsoleWrap
Interface: IConsole {872da645-4a9b-1727-bee2-5585105b9eed}
2) 如果我在 Windows 上关闭 Hyper-V,我可以在 VirtualBox 上启动 Ubuntu。
但是当我尝试 vagrant up
时,出现错误:
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.
Command: ["startvm", "4e3f95fd-2ad3-423f-a39a-ffd65cfe0d46", "--type",
"headless"]
Stderr: VBoxManage: error: AMD-V is not available (VERR_SVM_NO_SVM)
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component
ConsoleWrap, interface IConsole
在 VirtualBox 设置中 AMD-V/VT-x 已启用 screenshot
是否有机会在虚拟 Ubuntu 上与 vagrant 合作?把真正的主系统从 Windows 改成 Ubuntu.
真是太不可取了感谢您的帮助!
更新。我可以添加我的 virtualbox 和 BIOS 截图,也许会有用。
虚拟盒子:
这是我的机器Ubuntu:
AMD-V 已启用:
BIOS: https://s8.hostingkartinok.com/uploads/images/2017/07/4fe67600624d20d8194edc3d9224db69.jpg https://s8.hostingkartinok.com/uploads/images/2017/07/6f05e15236404042ff929ad10280a1d1.jpg https://s8.hostingkartinok.com/uploads/images/2017/07/23e417ab2fb13191780417030960cb82.jpg https://s8.hostingkartinok.com/uploads/images/2017/07/fbcd47ad170ece6127592a6ca8d7dad5.jpg https://s8.hostingkartinok.com/uploads/images/2017/07/65de25614774edc4f19506c8c10c61fe.jpg https://s8.hostingkartinok.com/uploads/images/2017/07/ca73abc19ee7d82398f0574cf77789b4.jpg https://s8.hostingkartinok.com/uploads/images/2017/07/8a15b5e490b285c41268cd4f6b0930c3.jpg https://s8.hostingkartinok.com/uploads/images/2017/07/9c52e945ad8efc009b772b3e88f5672e.jpg https://s8.hostingkartinok.com/uploads/images/2017/07/3357dd1540a2ea57e308a59ae41cf0af.jpg https://s8.hostingkartinok.com/uploads/images/2017/07/311e96617a120ec3f22f4fe6833d3dc1.jpg https://s8.hostingkartinok.com/uploads/images/2017/07/4963e3b283d1209e4e88a6b14d133dcd.jpg https://s8.hostingkartinok.com/uploads/images/2017/07/628f1138d22dfc8b03a20def857e7967.jpg https://s8.hostingkartinok.com/uploads/images/2017/07/36f8ba9c6a7806914f49b57fceaf7061.jpg https://s8.hostingkartinok.com/uploads/images/2017/07/5a4df9d13773147f691e6ab3b244a547.jpg
结果,我成功配置了unix子系统,安装了vbox、vagrant和ansible。但是当我输入 vagrant up
我看到
VirtualBox is complaining that the installation is incomplete. Please run
VBoxManage --version to see the error message which should contain
instructions on how to fix this error.
所以,我 运行 VBoxManage --version
并且有
The character device /dev/vboxdrv does not exist. Please install the
virtualbox-dkms package and the appropriate headers, most likely linux-
headers-3.4.0+. You will not be able to start VMs until this problem is
fixed
如果我尝试 apt-get install virtualbox-dkms
它说最新版本已经安装了。
如果我对问题的理解正确,你想使用 Windows 10 作为你的主机 OS,运行 Ubuntu 作为该主机上的虚拟机 OS(使用 Hyper-V 或 VirtualBox),然后 运行 另一个 虚拟机嵌套在第一个虚拟机中(使用 Vagrant/VirtualBox)。这叫做"nested virtualization."
我认为嵌套虚拟化对于 VirtualBox 上的 64 位客户机 OSes 是不可能的,因为 VirtualBox does not expose VT-X/AMD-V within the Guest。
对于 Hyper-V,nested virtualization is supported on Windows 10,但官方仅支持客户机中的 Hyper-V 运行ning。来自文档:"Virtualization applications other than Hyper-V are not supported in Hyper-V virtual machines, and are likely to fail. This includes any software that requires hardware virtualization extensions."
您仍然可以尝试 运行在虚拟机中 运行在 Hyper-V 上使用 Vagrant 和 VirtualBox,看看它是否适合您。
从更广泛的角度看这个问题,我想知道您是否可以 运行 两个虚拟机并排...像这样:
- 在 Windows 10 上使用 VirtualBox 和 Vagrant
- 在 VirtualBox 上创建一个 Ubuntu VM 到网络 N运行 Ansible
- 使用 Vagrant 在网络 N 上创建另一个 VM
也就是说,我对 Ansible 了解不多,所以我可能遗漏了一些东西。
披露:我在 Microsoft 的 Hyper-V 团队工作。
事实上,您可以使用 Windows(有点)。至少,您不需要用于 Ansible 的完整 Linux 虚拟机。尝试查看 运行ning Windows Subsystem for Linux in Windows 10,这样您就可以从那里使用 Ansible。
您可以为 Windows 安装 Vagrant,它将支持 Hyper-V 提供商。现在从 Bash 到 windows 你可以同时使用:Linux ansible 二进制和 windows vagrant.exe (这将启动你的常规 windows 控制台),都来自 bash shell.
我以这种方式使用 Ansible 非常方便,我刚刚测试了从 bash.
启动一个 windows 进程根据上面的截图,你的 Windows 主机上的任何逻辑驱动器都可以通过 /mnt/drive_letter/
访问,这就是你调用 vagrant 的方式。
因此,您的工作流程将是:
- 安装 WSL
- 在 WSL 中安装 Ansible
- 在 Windows 中启用 Hyper-V 组件
- 为 Windows 安装 Vagrant
- 创建一个管理 vagrantfile 的剧本(使用 Hyper-V 提供者)并调用 "vagrant.exe up"
当 ansible-playbook 为 运行 时,它应该根据您的 vagrantfile 启动 Hyper-V 虚拟机。此设置允许您在主机和 vagrant 机器之间获得任何类型的网络连接,包括使用 WSL 中的 Ansible 管理这些 VM,同时让 playbook 贴近您的 Windows 心脏,并根据需要使用 Notepad++ 编辑它们: )
这里有一个网站,可以帮助 Vagrant 和 Hyper-V 结合一些示例和详细步骤:Vagrant up on Windows 10 with Hyper-V