Visitors

HOW TO: Identify VMFS Datastore on Perennially Reserved LUN

We all well familiar with the problem with Raw Device Mapped (RDM) LUNs that are used by VMs running Microsoft Clusters Service.

VMware KB: 1016106

ESXi 5.0 uses a technique to determine if Raw Device Mapped (RDM) LUNs are used for MSCS cluster devices, by introducing a configuration flag to mark each device as “perennially reserved” that is participating in an MSCS cluster. During the boot of an ESXi host, the storage mid-layer attempts to discover all devices presented to an ESXi host during the device claiming phase. However, MSCS LUNs that have a permanent SCSI reservation cause the boot process to lengthen as the ESXi host cannot interrogate the LUN due to the persistent SCSI reservation placed on a device by an active MSCS Node hosted on another ESXi host.

Going through the ESX host logs we noticed several storage errors such as the following.

2013-09-10T10:36:37.498Z cpu0:6070)Partition: 484: Read of GPT header failed on "naa.6006016002d02c00763f3a9f87b0e111": I/O error
2013-09-10T10:36:40.389Z cpu5:6070)WARNING: Partition: 1083: Device "naa.6006016031d02c00ec0b2c0d8f88e211" with a VMFS partition is marked perennially reserved. This is not supported and may lead to data loss.

We still need to investigate how or why the LUN that is VMFS formatted  has been configured as such but in the mean time, here is the script that checks if any datastore / corresponding LUN is configured as “Perennially Reserved“.

$PRreport = @()
$cluster = "My_Super_Cluster"
$vmhosts = Get-Cluster -Name $cluster | Get-VMHost
foreach ($vmhost in $vmhosts) {
$myesxcli = Get-EsxCli -VMHost $vmhost
foreach ($DS in Get-Datastore -VMHost $vmhost){
$Result = New-Object PSObject
$DSDiskName = $DS.ExtensionData.Info.vmfs.extent[0].diskname
$diskinfo = $myesxcli.storage.core.device.list("$DSDiskName") | Select IsPerenniallyReserved
# Option 1| Write-Host $vmhost, $DS, $DS.ExtensionData.Info.vmfs.extent[0].diskname, $diskinfo.IsPerenniallyReserved
# Option 3| if ($diskinfo.IsPerenniallyReserved -eq "true"){
# Option 2| $Result | add-member -membertype NoteProperty -name "Host" -Value $vmhost
# Option 2| $Result | add-member -membertype NoteProperty -name "Datastore" -Value $DS
# Option 2| $Result | add-member -membertype NoteProperty -name "Disk Name" -Value $DS.ExtensionData.Info.vmfs.extent[0].diskname
# Option 2| $Result | add-member -membertype NoteProperty -name "Is PR'd?" -Value $diskinfo.IsPerenniallyReserved
# Option 2| $PRreport += $Result
# Option 3| }
}
}
# Option 2| $PRreport | Export-Csv -Path "C:PRreport.csv"

There are three output options. (Un-comment relevant line and remote “Option x|”):

  • Option 1| – Lists Host name, Datastore name, Disk Name, Perennially Reserved (true or false);
    ESX51-01.vStrong.info DATASTORE01 naa.6006016031d02c0007171886a6fae211 false
  • Option 2| – Exports the list to CSV file
    Host Datastore Disk Name Is PR’d?
    ESX51-01.vStrong.info DATASTORE01 naa.6006016031d02c0007171886a6fae211 FALSE
  • Option 3| – Does exactly the same as Option 2 but lists PR’ed LUNs only.

Hope this will help.

6 comments to HOW TO: Identify VMFS Datastore on Perennially Reserved LUN

  • Hi Mark,

    Thanks for the script…
    Can you please explain me how to use it.

    Regards
    Prasad

    • Hi Prasad,
      You need to run this script for a particular VMware cluster or, if you want to check all hosts/datastores, remove ‘$cluster = “My_Super_Cluster”‘ and change ‘$vmhosts = Get-Cluster -Name $cluster | Get-VMHost’ to ‘$vmhosts = Get-VMHost’.
      Regards
      Mark

  • Chip

    When I run this on a cluster, I only get LUNs that are false. I know that is not the case.

  • Dan

    Chip, could it be you’re looking for RDM LUNs? As Mark is just checking VMFS datastores.

  • Syed

    How could we check for RDM`s
    I need to check for all RDM`s if the PR is set or not.

  • Bjarne

    Syed, something like this might help you :

    $vms = get-vm
    foreach($vm in $vms){
    $rdms = Get-HardDisk -DiskType rawPhysical -Vm $vm
    if ($rdms.count -gt 0) {$esxcli = Get-EsxCli -VMHost $vm.vmhost.name}
    foreach($rdm in $rdms){
    $dvc = $esxcli.storage.core.device.list($rdm.ScsiCanonicalName)
    foreach ($dv in $dvc | where {$_.Device -match “naa.”} ) {
    if ($dv.IsPerenniallyReserved -eq $false) {
    Write-Host $dv.Device “needs to be fixed”
    } else { Write-Host $dv.Device “is OK” }
    }
    }
    }

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>