POWERCLI SCRIPT TO SET RDM LUNS TO PERENNIALLY RESERVED – FIXES SLOW BOOT OF ESXI 5.1 WITH MSCS RDMS
I've previously posted around this topic as part of another problem but having had to figure out the process again I think it's worth re-posting a proper script for this. VMware KB 1016106 is snappily titled “ESXi/ESX hosts with visibility to RDM LUNs being used by MSCS nodes with RDMs may take a long time to boot or during LUN rescan” and describes the situation where booting ESXi (5.1 in my case) takes a huge amount of time to boot because it's attempting to gain a SCSI reservation on an RDM disk used by MS Clustering Services. It also details the fix.
The process is fairly simple, but a bit labour intensive if you're doing it manually on a large cluster.
- Retrieve the ScsiCanonicalName for each RDM
- Set the configuration for each RDM on each Host to “PerenniallyReserved”
Step 1 - Retrieve the ScsiCanonicalName for each RDM
This PowerCLI command lists the RDM disks attached to any VMs in a particular cluster. What we need here specifically is the SCSI canonical name (often known as the naa or eui identifier), but for the sake of sanity I suggest running it manually and examining the disks to ensure you're happy with the ones the script will set to PerenniallyReserved:
Step 2 - Set the configuration for each RDM on each Host to “PerenniallyReserved”
Once we have the list of RDM disks, we can then set the reservation via Get-EsxCli
Building Steps 1 and 2 into a script
Now it's just a simple case of constructing a script to loop through the hosts in a cluster and the RDMs on each host:
The script connects to each ESXi instance in the target cluster, queries all VMs on the target cluster and returns the RDM disks and then sets the PerenniallyReserved flag for each of the cluster hosts and RDM disks.
As usual, post any comments or improvements!
Edit: After my conversations with Mike, I've modified the script a little and attached as a zip file to download here: Set-RDMReservations