Skip to content

Instantly share code, notes, and snippets.

@darksystem23
Last active February 29, 2016 09:57
Show Gist options
  • Save darksystem23/af73be9d1d28ee0e5203 to your computer and use it in GitHub Desktop.
Save darksystem23/af73be9d1d28ee0e5203 to your computer and use it in GitHub Desktop.
Convert a VirtualBox .ova VM into a Vagrant box
Sometimes distribution providers (such as UCS) only give you VirtualBox .ova files to test their software. Here is how you can easily and non-interactively import a .ova file into a .box for use with Vagrant.
$ VBoxManage import ./UCS-Virtualbox-Demo-Image.ova --vsys 0 --eula accept
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Interpreting /home/crohr/dev/ucs/./UCS-Virtualbox-Demo-Image.ova...
OK.
Disks: vmdisk1 53687091200 -1 http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized UCS-Demo-Image-virtualbox-disk1.vmdk -1 -1
...
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Successfully imported the appliance.
Then list your VMs to find the VM ID:
$ VBoxManage list vms
"UCS 4.1" {acef4c0a-35be-4640-a214-be135417f04d}
You can now package that VM as a Vagrant box:
$ vagrant package --base acef4c0a-35be-4640-a214-be135417f04d --output UCS.box
==> acef4c0a-35be-4640-a214-be135417f04d: Exporting VM...
==> acef4c0a-35be-4640-a214-be135417f04d: Compressing package to: /home/crohr/dev/ucs/UCS.box
And add it to the list of your local Vagrant boxes:
$ vagrant box add UCS.box --name UCS
Finally, you can create a Vagrantfile to use this box:
Vagrant.configure("2") do |config|
config.vm.box = "UCS"
# ...
end
And vagrant up!
Source: https://github.com/crohr/ebarnouflant/issues/7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment