Monday, February 13, 2023

Import OVA which is created by VMWare to VirtualBox

Notes about the problem I had when trying to import OVA created by VMWare to VirtualBox...

My environment: 
  • Windows 10 pro + VirtualBox v7.0 
    • VirtualBox downgraded to 6.1.26 due to this issue with Wayland
      • Still not fixed with Wayland on old linux guest machine (kernel 2.x)
Failed to import OVA file, error when trying import OVA file (exported by VMWare) to VirtualBox:  
  • VBOX_E_INVALID_OBJECT_STATE (0x80bb0007)
OVA file is just a tar file, so extracted it using 7z, we can see these 3 files:
  • vm-disk1.vmdk: Virtual Disk file
  • vm.mf: checksum data
  • vm.ovf: OVF file, VM definition file
Use "qemu-img" to check "vm-disk1.vmdk" (need to install qemu tool to Windows ):
> qemu-img info vm-disk1.vmdk
image: vm-disk1.vmdk
file format: vmdk
virtual size: 22 GiB (23667847168 bytes)
disk size: 316 MiB
cluster_size: 65536
Format specific information:
    cid: 1377153543
    parent cid: 4294967295
    create type: streamOptimized
    extents:
        [0]:
            compressed: true
            virtual size: 23667847168
            filename: vm-disk1.vmdk
            cluster size: 65536
            format:
Probably  VirtualBox could not handle the "streamOptimized" type or compressed vmdk disk image format. 

Tried  use "qemu-img" to convert it to non-compressed disk image:
> qemu-img convert -f vmdk vm-disk1.vmdk -O vmdk vm-disk1-decompressed.vmdk
    
> qemu-img info vm-disk1-decompressed.vmdk
image: vm-disk1-decompressed.vmdk
file format: vmdk
virtual size: 22 GiB (23667847168 bytes)
disk size: 709 MiB
cluster_size: 65536
Format specific information:
    cid: 3421777080
    parent cid: 4294967295
    create type: monolithicSparse
    extents:
        [0]:
            virtual size: 23667847168
            filename: vm-disk1-decompressed.vmdk
            cluster size: 65536
            format:
Ok, now it is "monolithicSparse" and not-compressed disk image type.

Because we just created a new disk, old checksum in file "vm.mf" cannot be used so just delete this file before trying to import again

Replace the  original "vm-disk1.vmdk" with "vm-disk1-decompressed.vmdk"(or edit the "vm.ovf" to make it point to "vm-disk1-decompressed.vmdk", no need to correct the disk size information in this case)

Now try to import again "vm.ovf" and we should be able to import it to VirtualBox. After this step, we can modify the config of the imported VM (cpu numer, memory size, etc., just check the "vm.ovf" and try to set the same config)

After this step, we can run the imported virtual machine, but if you see the error No bootable medium found! System halted , you should enable the "Enable EFI" config:


Done.

No comments: