问题
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:
vagrant failed to connect VM
https://superuser.com/questions/342473/vagrant-ssh-fails-with-virtualbox
https://github.com/mitchellh/vagrant/issues/410
http://vagrant.wikia.com/wiki/Usage
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?
回答1:
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?
来源:https://stackoverflow.com/questions/25966650/vagrant-stuck-in-waiting-for-vm-to-boot