Copying vagrant virtual machines from one computer into another

2,667 views
Skip to first unread message

Sean Tan

unread,
Jan 29, 2017, 5:06:59 PM1/29/17
to Vagrant
I am trying to copy a VirtualBox virtual machine from my old MacBook to my new MacBook

The virtual machine was created using Vagrant. I copied the project folder to my new MacBook. The project contains

  Vagrantfile
  .vagrant/
  ...

I also copied over the virtual machine folder in ~/VirtualBox VMs. The folder contains .vmdk, .vbox, .vbox-prev and other files.

Problem

* The virtual machine is not shown in VirtualBox in the new machine
* When I do `vagrant up`, it creates a new virtual machine in ~/VirtualBox VMs, instead of using the one I copied.

How do I copy over a virtual machine to another computer?

Alvaro Miranda Aguilera

unread,
Jan 29, 2017, 5:44:47 PM1/29/17
to vagra...@googlegroups.com
Hello.

in the old Machine if you run:
VBoxManage list vms

you will see the VM created have an uuid.

On the new machine, open Virtualbiox gui and see if you have the machine there, if not, try to open the machine file, the *.vbox file

Once the machine is listed, run 
VBoxManage list vms

and update this file with the new uuid:

.vagrant/machines/<boxname>/virtualbox/id

example:
.vagrant/machines/prdvbox-racn1/virtualbox/id

Once done.. why you need to keep this machine? Vagrant way is destroy/up all the time :)


Alvaro




--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/3a5df462-a00c-48c2-8f62-e924578d4bcd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Sean

unread,
Jan 30, 2017, 10:58:02 PM1/30/17
to Vagrant
Hi Alvaro.

Thanks a lot, that worked. Now, I understand how a Vagrant project is linked to a VM, via the UUID.

I am doing the provisioning via SaltStack. I am still doing some of the provisioning manually, since I am not sure how to code some operations.
Also, I have added some test data manually into the VM MySQL database, while developing.

It is easier for me now just to copy over the VM, though this need arose from bad programming practices :)

Alvaro Miranda Aguilera

unread,
Jan 31, 2017, 2:47:46 AM1/31/17
to vagra...@googlegroups.com

On Tue, Jan 31, 2017 at 4:58 AM, Sean <cct....@gmail.com> wrote:
It is easier for me now just to copy over the VM, though this need arose from bad programming practices :)

Well, don't do this:
It is easier for me now just to copy over the VM, though this need arose from bad programming practices :)

And use vagrant package.

think on you are creating an intermediate machine.

So on this intermediate machine use:
config.ssh.insert_key = false

Do the work

And then just create a new Vagrant box to be consumed by the next step.


OR

have a look at packer with virtualbox-ovf

Basically you put a folder with the VM to be used, and you start with an existing VM.
its pretty fast.

IF you need help on any of this, feel free to reply.


Alvaro.



Reply all
Reply to author
Forward
0 new messages