Vagrant 卡在“等待 VM 启动"中 [英] Vagrant stuck in "Waiting for VM to Boot"
问题描述
我想在这个问题的开头提到我确实看过了大多数(如果不是全部)流浪的等待 VM 启动"故障排除线程:
我尝试过的方法包括:
还有更多.
以下是我设置 Vagrant 的方法:
注意:我们正在使用 Vagrant 1.2.2,因为我们目前没有时间将配置更改为更新版本.我也在使用 VirtualBox 4.2.26.
- 我的办公室有一个
/official/
文件夹,其中包含诸如Vagrantfile
之类的内容.在我的Vagrantfile
中有这些自定义设置:
<块引用>
config.vm.box = "my_box"config.ssh.private_key_path = "~/.ssh/github_rsa"config.ssh.forward_agent = trueconfig.ssh.forward_x11 = 真config.ssh.max_tries = 300config.vm.provision :shell, :inline =>/etc/init.d/networking restart"
我通过
vagrant box add my_box absolute_path/package.box
安装了我们的自定义框(称为package.box
),这很顺利.运行
vagrant up
,我会查看VirtualBox 的预览",它只会停留在登录页面.我的终端也只会说:Waiting for VM to boot.这可能需要几分钟时间.
据我所知,这是一个 SSH 问题.或者我的私钥问题,尽管在我的Vagrantfile
中我明确指出了我的私钥位置.
有趣的笔记:
在 VirtualBox GUI 中运行
dhclient
,它说没有找到命令.运行sudo dhclient eth0
是建议的修复之一.此修复:https://superuser.com/a/343775/298915的修改
/etc/rc.local
文件以在exit 0
之前包含行sh/etc/init.d/networking restart
."没有采取任何措施来解决问题.
结论:
我以为我弄乱了文件,尝试重新安装所有东西,但似乎并没有改善问题.我无法解决这个问题.有人能给我一些见解吗?
所以经过大约 12 个小时沮丧的故障排除后,我能够(最终)让 VM 启动.
设置您的私钥/公钥 使用提供的链接.我的盒子是
Debian Linux 3.2.0-4-amd64
,所以你必须使用/home 而不是
(以及私钥的相应/root/.ssh/id_rsa.pub
/vagrant/.ssh/id_rsa.pubid_rsa
路径).注意:确保您的文件具有正确的权限.使用
ls -l path
检查,并使用chmod
更改.您的机器可能没有/home/vagrant/.ssh/authorized_keys
,因此请使用touch/home/vagrant/.ssh/authorized_keys
生成该文件.使用 VirtualBox GUI 启动您的虚拟机(通过
Vagrantfile
boot-GUI 命令,或使用 VirtualBox 启动您的虚拟机).出现提示时使用vagrant
和vagrant
登录.在 GUI 中,使用
sudo dhclient eth0 -v
手动启动 dhclient.为什么默认关闭?我不知道. 我发现当我在上面的教程中尝试wget
私钥/公钥时它已关闭,但无法做到.转到本地机器的命令行并使用
vagrant reload
重新加载 vagrant.它应该会启动,并且不会再挂在等待 VM 启动"状态.
这对我有用.尽管其他机器可能会有所不同,但无论出于何种原因,Vagrant 都喜欢破坏.
建议:可以把这个保存成脚本,这样我们就不用每次都手动做这个了吗?
更新到最新版本的 Vagrant,您将永远不会再看到此问题.时间差不多了吧?
I want to preface this question by mentioning that I have indeed looked over most if not all vagrant "Waiting for VM to Boot" troubleshooting threads:
Things I've tried include:
https://superuser.com/questions/342473/vagrant-ssh-fails-with-virtualbox
http://scotch.io/tutorials/get-vagrant-up-and-running-in-no-time
And more.
Here's how I setup my Vagrant:
Note: We are using Vagrant 1.2.2 since we do not at the moment have time to change configs to newer versions. I am also using VirtualBox 4.2.26.
- My office has an
/official/
folder which includes things such asVagrantfile
inside. Inside myVagrantfile
are these custom settings:
config.vm.box = "my_box" config.ssh.private_key_path = "~/.ssh/github_rsa" config.ssh.forward_agent = true config.ssh.forward_x11 = true config.ssh.max_tries = 300 config.vm.provision :shell, :inline => "/etc/init.d/networking restart"
I installed our custom box (called
package.box
) viavagrant box add my_box absolute_path/package.box
which went without a hitch.Running
vagrant up
, I would look at the "preview" of the VirtualBox, and it would simply be stuck at the login page. My Terminal would also only say:Waiting for VM to boot. This can take a few minutes.
As far as I know, this is an SSH issue. Or my private key issues, though in myVagrantfile
I explicitly pointed to my private key location.
Interesting Notes:
Running
dhclient
within the VirtualBox GUI, it says command no found. Runningsudo dhclient eth0
was one of the suggested fixes.This fix: https://superuser.com/a/343775/298915 of "modify the
/etc/rc.local
file to include the linesh /etc/init.d/networking restart
just beforeexit 0
." did nothing to fix the issue.
Conclusion:
Having tried to re-install everything thinking I messed up a file, it did not seem to ameliorate the issue. I am unable to work with this issue. Could someone give me some insight?
So after around twelve hours of dejected troubleshooting, I was able to (finally) get the VM to boot.
Setup your private/public keys using the link provided. My box is a
Debian Linux 3.2.0-4-amd64
, so instead of/root/.ssh/id_rsa.pub
, you have to use/home/vagrant/.ssh/id_rsa.pub
(and the respectiveid_rsa
path for the private key).Note: make sure your files have the right permissions. Check using
ls -l path
, and change usingchmod
. Your machine may not have/home/vagrant/.ssh/authorized_keys
, so generate that file withtouch /home/vagrant/.ssh/authorized_keys
.Boot your VM using the VirtualBox GUI using (through either
Vagrantfile
boot-GUI command, or starting your VM using VirtualBox). Login usingvagrant
andvagrant
when prompted.Within the GUI, manually start dhclient using
sudo dhclient eth0 -v
. Why is it off by default? I have no idea. I found out that it was off when I tried towget
the private/public keys in the tutorial above, but was unable to.Go to your local machine's command line and reload vagrant using
vagrant reload
. It should boot, and no longer hang at "Waiting for VM to Boot."
This worked for me. Though it may be different for other machines, for whatever reason Vagrant likes to break.
Suggestion: can this be saved as a script so we don't need to manually do this everytime?
EDIT: Update to the latest version of Vagrant, and you will never see this issue again. About time, huh?
这篇关于Vagrant 卡在“等待 VM 启动"中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!