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 new vmdk file and mount it to VMFS disk using RDM. After it's done, you'll be able to add this “vmdk” disk to VM and use it's 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 virtual machine where RDM disk should be added. To do this enter:
Obtain path to the local hard drive and datastores that should be mapped. Use 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 virtual machine using vSphere as new drive from existing vmdk.
Now you can scan datastore from inside of one of VM's. datastore will be represented as one of the local RAW disks in Windows disk manager or as a VMFS volume in "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
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 to use -z parameter during mount operation as at this case disks are mounted as is and represented to guest OS as a real hardware drives.
Hint: at some cases ESX required that datastore should have "unmounted" state to allow RDM mapping.