5

How do I convert a virtual appliance image in RAW format (in)directly to OVF/OVA format?

There is a tool called ovftools that allows the conversion from .ovf/.ova/.vmx to .ovf/.ova/.vmx. but it doesn't appear to support RAW disk as an input format.

Virtual Box also has VBoxManage allowing you to convert from VDI|VMDK|VHD|RAW to VDI|VMDK|VHD|RAW but nothing aboutOVF/OVA format.

I'm running Ubuntu/Debian GNU/Linux.

3 Answers3

3

.ova files are just a Posix tar file:

$ file foo.ova
foo.ova:            POSIX tar archive

If you decompress it, you'll find one .ovf (XML) file describing the VM, one text file with checksums (SHA-1), and one or more .vmdk files:

$ file *                                                                                                                                                                        
foo-disk1.vmdk:                        VMware4 disk image                                                                                                                                                          
foo-disk2.vmdk:                        VMware4 disk image                                                                                                                                                          
foo-disk3.vmdk:                        VMware4 disk image                                                                                                                                                          
foo-disk4.vmdk:                        VMware4 disk image                                                                                                                                                          
foo-disk5.vmdk:                        VMware4 disk image                                                                                                                                                          
foo.ova:                               POSIX tar archive                                                                                                                                                           
foo.mf:                                ASCII text                                                                                                                                                                  
foo.ovf:                               XML 1.0 document, ASCII text, with very long lines

So for a RAW .ova conversion, you will have to convert your raw files to .vmdk format, write the right .ovf file, create the .mf file, and tar everything into an .ova file. Notice that the latter does not include compression. The lines in the .mf file look like this:

SHA1(foo.ovf)= e33370daa74544dc30841e1c527628e5c8610c54

It can be easily obtained from sha1sum, but the format is different:

$ sha1sum 'foo.ovf'
e33370daa74544dc30841e1c527628e5c8610c54  foo.ovf

So:

$ sha1sum *.ovf *.vmdk | awk 'BEGIN { FIELDWIDTHS = "40 2 1024" } { print "SHA1(" $3 ")= " $1 }'
SHA1(HyperFile 3.3.0.ovf)= e33370daa74544dc30841e1c527628e5c8610c54
SHA1(HyperFile_3.3.0-disk1.vmdk)= a60c58d00010bdc715d96e89e34fd45f48a58b4c
SHA1(HyperFile_3.3.0-disk2.vmdk)= 92250a09ef4b924c51c64b37ba6dc7049eb24cc2
SHA1(HyperFile_3.3.0-disk3.vmdk)= aff779bf46c859506606fd8925f79ffb9a86d955
SHA1(HyperFile_3.3.0-disk4.vmdk)= 64dd05f7e5d73929234393c109b2d92d69dedc8e
SHA1(HyperFile_3.3.0-disk5.vmdk)= 157e9f9f6adeabcc41f228cd7b53fc0ef4da43f9

I'll let you read about the OVF format here: https://www.dmtf.org/standards/ovf

3

One thing that I want to say before I go on in case of confusion is that RAW,VMDK,VHD,VDI are all (virtual*) hard drive files, where as OVF,OVA,.VMX are Virtual Machine settings files. An OVF File comes with a separate virtual hard drive (which can be in VMDK format, or one of a few others), where as a OVA file is a contained all in one virtual machine.

(* - Majority are virtual!)

I have personally not seen a Virtual Machine boot from a RAW drive before. If you can convert a RAW to a VMDK using VBoxManage I would the recommend using VMWare Player or Workstation (for sure) or Virtual Box (not so sure!) to create a new Virtual Machine and select the VMDK file you just converted.

Again, I am not sure what Virtual Box uses as it's default settings file, but, I know VMWare Workstation uses VMX, you should then have no problems using ovftools as you will have a new Virtual Machine with the correct hard drive.

After looking around, the only tool I could find is Live View which can convert a Raw file to a VMDK.

William Hilsum
  • 117,648
0

I use Vboxmanage to convert raw to vdi. I then create a new machine in Vbox using the vdi file as the virtual disk. I start the new machine once to make sure it works. After shutdown I export the machine as an Ova file. Most VM tools such as Vbox will allow the ova to be imported and will run the machine.

Vboxmanage convertfromraw - - format /vdi

Mike
  • 11