Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vagrant stuck in "Waiting for VM to Boot"

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:

  1. vagrant failed to connect VM

  2. https://superuser.com/questions/342473/vagrant-ssh-fails-with-virtualbox

  3. https://github.com/mitchellh/vagrant/issues/410

  4. http://vagrant.wikia.com/wiki/Usage

  5. 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.

  1. My office has an /official/ folder which includes things such as Vagrantfile inside. Inside my Vagrantfile 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"
  1. I installed our custom box (called package.box) via vagrant box add my_box absolute_path/package.box which went without a hitch.

  2. 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 my Vagrantfile I explicitly pointed to my private key location.

Interesting Notes:

  1. Running dhclient within the VirtualBox GUI, it says command no found. Running sudo dhclient eth0 was one of the suggested fixes.

  2. This fix: https://superuser.com/a/343775/298915 of "modify the /etc/rc.local file to include the line sh /etc/init.d/networking restart just before exit 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?

like image 591
theGreenCabbage Avatar asked Sep 22 '14 04:09

theGreenCabbage


People also ask

Can vagrant work without VirtualBox?

Getting Started With Vagrant Before you start, make sure you already have a virtualization solution on your system. Solutions that work with Vagrant include VirtualBox, VMware, Docker, Hyper-V, and custom solutions.

How do I stop and start vagrant VM?

There are two ways to 'stop' a running Vagrant machine. You can either suspend or halt. vagrant halt shuts down the Vagrant machine - as though you shut down the machine cleanly, for example running a sudo shutdown now from the terminal in Ubuntu. Which, as the command would imply, forces the shutdown regardless.


1 Answers

So after around twelve hours of dejected troubleshooting, I was able to (finally) get the VM to boot.

  1. 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 respective id_rsa path for the private key).

    Note: make sure your files have the right permissions. Check using ls -l path, and change using chmod. Your machine may not have /home/vagrant/.ssh/authorized_keys, so generate that file with touch /home/vagrant/.ssh/authorized_keys.

  2. Boot your VM using the VirtualBox GUI using (through either Vagrantfile boot-GUI command, or starting your VM using VirtualBox). Login using vagrant and vagrant when prompted.

  3. 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 to wget the private/public keys in the tutorial above, but was unable to.

  4. 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?

like image 197
theGreenCabbage Avatar answered Oct 13 '22 09:10

theGreenCabbage