Mapping a VMFS disk to Guest OS as RDM disk
Warning: officially VMware doesn't support this feature. But we've tested mounting VMFS disk as RDM at ESX 6.5 and it worked.
You need to create a new VMDK file and mount it to a VMFS disk using RDM. After it's done, you'll be able to add this “VMDK” disk to VM and use its data from within guest OS.
Now connect to ESXi host using SSH. If SSH is disabled, please see this guide on how to enable it
Browse to the folder with a virtual machine where the RDM disk should be added. To do this enter:
Obtain path to the local hard drive and datastores that should be mapped. Use the following commands to list available HDDs and datastores:
ls -l /vmfs/devices/disks/
ls -l /vmfs/volumes/
Create a vmdk file:
vmkfstools -z /vmfs/devices/disks/"test_rdm_disk".vmdk
Mapping local hard drive to vmdk file:
vmkfstools -z /vmfs/devices/disks/"HDD_name" /vmfs/volumes/"datastore_name"/"test_rdm_disk".vmdk
Add new VMDK file to the virtual machine using vSphere as a new drive from existing VMDK.
Now you can scan the datastore from inside of one of the VM's. datastore will be represented as one of the local RAW disks in Windows disk manager or as a VMFS volume in the "Hard drives" section of the disk list in VMFS Recovery™.
Please note: you can use -r parameter instead of -z:
vmkfstools -r /vmfs/devices/disks/"HDD_name" /vmfs/volumes/"datastore_name"/"test_rdm_disk".vmdk
Warning: Quotes represent parameters you should replace by own values from results of execution of ls -l command (above).
Also, pay attention to the spaces in the command, so you pass exactly 3 parameters to vmkfstools command. Here it is again with "[SPACE]" string to highlight these important spaces:
Disks connected as “-r” are connected as hypervisor disks. Such mode offers better compatibility for some guest OS, but some features like disk's S.M.A.R.T. are unavailable. We recommend using the -z parameter during mount operation as in this case disks are mounted as-is and represented to guest OS as real hardware drives.
Hint: at some cases, ESX required that datastore should have an "unmounted" state to allow RDM mapping.