Home » Posts tagged 'RDM'

Tag Archives: RDM

Advertisements

Configure RDMs On ESXi Hosts

Due to a locking problem, booting ESXi hosts takes a lot of time when MSCS are running on LUNs. Since ESXi 5 this can be solved by setting an extra option on the LUNs called perennially reserved. This setting is local to each ESXi host and should be set on each host accessing the RDM. Now if you have a lot of RDMs, or a lot of hosts in your cluster that might take some work, so… powershell!

Note that this has been rewritten here, which was especially done for Site Recovery Manager.

# This script performs the following steps
# 1. Get all RDM information from your environment, listing VM, Cluster and diskinfo
# 2. Export this information to a csv file
# 3. Filters out RDMs that are not part of MSCS 
# 4. Set the IsPerenniallyReserved for each RDM on each host in the cluster to true
#
# Note: This scrip can be run each time a RDM or a host is added.
  # Script variables
$timestamp = Get-Date -format "yyyyMMdd-HH.mm"
$startdir = "D:\sjoerd"
$csvfile = "$startdir\rdmsettings-$timestamp.csv"
  # Scipt functions
# Note that you can suppress output from commands using | Out-Null
Function logger ($message) {Write-Host -ForegroundColor Green (Get-Date -format "yyyyMMdd-HH.mm.ss") "$message" `n}
Function loggeralert ($message) {Write-Host -ForegroundColor Red (Get-Date -format "yyyyMMdd-HH.mm.ss") "$message" `n}
  # Define csv table
$myTable = @()
  logger "Starting to create a csv file. This might take a while."
  foreach ($vm in (Get-VM | Get-HardDisk -DiskType "RawPhysical","RawVirtual")){
  $RDMInfo = "" |select-Object VMName,VMClusterName,DiskType,ScsiCanonicalName   $RDMInfo.VMName = $vm.Parent
   $RDMInfo.VMClusterName = Get-VM $vm.Parent | Get-Cluster
   $RDMInfo.DiskType = $vm.DiskType
   $RDMInfo.ScsiCanonicalName = $vm.ScsiCanonicalName   $myTable += $RDMInfo
}
  $myTable |Export-csv -NoTypeInformation $csvfile
  logger "Finished creating csv file. Now filtering out RDMs that are not part of MSCS."
  $allrdms = Import-Csv $csvfile
#Only get duplicates RDMs, these are part of MSCS 
$duprdms = Import-Csv $csvfile | Group-Object ScsiCanonicalName -noElement | where {$_.count -gt 1}   logger "Starting to set the Perennially Reserved option on:"
  ForEach ($rdm in $duprdms){
   $cluster = ($allrdms | where {$_.ScsiCanonicalName -eq $rdm.Name} | select VMClusterName | Select -First 1).VMClusterName
   $rdmdisk = $rdm.Name
   ForEach ($esxihost in (Get-Cluster $cluster | Get-VMHost)){
   Write-Host "ESXihost = $esxihost `t RDM = $rdmdisk"
  #To set the esxcli instance, run this command:
   $myesxcli = get-esxcli -VMHost $esxihost
   #To verify the parameter updates, run this command:
   #$myesxcli.storage.core.device.list("$rdmdisk")
   #To set the device as perennially reserved, run this command:
   $myesxcli.storage.core.device.setconfig($false, "$rdmdisk", $true)
   }
}

Resources

Source: http://www.getshifting.com/wiki/rdmsettings

Advertisements