Matching a LUN’s NAA Number to its NetApp Serial Number with Powershell

As stated here, a LUN NAA (Network Address Authority) number is a globally unique identifier for a LUN. The NAA number can be used to determine a LUN’s serial number and vice-versa.

On an ESXi host we can easily find the NAA for a device, either in the vSphere client, or via PowerCLI, or ESXCLI (shown below):

~ # esxcli storage vmfs extent list

Volume Name    VMFS UUID                            Extent Number  Device Name                                           Partition
-------------  -----------------------------------  -------------  ----------------------------------------------------  ---------
RDM-TEST-VMFS  5596aee8-ae391514-0cbd-000c296f569c              0  naa.600a09803830352d687b473155367f69                  1

NetApp explain that if you remove the vendor ID information from the NAA address then you are left with a hexadecimal string that when converted to ASCII will be the LUN serial number.

With this example address naa.600a09803830352d687b473155367f69, the highlighted part is the hex string, whilst 600a0980 is the vendor ID. 3830352d687b473155367f69 in ASCII is 805-h{G1U6⌂i, which is the serial number for this LUN.

For convenience we can use PowerShell to do the conversion for us, using the following code:

$hex = Read-Host "Enter NAA Address";
$hex = $hex.substring(12);
$hex -split '(..)' | ? { $_ }| FOREACH {WRITE-HOST -object ( [CHAR][BYTE]([CONVERT]::toint16($_,16))) -nonewline }; write-host " ";

Ran as a script, this takes the NAA address as an input, strips out the vendor ID and converts the remainder to ASCII. Credit to this article for most of the conversion code.

This results in:

Potentially useful as a vSphere admin when talking to the storage guys!

If you’re interested in setting up your own NetApp test environment, have a look at this ebook about building your own NetApp ONTAP 9 lab.

Related posts

VMware vSphere Virtual Machine Snapshots Explained

Understanding Type 1 and Type 2 Hypervisors

How to Enable SSH on All ESXi Hosts using PowerCLI

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Read More