Believe it or not, there are still applications that require the use of a Raw Device Mapping (RDM) if you're going to virtualize the machine it runs on. Recently I encountered a situation where the hard disk was already formatted as a Virtual Machine Disk format (VMDK) on a Virtual Machine File System (VMFS) datastore in VMware. In a previous article, I talked about converting an RDM to a VMDK; in this one, I cover the reverse process. I think the VMware KB article 3443266 on the subject is somewhat confusing, so I will attempt to explain the process in basic terms.
Converting a VMDK to an RDM
First, you should get a backup of your VM (this is a safety measure and not necessary to the process). After you back it up, sign in to vCenter and open an SSH session to the ESXi the VM in question resides on. You also need to create a lun to be used with the RDM in your storage. Make sure your ESXi cluster can see it, but you should not format it as a VMFS datastore.
These are the commands provided in KB article 2443266. Note: The only real difference between the two is whether you specify rdm (virtual) or rdmp (physical) within the command.
For conversion to a virtual RDM:
# vmkfstools –i srcfile -d rdm:/vmfs/devices/disks/identifier:partition /vmfs/volumes/datastore/vmdir/vmname.vmdk
For conversion to a physical RDM:
# vmkfstools –i srcfile -d rdmp:/vmfs/devices/disks/identifier:partition /vmfs/volumes/datastore/vmdir/vmname.vmdk
Let's break down what the commands mean. The vmkfstools is a built-in VMware command that allows you to do many things with the hard disks within virtual machines (VMs), and the –i switch clones the source to your destination.
The srcfile will be the location of your current hard disk that you'd like to convert. If you have several hard disks on that VM, you'll want to pick the right one. You can double check that you have the right one by going into Edit Settings on that VM and seeing how it’s labeled (Figure A).
Next you want to list the destination with the –d switch followed by the lun you created earlier. If you're not sure what the lun identifier is, you can find this in vCenter. Highlight the host the VM is on, click the Configuration tab, and then click Storage Adapters. You will need to find the hba that your new lun is mapped to (Figure B). The last part of the command is essentially the pointer the RDM will use.
Follow these steps to do the conversion:
1. Create a new lun on your shared storage.
2. Rescan your HBAs and check under Storage Adapters to ensure the cluster can see the lun.
3. Shut down the VM.
4. SSH into the ESXi host where the VM resides.
5. Type the command shown above.
a. Ex: # vmkfstools –i vmfs/volumes/VM/VM_1.vmdk -d rdmp:/vmfs/devices/disks/naa.5000144f72913613 /vmfs/volumes/datastore/vmdir/vmname.vmdk
6. You will see the clone status in the command line — wait for that to complete.
7. Right-click the VM again and go to Edit Settings.
8. Highlight the disk you are converting and click Remove, but make sure you do not delete it from disk — just remove it from inventory.
9. Click OK.
10. Go back into Edit Setting and click Add and then add a hard disk. Choose to add an RDM and follow the RDM wizard.
11. After you complete the wizard, power on the VM. You can go into Disk Management to make sure it's there. You should be able to also go into Windows Explorer and see the disk with all your data there.
Your VM should be up and running with all the hard disks. You will need to have a maintenance window for this, as your VM will be powered off during the entire cloning process; this could take a long time if you have a very large hard disk.
Please feel free to leave any comments or questions in the comments section.
Also read: Virtualizing the Enterprise, a Special Feature from TechRepublic and ZDNet
Lauren Malhoit has been in the IT field for over 10 years and has acquired several data center certifications. She's currently a Technology Evangelist for Cisco focusing on ACI and Nexus 9000. She has been writing for a few years for TechRepublic, Tech Pro Research, and VirtualizationAdmin.com. As a Cisco Champion, EMC Elect, VMware vExpert, and PernixPro, Lauren stays involved in the IT community. Lauren has been a delegate for Tech Field Day and has also authored a book called VMware vCenter Operations Manager Essentials.