6

I created a virtual machine with that has a 4.7 GB virtual hard disk (.vmdk). I exported to .ova version 1.0 and got a 1.7 GB file which I was able to compress by another 200 mb using 7zip. So the 7zip archive with OVA is 1.5 GB.

7zipping the vm files directly gave me a file size of 1.1 GB. This is an ideal size and I'm wondering if anybody knows how to increase the compression of the ova file or manually create the ova file. I'm using virtual box but also have vmware. Here is the command I'm running on 7zip.

 7z a -t7z vm.7z -m0=lzma2 -mx=9 -aoa vm.ova

I'm running the same command without vm.ova inside the vm folder to get the 1.1 GB file. My goals are smallest file size and easily useable in both vmware and virtualbox, import to qemu, hyper-v, and vshere is a plus.

2
  • what happens if you shutdown the original VM, clone it first, then export without ever turning the clone on? thoughts are to minimize any extraneous files (memory, log, etc) and also that you thin provisioned any virtual drives used.
    – TG2
    Oct 1, 2016 at 18:27
  • Logs only add up to around 500 kb. I did clone then export for thoroughness, the exported .ova file was 1.7 GB as well. The drives are thin provisioned. Oct 1, 2016 at 21:43

2 Answers 2

6

An .ova file is just a tar file according to the specs. Within the ova file is a .vmdk file which holds the virtual disk and a .ovf file which holds the configuration. OVF is a standard that works cross-platform.

After creating the ova file, extract the ovf and vmdk using tar

tar xvf appliance.ova

Delete the ova file or move it somewhere else if you need to.

The vmdk file is already compressed at this point so running 7zip directly on these two files won't reduce the compression by much.

Delete the .vmdk file and grab the original uncompressed vmdk file from before you made the appliance. Check your .ovf file (xml) to make sure the filenames match. Find the xml element that starts like this

<File ovf:href="diskname.vmdk" ovf:id="file1" />

In this case, the uncompressed vmdk file should be named (or renamed, if needed) to diskname.vmdk

Now run this 7zip command inside the directory with your 2 files (.ovf and .vmdk).

7z a -t7z appliance.7z -m0=lzma2 -mx=9 -aoa

Your .7z file can now be distributed with the smallest file size I was able to achieve.

To run the appliance just extract the files and import the .ovf file into VirtualBox, VMware or any other virtualization solution that can import appliances. As long as the two files are in the same directory it should import and run fine.

1
  • I tried several different methods and this is the one that worked best for me with the goal of having the smallest download size. manually creating the .ova file with tar and max gzip compression, compressing the ova file with 7zip, and creating the ova file with 7zip using the -tgzip switch. This created the smallest size but will create 2 copies of the uncompressed vmdk (once on extraction, once on import). after import, the extract files can be deleted though. An ova file might work best for simplicity if that is your goal. Oct 2, 2016 at 15:53
4

We found that zeroing out and then re-exporting from VirtualBox dramatically reduced the disk space of the ova. Went from 8.5 GB -> 3 GB.

  1. Followed through step 2 of these instructions (https://www.howtogeek.com/312883/how-to-shrink-a-virtualbox-virtual-machine-and-free-up-disk-space/)
  2. Exported an new OVA from the VirtualBox GUI. (Am using 5.1.26 r117224 (Qt5.6.2) on a MacBook.

Hope that helps.

2
  • Zeroing out a vm drive is a basic step so I didn't mention it. Good tip for newbies though. The above steps produced the smallest file size on an optimized VM. Sep 24, 2017 at 14:27
  • 1
    This answer is actually talking about sdelete. For me personally, it reduced my ova from 13.7GB to 13.2GB. See: serverfault.com/a/165074
    – Jeff Luyet
    Aug 18, 2022 at 13:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .