Transferring a Vagrant box to a new host machine (VirtualBox)

Submitted by kentr on 05/10/2018, 15:31

Problem

I recently switched to a new machine, and for various reasons some of my Vagrant boxes didn't transfer in the migration.  vagrant status resulted in a status of "not created (virtualbox)".

Since Vagrant boxes are supposed to be disposable and reproducible, in most cases this was fine.

But there were a couple that I wanted to transfer as-is.  This is how I did it.

Solution

  1. On the first machine, halt the Vagrant box.
  2. Copy the actual VirtualBox machine files.  On the Mac, these are in ~/VirtualBox VMs.
  3. Open the VirtualBox GUI, and choose Machine > Add.
  4. Navigate to the machine and add it, so that it appears in the VirtualBox GUI.
  5. Under the Vagrant project directory, copy the files for the Vagrant box in question under .vagrant/machines into the .vagrant/machines directory under the corresponding Vagrant directory on the new machine.
  6. In the Vagrant directory, double-check the machine's status with vagrant status.  It should be "poweroff" instead of "not created".
  7. At this point, you should be able to run vagrant up or vagrant reload as normal.

Add new comment