How to convert a VMDK to a RDM
Sometimes you have a nice colleague who is moving a Virtual Machine from one datacenter to another, however if this Virtual Machine have a RDM connected to it, and the storage is not linked to each other you would end up with an extra VMDK, that once was a RDM .
Okay so far my frustration (just kidding here) but It would be nice if VMware would have shown a big information message, that indicate that the RDM will be converted to a VMDK when an Admin is doing something like mentioned here above, because not every administrator is aware what he is doing.
Now lets take a look at how we can fix this, because we end up with quite a large VMDK file of around 450 GB, and because we only have a few VMFS datastores of approximately 500 GB each, this is not a great situation.
Step one: compatibility mode
The first step would be to determine what kind of compatibility mode (physical or virtual) you’re using or want to use, you need this information because each compatibility mode have it’s own command line option. Below I have written down a summary of these two compatibility modes.
The default is physical compatibility mode. This allows the Guest OS to access the hardware directly, and this can be useful for: Situations where SAN snapshot capabilities require this Physical-to-virtual clustering, or you want to use software/tools from the array vendor.
Virtual compatibility allows the VM to use VMware snapshots and other advanced functionality while still providing direct LUN access. This is the preferred mode to use if possible since you get the benefits of VM snapshots.
Unfortunately you can’t convert the VMDK file back to a RDM while it’s being used by the Virtual Machine, so to be able to convert it, you need to remove the VMDK from the Virtual Machine or shutdown the guest OS.
But remember if this VMDK/RDM is used by for example a database server it is better to shutdown the guest OS and secondly to remove (note: just remove it from the VM and not from the datastore!!!) the VMDK from the Virtual Machine itself.
Below you will find the command lines for each compatibility mode, make note that there’s actually one small difference between these two, the difference is where you point to the RDM itself, for virtual compatibility you use the RDM option and for Physical compatibility mode you need to use RDMP as shown here below.
- The command line itself is very straightforward, first you need to point to the VMDK file you want to convert, in my example below it’s located in /vmfs/volumes/DATASTORE-NAME/VM-NAME/VMDK-SOURCE.vmdk.
- In the next step you need to choose if you want to use Virtual or Physical Compatibility Mode, and you need to point to the RDM LUN itself.
- And in the last section you create a “pointer” VMDK file which can be used to connect the RDM to the Virtual Machine.
For Virtual Compatibility Mode enter: "vmkfstools -i /vmfs/volumes/DATASTORE/VM/VMDK-SOURCE.vmdk -d /vmfs/devices/disks/t10.F405E46494C45400373613631636D284B67665D28725C685 /vmfs/volumes/DATASTORE/VM/VMDK-TARGET.vmdk"
For Physical Compatibility Mode enter: "vmkfstools -i /vmfs/volumes/DATASTORE/VM/VMDK-SOURCE.vmdk -d /vmfs/devices/disks/t10.F405E46494C45400373613631636D284B67665D28725C685 /vmfs/volumes/DATASTORE/VM/VMDK-TARGET.vmdk"
Depending on the size of the VMDK file it could take some time to do the conversion, when it’s ready you only need to add the “pointer” file which you created in step 3, to be able to connect the RDM to the Virtual Machine.
Well that’s it, as you see it’s not that hard, it only could take up some (down) time.
Later I found out that VMware have written a nice KB article about this, so next time I first check out the KB list before I figure out how things are working .