Skip to content

Instantly share code, notes, and snippets.

@aondio
Created April 8, 2019 15:09
Show Gist options
  • Star 39 You must be signed in to star a gist
  • Fork 16 You must be signed in to fork a gist
  • Save aondio/66a79be10982f051116bc18f1a5d07dc to your computer and use it in GitHub Desktop.
Save aondio/66a79be10982f051116bc18f1a5d07dc to your computer and use it in GitHub Desktop.
Convert VirtualBox .ova to Vagrant box

Here's a step by step guide to convert a Virtualbox .ova to a Vagrant box.

  1. List your VMs to find the VM id you want to convert:
$ VBoxManage list vms
"testing" {a3f59eed-b9c5-4a5f-9977-187f8eb8c4d4}
  1. You can now package the .ova VM as Vagrant box:
$ vagrant package --base a3f59eed-b9c5-4a5f-9977-187f8eb8c4d4 --output name-of-your-box.box

the command vagrant package runs for quite some time before it can creates a Vagrant box. Be faithful and wait.

  1. Add the new box to the list of local Vagrant boxes:
$ vagrant box add new-box-name name-of-your-box.box
  1. Init, up, ssh and start usign your Vagrant box:
$ vagrant init #Init the new box with a Vagrantfile
$ vagrant up
$ vagrant ssh

And enjoy!

@topplethepat
Copy link

The first command worked great, but now with:
vagrant box add new-box-name name-of-your-box.box

I'm getting an error. Do I need to include the path to the new box?

@sunilvishvakarma
Copy link

The command should be
vagrant box add --name

@arturmartins
Copy link

warning: you need to have a user called vagrant before making it a vagrant box (it also needs a public key).

@ForeverWintr
Copy link

Note you can also instruct vagrant to use a different username. e.g. by adding config.ssh.username = "new_username" in the Vagrantfile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment