The other day one of our devs ran into a problem. They vagrant uped their VM and instead of a happy working VM they receive the following message:
Instead of booting the VM that already existed it created a new VM. When we looked at Virtual Box we saw that the old VM (BrokenVM in this example) still existed and the new vm (ubuntu_default_1455929302562_42575) had been created in error:
Vagrant uses a file to keep track of what VirtualBox VM it’s using. If you look in the “.vagrant/machines/default/virtualbox/” directory (“default” is the name of the Vagrant box so it might be different if you have multiple VMs) in the folder that contains your Vagrantfile you’ll see a file named “id”. This represents the VirtualBox ID of the VM it’s using. In my case it looks like this:
5b9eb013-65e0-4d4c-91f3-87b0fd19156a
Now we need to figure out what is the “correct” VM ID by using VBoxManage
As you can see the second line refers to the ID of the newly created/wrong VM but the first line contains the correct VM. To fix this problem we just need to copy and paste the “cb533ed8-4267-4450-9955-b8b11add10b4” in the id file we looked at earlier.
Because we’re using Vagrant it wouldn’t have been the end of the world if we had to reset the development box but this way the dev didn’t loose their test data.
Scott Keck-Warren
Scott is the Director of Technology at WeCare Connect where he strives to provide solutions for his customers needs. He's the father of two and can be found most weekends working on projects around the house with his loving partner.
Like this post? Don't forget to follow us on Twitter and Facebook for updates.