I have a Vagrant box with Ubuntu 12.04 LTS. Sometimes after forcing a shutdown (e.g. because the machine became unresponsive) the vagrant box fails to boot the next time.
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
[default] Clearing any previously set forwarded ports...
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
[default] Running 'pre-boot' VM customizations...
[default] Booting VM...
[default] Waiting for machine to boot. This may take a few minutes...
The preview screenshot in Virtualbox suggests that the box hangs at the grub stage, forever waiting for a user input to select the kernel.
So every time this occurs, I set vb.gui = true
in the Vagrantfile, restart the machine and select the kernel to boot manually. The interesting thing is that after selecting the kernel once, subsequent headless starts again just work fine – until the next ungraceful machine shutdown.
My questions is: Is there a more elegant way that does not require manual intervention to prevent that the vagrant box hangs at the grub kernel selection screen after a forced shutdown?
Best Answer
First, get the machine id
Power off the VM
Then boot the machine with a GUI console
Wait for it to boot, login, run:
When successful, shut it down
And after this, vagrant up will just boot your VM normally
Source