一次vagrant启动失败的修复过程

一次vagrant启动失败的修复过程

    • vagrant启动失败
    • 问题排查
    • 修复过程
    • 结果

vagrant启动失败

由于电脑使用vagrant+ubuntu搭建的虚拟机开发环境,一次电脑突然断电导致vagrant启动失败。

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
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.

问题排查

  1. Google了一下解决办法,有篇blog说直接删除vagrant目录下生成的.vagrant隐藏文件即可,该blog下的七八个comments都表示这个方法有效。但是这样可能会导致vagrant数据丢失
  2. 由于这里错误信息有限,我们通过Virtual Box管理器试试能否启动
  3. 果然报了下面这个错误,这个才是真正的错误,原来是文件找不到
Runtime error opening 'C:\Users\Administrator\VirtualBox VMs\ubuntu1804\ubuntu1804.vbox' for reading: -102 (File not found.).

修复过程

去到:C:\Users\Administrator\VirtualBox VMs\ubuntu1804\这个目录下,发现有一个ubuntu1804.vbox.tmp文件,有可能是异常退出导致启动文件没有没有保存,把该文件改为:ubuntu1804.vbox,重新启动

结果

能正常启动了

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 80 (guest) => 8080 (host) (adapter 1)
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...

你可能感兴趣的:(Linux)