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.

Screenshot of Vagrantbox stuck at grub

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?


First, get the machine id

# Before v1.1
# MACHINE_ID=$(awk -F\" '{print $6}' .vagrant)
# After v1.1
MACHINE_ID=$(cat .vagrant/machines/default/virtualbox/id)

Power off the VM

VBoxManage controlvm ${MACHINE_ID} poweroff

Then boot the machine with a GUI console

VBoxManage startvm ${MACHINE_ID}

Wait for it to boot, login, run:

sudo update-grub

When successful, shut it down

VBoxManage controlvm ${MACHINE_ID} poweroff

And after this, vagrant up will just boot your VM normally


  • Thanks for pointing out this answer. However, this solution also contains a lot of manual steps and I wondered if there exists some "automatic" way to fix this. Mar 23 '14 at 11:22
  • I don't think there's a grub specific option to add to your Vagrantfile to prevent this behaviour. But once fixed, it should not happen again. Mar 23 '14 at 11:26
  • After it boots successfully you can add GRUB_RECORDFAIL_TIMEOUT=0 to /etc/default/grub to prevent this from happening again (and run update-grub after adding that line). This will tell grub to boot normally after a crash instead of waiting around for user input to choose recovery options which can't be answered since the VM is headless.
    – Matthew
    Jul 11 '15 at 2:52

Add to /etc/default/grub of your box:


And run:

sudo update-grub

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.