How to switch Vagrant virtual machine?

I was working on a virtual machine that I configured using Vagrant when I realized that I needed to access it through port 8000 to test the web interface, so I did a vagrant halt to change the Vagrantfile and forward port 8000, then I saved the file and did vagrant up to download a backup of this machine and, to my surprise, instead, Wagrant built a new machine from scratch. Now, when I look in the folder named "VirtualBox VMs", I see two virtual machines with the same name + a long number that is different. I believe this is the first machine I want to load with all my packages and settings, and the other is empty. How can I go back to the first, so when I do vagrant up , does it really download this file? And optionally, how do I get rid of the new, the empty?

+7
vagrant ubuntu virtualbox
source share
2 answers

I understand that every project of the Vagrant project (home of the Vagrantfile ) is associated with a virtual machine managed by vagrant in VirtualBox (the default provider). Usually in the template "baseboxname_id".

Your problem may be caused by errors in older versions of vagrants. Make sure you are using the latest version of Vagrant 1.3.3 + VirtualBox 4.2.18. OR, possibly mixed with several Vagrantfile (this is unlikely to be based on your description).

Calculation of the identifier of the block of strollers

  • Change the directory where Vagrantfile is located
  • Browsing the contents => /path/to/Vagrantfile/.vagrant/.vagrant/machines/default/virtualbox/id you will get an identifier like a90df491-4c25-4a07-be1a-be137908058c .

    NOTE. is a uuid virtual machine associated with a Vagrantfile managed by VirtulBox.

How to get rid of a new / empty VM

Now that you know uuid , you can unregister virtual machine and delete it => VBoxManage unregistervm <uuid> --delete .

Vagrantfile to 1st Virtual Machine

  • Get a list of virtual machine names and uuids managed by VirtualBox
  • Replace id with uuid of 1st virtual machine in /path/to/Vagrantfile/.vagrant/.vagrant/machines/default/virtualbox/id
  • Bring 1st VM up => vagrant up
  • Done!
+7
source share

As stated above, collect the desired vm id with something like:

 `vboxmanagevm list vms` 

Then replace the contents of $ vagrant_base_dir / .vagrant / machines / default / virtualbox / id with the desired identifier.

What is not mentioned above is that the file should be a single line without a new line or carriage return: Try something like:

 tr -d '\n' < id > id 

This tidbit was found. How to link the Vagrant project directory with an existing VM virtual machine?

Hope this helps anyone who finds it.

0
source share

All Articles