在Hyper-V Ubuntu虚拟机内通过Vagrant创建VirtualBox VM失败的问题求助
各位大佬好,我最近入手了《DevOps for the Desperate》这本书,结果卡在第1章创建Oracle VirtualBox虚拟机的练习上了,折腾好多次都没搞定,想请教下大家怎么解决。
我的操作流程是这样的:
- 先在Hyper-V里搭建了一台Ubuntu虚拟机(先后试过18.04 LTS、20.04 LTS、22.04 LTS三个版本,结果都一样)
- 接着打算在这台Ubuntu虚拟机里,用Vagrant再创建一层VirtualBox虚拟机
我已经顺利完成了书中的这些步骤:
- 按照xiv页的命令开启了虚拟化扩展:
Set-VMProcessor -VMName 'Ubuntu 20.04 LTS' -ExposeVirtualizationExtensions $true - 按照xxi页的命令克隆了项目仓库:
git clone https://github.com/bradleyd/devops_for_the_desperate/ - 完成了第4页的Vagrant安装
- 完成了第7页的Ansible安装
另外,因为最开始运行vagrant up时总是提示磁盘空间不足,我额外做了两个操作:
- 在Hyper-V设置里把虚拟机硬盘扩容到了100GB
- 用
growpart工具调整了Linux的分区大小,确保空间足够
现在的问题是,到第9页运行vagrant up时一直失败,当前出现的错误信息如下:
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'ubuntu/focal64'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'ubuntu/focal64' version '20230719.0.0' is up to date...
==> default: Setting the name of the VM: dftd
==> default: Clearing any previously set network interfaces...
There was an error while executingVBoxManage, a CLI used by Vagrant for controlling VirtualBox. The command and stderr is shown below.
Command: ["hostonlyif", "ipconfig", "vboxnet2", "--ip", "172.28.128.1", "--netmask", "255.255.255.0"]
Stderr: VBoxManage: error: Code E_ACCESSDENIED (0x80070005) - Access denied (extended info not available)
VBoxManage: error: Context: "EnableStaticIPConfig(Bstr(pszIp).raw(), Bstr(pszNetmask).raw())" at line 242 of file VBoxManageHostonly.cpp
有没有朋友遇到过类似的权限问题?麻烦帮我分析下原因,或者给点解决方向,谢谢大家!
备注:内容来源于stack exchange,提问作者Tikhon

