无法启动homestead,出现报错Your VM has become "inaccessible." 该怎么办?

今天早上,进入到 Homestead 目录,执行 vagrant up,结果报错:

Bringing machine 'homestead-7' up with 'virtualbox' provider...
==> homestead-7: Checking if box 'lc/homestead' version '8.2.1' is up to date...
Your VM has become "inaccessible." Unfortunately, this is a critical error
with VirtualBox that Vagrant can not cleanly recover from. Please open VirtualBox
and clear out your inaccessible virtual machines or find a way to fix
them.

好吧,再一次出现了这个问题,我决定好好记录一下这个过程。

缕清思路#

我们使用 Homestead 开发的目的是,使用最高效的方式得到一个快速开发的、可更替的环境。所以解决这个报错的前提条件是,不能浪费太多时间,也不需要保留这个虚拟机的数据。

开始解决#

借鉴百度上面的方法#

按照刚才的思路,我们百度一下,看看网上其他人怎么做的。

删除.vagrant,重新执行 vagrant up

按照这个方法,会报错如下

Bringing machine 'homestead-7' up with 'virtualbox' provider...
==> homestead-7: Importing base box 'lc/homestead'...
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["import", "\\\\?\\C:\\Users\\admin\\.vagrant.d\\boxes\\lc-VAGRANTSLASH-homestead\\8.2.1\\virtualbox\\box.ovf", "--vsys", "0", "--vmname", "lt-settler_default_1574502090510_42501_1606697104250_24158", "--vsys", "0", "--unit", "11", "--disk", "C:/Users/admin/VirtualBox VMs/lt-settler_default_1574502090510_42501_1606697104250_24158/box-disk001.vmdk"]

Stderr: 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Interpreting \\?\C:\Users\admin\.vagrant.d\boxes\lc-VAGRANTSLASH-homestead\8.2.1\virtualbox\box.ovf...
OK.
0%...
Progress state: E_INVALIDARG
VBoxManage.exe: error: Appliance import failed
VBoxManage.exe: error: Code E_INVALIDARG (0x80070057) - One or more arguments are invalid (extended info not available)
VBoxManage.exe: error: Context: "enum RTEXITCODE __cdecl handleImportAppliance(struct HandlerArg *)" at line 957 of file VBoxManageAppliance.cpp

直接重新安装#

到了这一步,我按照自己的习惯,喜欢推倒一切,重新再来,速度更快。所以开始销毁这个虚拟机,重新搭建一套。

  1. 首先卸载 vagrant, 卸载 virtualbox
  2. 删除 C:\Users\admin 下面的 vagrant 和 virtualbox 的配置文件
    到此为止,已经完成 “推倒”
    下面来重建,
  3. 安装 virtualbox 和 vagrant
  4. 添加虚拟机
    进入 lc-homestead-8.2.1-2019112300 目录
    vagrant box add metadata.json
    成功添加,返回如下
    ==> box: Loading metadata for box 'metadata.json'
     box: URL: file://E:/lc-homestead-8.2.1-2019112300/metadata.json
    ==> box: Adding box 'lc/homestead' (v8.2.1) for provider: virtualbox
     box: Downloading: virtualbox.box
     box:
    ==> box: Successfully added box 'lc/homestead' (v8.2.1) for 'virtualbox'!
  5. 重新恢复 Homestead
    git checkout .
    ./init.bat
  6. 最后把之前备份的 Homestead.yml 放到里面,执行 `vagrant up’

乱七八糟的程序,想搞清楚里面的东西真的很花时间,不如推倒重来

本作品采用《CC 协议》,转载必须注明作者和本文链接
《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。