Here's something I discovered while doing some exports and imports with Virtualbox appliances. I thought it would be useful for others to know.

Let's say that we have a virtual machine with a disk image in Virtualbox's native disk image format, VDI

Now, if we export that disk image as an appliance in the OVA/OVF format, this new disk image in the OVA/OVF package will be a VMWare disk image file (VMDK). Why? I guess, beause at the time of the creation of that standard, VMWare was probably the dominant player in the VM field.

So, if we would now import the previously exported appliance, we would like the resulting new vitual machine to again have a VDI disk image. Unfortunately for us, the imported virtual machine has now a vmdk disk image file, instead. OK, but why is that important, you ask. Why do we want the disk image to be in the VDI format?
For one, I prefer to the disk image format to be native to the virtualization software in order to avoid any hickups. But the main reason for me, is that Virtualbox cannot do some things like resizing or shrinking on VMDK disk images, to date. Today, if you want to resize or shrink a VMDK image, you need to first clone it into a VDI image, then do whatever you want to do with it, and if you really want to stick with VMDK, clone the processed file back into the VMDK format. Not to forget the other steps like releasing and attaching the disk images to a VM. Better to stick with the native format in the first place, right?

The solution is quick and easy though:

While importing the appliance, just rename the extension of the resulting image file from .vmdk to .vdi (see screenshot below). The importer will then write the imported disk image in the VDI format.

virtualbox import expert mode vdi

I have confirmed this to work with the current version of Virtualbox, 5.1.26. The functionality  seems to have been implemented with version 4.0.0 back in 2010 (changelog), though.

Reading the first few hundred bytes of the disk image with `less` or some equivalent tool, like so `less your_disk_image.vdi` should show something like this:

<<< Oracle VM VirtualBox Disk Image >>>
^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^?^Pھ^A^@^A^@^A^@^@^A^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@

 

...while doing the same with an vmdk image would show something like this:

KDMV^A^@^@^@^C^@^@^@^@^@^@^E^@^@^@^@^@^@^@^@^@^@^@^A^@^@^@^@^@^@^@^T^@^@^@^@^@^@^@^@^B^@^@^U^@^@^@^@^@^@^@^_^T^@^@^@^@^@^@(
^@^@^@^@^@^@^@
 
^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@# Disk DescriptorFile
version=1
CID=ee763a6f
parentCID=ffffffff
createType="monolithicSparse"

# Extent description
RW 83886080 SPARSE "kubuntu test-disk001.vmdk"

# The disk Data Base 
#DDB

ddb.virtualHWVersion = "4"
ddb.adapterType="ide"
ddb.geometry.cylinders="16383"
ddb.geometry.heads="16"
ddb.geometry.sectors="63"
ddb.geometry.biosCylinders="1024"
ddb.geometry.biosHeads="255"
ddb.geometry.biosSectors="63"
ddb.uuid.image="47b2c3ed-b90d-4746-a4c7-103ce9b16f9a"
ddb.uuid.parent="00000000-0000-0000-0000-000000000000"
ddb.uuid.modification="00000000-0000-0000-0000-000000000000"
ddb.uuid.parentmodification="00000000-0000-0000-0000-000000000000"
ddb.comment=""
^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@