Thanks, but editing files is not acceptable for automation. There can be no human intervention once the script starts. Adding code to edit files, and then editing again to remove the lines will not work.
Also, I just tried creating a virtual disk, and then converting it to an RDM.
vmkfstools -i L1A1.vmdk -d rdmp:/vmfs/devices/disks/naa.60060160cd10330057dc59aeb981e211 /vmfs/volumes/datastore3/Linux1Auto1/L1_rdm.vmdk
That works, but you still get the same error trying to attach it.
If you attach the virtual disk first, and then try to convert it, you get this error message.
Linux1Auto1 # vmkfstools -i L1A1.vmdk -d rdmp:/vmfs/devices/disks/naa.60060160cd10330057dc59aeb981e211 /vmfs/volumes/datastore3/Linux1Auto1/L1_rdm.vmdk
Failed to open 'L1A1.vmdk': Failed to lock the file (16392).