Skip to content

Instantly share code, notes, and snippets.

@pcn
Last active August 29, 2015 14:02
Show Gist options
  • Select an option

  • Save pcn/5d785a174fd39137d860 to your computer and use it in GitHub Desktop.

Select an option

Save pcn/5d785a174fd39137d860 to your computer and use it in GitHub Desktop.
Virtualbox can't import OVA files

http://answers.nuxeo.com/questions/8408/virtualbox-does-not-import-nuxeo-592 says that it's working in 4.2.

At least in 4.3, here's the garbage I'm getting:

Peters-MacBook-Pro:packer peter$ VBoxManage import ubuntu-12.04-server-cloudimg-amd64.ovf --vsys 0 --unit 11 --disk /tmp/foo/test.[5/2597]
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Interpreting /Users/peter/work/packer/ubuntu-12.04-server-cloudimg-amd64.ovf...
OK.
Disks:  vmdisk1 2361393152      -1      http://wiki.qemu.org/download/qcow2-spec.html   ubuntu-12.04-server-cloudimg-amd64-disk1.img    12
60768256        -1
Virtual system 0:
 0: Suggested OS type: "Ubuntu"
    (change with "--vsys 0 --ostype <type>"; use "list ostypes" to list all possible values)
 1: Suggested VM name "vm"
    (change with "--vsys 0 --vmname <name>")
 2: Product (ignored): Ubuntu 12.04 LTS (Precise Pangolin) Server
 3: Description "This is Ubuntu Server."
    (change with "--vsys 0 --description <desc>")
 4: Number of CPUs: 1
    (change with "--vsys 0 --cpus <n>")
 5: Guest memory: 256 MB
    (change with "--vsys 0 --memory <MB>")
 6: USB controller
    (disable with "--vsys 0 --unit 6 --ignore")
 7: Network adapter: orig bridged, config 3, extra type=bridged
 8: CD-ROM
    (disable with "--vsys 0 --unit 8 --ignore")
 9: SCSI controller, type LsiLogic
    (change with "--vsys 0 --unit 9 --scsitype {BusLogic|LsiLogic}";
    disable with "--vsys 0 --unit 9 --ignore")
10: IDE controller, type PIIX4
    (disable with "--vsys 0 --unit 10 --ignore")
11: Hard disk image: source image=ubuntu-12.04-server-cloudimg-amd64-disk1.img, target path=/tmp/foo/test.vmdk, controller=9;channel=0
0%...
Progress state: VBOX_E_NOT_SUPPORTED
VBoxManage: error: Appliance import failed
VBoxManage: error: Could not find a valid medium format for the source disk 'ubuntu-12.04-server-cloudimg-amd64-disk1.img' Check correctness of the image format URL in the OVF description file.
VBoxManage: error: Details: code VBOX_E_NOT_SUPPORTED (0x80bb0009), component Appliance, interface IAppliance
VBoxManage: error: Context: "int handleImportAppliance(HandlerArg*)" at line 779 of file VBoxManageAppliance.cpp
Peters-MacBook-Pro:packer peter$ VBoxManage --version
4.3.10r93012

The stupid answer is stupid: https://bugs.launchpad.net/ubuntu/+source/virtualbox/+bug/1004316

So need to "brew install quemu" to get the qemu-img command to transform the image from qcow2 to vmdk.

Peters-MacBook-Pro:packer peter$ qemu-img convert -f qcow2 -O vmdk ubuntu-12.04-server-cloudimg-amd64-disk1.img  ubuntu-12.04-server-cloudimg-amd64-disk1.vmdk

Next, the .ovf file has to be updated so that this:

  <References>
    <File ovf:href="ubuntu-12.04-server-cloudimg-amd64-disk1.img" ovf:id="file1" ovf:size="226426880" />
  </References>
  <DiskSection>
    <Info>Virtual disk information</Info>
    <Disk ovf:capacity="2147483648" ovf:diskId="vmdisk1" ovf:fileRef="file1" ovf:format="http://wiki.qemu.org/download/qcow2-spec.html"/>
  </DiskSection>

Becomes this:

  <References>
    <File ovf:href="ubuntu-12.04-server-cloudimg-amd64-disk1.vmdk" ovf:id="file1" ovf:size="260768256" />
  </References>
  <DiskSection>
    <Info>Virtual disk information</Info>
    <Disk ovf:capacity="2361393152" ovf:diskId="vmdisk1" ovf:fileRef="file1" ovf:format="http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized"/>
  </DiskSection>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment