How to change VMDK geometry

I recently ran into an issue were I needed to change the geometry of some VMDK files – I will do a seperate blog post on where and why later. For now I will just focus on how to change VMDK geometry.

A VMDK is just a file with some descriptional data and the actually binary data of the VMDK. Think of it as a virtual harddisk. It adheres to the same physical characteristics and there for the physical characteristics are also part of a VMDK file.

Normally you won’t need to change the geometry of a VMDK – I this case I needed to upload vRops applience to a cloud service, which only supports 63 sectors, which is not how the vRops ova is by default.


If I were using linux, I guess I would simple have used sed to change the values in the VMDK files, which needed correction, but i’m using windows. I started out trying to change the value in the VMDKs with notepad++, but files were too big, I then moved in to use default windows methods, batch, powershell, but ran quickly into issues with speed and or memory limitations. Having 20 GB of memory didn’t help at all. Knowing that this problem could be solved fast on linux, I installed GnuWIN32, but also here I ran into issues – The tools didn’t behave like I was use to on linux. So instead I went back to seeing if I couldn’t find a useful way to get it working with powershell.


How to change VMDK geometry – Prerequisites

Normally the .vmdk files contains just a descrption of the data and chain of the data contained in the -flat.vmdk files. This being an ova, I needed to deploy, the vmdk files have been compressed, so that all data descriptional and binary is contain within each VMDK file. This is the reason that notepad++ wouldn’t open the files, they were just too big, the same goes for the powershell commandlet get-content, which will load the entire file into memory, my 20GB of memory will never be enough.

The first part of solving this issue, was to find a way to edit the VMDKs. The solution was to convert the VMDKs from compressed to full VMDKs with VMware Workstation. This means that I would get the small .vmdk file with only the descriptional data just perfect for my need. Doing the next part with Powershell was now a lot easiere!


  • VMware Workstation
  • Powershell
  • 7-zip or another tool that can extract tar files


The solution

First of I have downloaded the vRops OVA file and extracted that to a folder, as can be seen in the first line of the script below. If you are using 7-zip like I, you can just right click on the OVA and extract it, other tools might need you to to rename the .ova file to .tar. The variable $Path, needs to point to the directory where the VMDK files have been extracted to. The next variable points to the location of the vmware-vdiskmanager.exe, which comes default with VMware Workstation, again this path needs to be correct.

$Path is very important as the script will do a dir and get ALL VMDKs in that path – So if other VMDKs are in the dir, they will get the treatment aswell and I also do some clean up later on in the script, which could result in data loss! So please extract the OVA to it own directory and not a shared one with other files.

The next part of the script changes the cylinders, heads and sectors if the sectors is not by default 63, and only then! If you need it to do anything else, you need to modify the script your self.

First it will verify that the VMDK needs to have changes made, then it does some math, before it decompresses the VMDK files, in a new name. Leveaing the orginals untouched. Doing the changes to the temp VMDKs, before it compresses the temp VMDKs to new VMDKs with the postfix “-NEW.vmdk”. Lastly it deletes all files the temp files, leaving the untouched orginals and the new VMDK files.


In order to have a working OVF, I simple copy the new VMDKs and the ovf file to a new dir and rename the VMDKs, so that I can upload it to the cloud service. If you for some reason need a OVA file again, OVFtool can do the convertion. I did a blog post on a wrapper for ovftool for vCloud Air.


If you want to know more about how cylinders, heads and sectors fit togher, have a look at this KB. You can also read more on wikipedia.

Leave a Reply

Your email address will not be published. Required fields are marked *