Vagrant虚拟机启动失败The guest machine entered an invalid state…

新建的vagrant虚拟机启动的时候莫名其妙的报了下面的错误:

The guest machine entered an invalid state while waiting for it to boot. Valid states are 'starting, running'. The machine is in the 'poweroff' state. Please verify everything is configured properly and try again.

If the provider you're using has a GUI that comes with it, it is often helpful to open that and watch the machine, since the GUI often has more helpful error messages than Vagrant can retrieve. For example, if you're using VirtualBox, run `vagrant up` while the VirtualBox GUI is open.

根据错误提示,直接用VirtualBox试开了一下vagrant产生的虚拟机,发现报错内容中包含了USB2.0字样,完整如下:

Failed to open a session for the virtual machine seconion-standalone. Implementation of the USB 2.0 controller not found! Because the USB 2.0 controller state is part of the saved VM state, the VM cannot be started. To fix this problem, either install the 'Oracle VM VirtualBox Extension Pack' or disable USB 2.0 support in the VM settings (VERR_NOT_FOUND).

既然这样,干脆直接禁用USB 2.0支持好了,反正现在基本上都是3.0起,禁用后问题解决。

禁用方法为在Vagrantfile中加入以下几行

config.vm.provider "virtualbox" do |vb|
  vb.customize ["modifyvm", :id, "--usb", "on"]
  vb.customize ["modifyvm", :id, "--usbehci", "off"]
end