===== List disk UUID on AIX =====
The command switch displays unique id of disks (UDID) and does the same job as the code I was using before, but in a more handy way.
Now simple commands
# lspv -u
hdisk0 00f992d442626fae old_rootvg 33213600507680XXXXXXXXX0000000000080E04214503IBMfcp 5fe2b852-5734-bdec-35e4-2d282e6b4380
hdisk1 00f992d443278dcf nimavg active 33213600507680XXXXXXXXX0000000000080F04214503IBMfcp f464df3f-48ac-baa1-be03-74832653707e
Friendly name based on LUN names on storage IBM
# lsmpio -q
Device Vendor Id Product Id Size Volume Name
---------------------------------------------------------------------------------
hdisk0 IBM 2145 40.00GiB AIXNA001_ROOTVG
hdisk1 IBM 2145 1.12TiB AIXNA001_NIMAVG01
lsdev -Cc disk -F name | while read hdisk
do
echo ${hdisk},$(odmget -q "name=${hdisk} and attribute=unique_id" CuAt|grep value|cut -d '"' -f2)
done
UDID is build up using a certain logic. I haven't seen the code, but some of the interesting parts are easy to spot:
unique_id attribute of an SAS attached hdisk is 2A1135000C500337924AB0BST9146852SS03IBMsas. This ID contains WWNN of the SAS controller (00C500337924AB), disk vendor (IBM), connection type (sas), and also disk model ST9146852SS, which is 146,8GB SAS.
unique ID of a logical volume is VGID.sequence_number. For example ID of a third logical volume in a specific VG is 00cc572600004c00000001325d0ab9bd.3.
A few examples of lspv -u outputs with comments on UDID:
Locally attached SAS disk
hdisk0 00cc57264df9dc6b rootvg active 2A1135000C500238633030BST9146852SS03IBMsas
virtual disk connected via virtual scsi, backed by SAS disk.
hdisk28 00cc572646f271f9 none 3F2A2A1135000C500337924AB0BST9146852SS03IBMsas05VDASD03AIXvscsi
virtual disk connected via virtual scsi, backed by logical volume. Logical volume ID can by identified by a period.
hdisk0 00cc57265d4534bd rootvg active 372200cc572600004c00000001325d0ab9bd.205VDASD03AIXvscsi
SAN disk attached via physical or virtual FC. The disk comes from a DS8100 disk array identified as 75BBXM1. Volume ID of the disk in DS8100 is 180D.
hdisk39 00cc5726aaa9e19e testvg active 200B75BBXM1180D07210790003IBMfcp
virtual disk connected via virtual scsi, backed by SAN disk. The disk comes from a DS8300 disk array identified as 75YY981. Volume ID of the disk in DS8300 is 0501.
hdisk2 00cc57260b6d4ca6 rootvg active 3520200B75YY981050107210790003IBMfcp05VDASD03AIXvscsi
Examples of UUID:
**DS8000:** through VIOS
^virtual prefix^storage^storage serial^LUN ID^xx^type^xx^vendor^type^xx^virtual^
|3520|200B|75YY981|0501|07|2107|90003|IBM|fcp|05VDASD03|AIXvscsi|
**V3000/V7000/SVC:** native with SDDPCM
^storage^LUN serial^xx^type^xx^vendor^type^
|33213|60050768018087388000000000000114|04|2145|03|IBM|fcp|
**SAS disk:** native SAS
^storage^xx^vendor^xx^type^
|2D11|3500000394980B406009MBF2300RC08|IBM|-ESXS|sas|
===== Script to list disks serial number =====
pcmpathq ()
{
# version 1.1 02/2016
verbose=$1 # -v for friendly format, default is comma separated
if [ "$verbose" == "-v" ]
then
printf "#########################################################################################################################\n"
printf "%-15s %-25s %-15s %-15s %-30s %-10s\n" '#'HDISK PVID VG MANUFACTURER SORAGE-DISK_SERIAL TYPE
printf "#########################################################################################################################\n"
fi
for line in $(lspv -u | sed 's/\ /;/g')
do
typeset -Z4 diskid
hdisk=$(echo $line | sed 's/;/\ /g' | awk '{print $1}')
pvid=$(echo $line | sed 's/;/\ /g' | awk '{print $2}')
vg=$(echo $line | sed 's/;/\ /g' | awk '{print $3}')
diskfull=$(echo $line | cut -c80- | sed 's/;/\ /g' | rev | awk '{print $2,$3,$4,$5}' | rev | sed 's/\ //g')
endline=$(echo $diskfull | sed 's/[0-9]/\ /g' | rev | awk '{print $1}' | rev)
if [ $(echo $endline | grep vscsi > /dev/null; echo $?) -eq 0 ]
then
type=vscsi
if [ $(echo $diskfull | grep "NVDISK" > /dev/null; echo $?) -eq 0 ]
then
diskfull=$(echo $diskfull | cut -c6-51)
else
diskfull=$(echo $diskfull | cut -c9- | sed 's/fcp/\ /' | awk '{print $1}')
fi
else
if [ $(echo $endline) == "IBMsas" ]
then
type=sas
else
type=fcp
diskfull=$(echo $diskfull | cut -c5- | sed 's/fcp/\ /' | awk '{print $1}')
fi
fi
manufacturer=$(echo $diskfull | rev | sed 's/[0-9]/\ /g' | awk '{print $1}' | rev)
if [ "$manufacturer" == "HITACHI" ]
then
serial=$(echo $diskfull | cut -c1-8)
hexadiskid=$(echo $diskfull | cut -c9-12)
diskid=$(printf "%d\n" 0x$hexadiskid)
else
if [ "$manufacturer" == "IBM" ]
then
if [ $(echo $diskfull | sed 's/IBM/\ /' | awk '{print $1}' | rev | cut -c3-10 | rev | grep -q '2145';echo $?) -eq 0 ]
then
# for SVC, V3k, V7k
serial=$(echo $diskfull | cut -c2-33)
diskid=""
if [ $(echo $diskfull | sed 's/IBM/\ /' | awk '{print $1}' | rev | cut -c3-10 | rev | grep -q '2107';echo $?) -eq 0 ]
then
# For DS8k serial: cut -c1-7 diskid: -c8-11
serial=$(echo $diskfull | cut -c1-4)
diskid=$(echo $diskfull | cut -c9-13)
else
typeset -Z9 diskid
serial="IBM"
diskid="Unknown"
fi
fi
else
typeset -Z2 diskid
if [ "$manufacturer" == "DataCore" ]
then
serial=$(lscfg -vpl $hdisk | grep "Device Specific" | grep "(Z0)" | sed 's/\./\ /g' | rev | awk '{print $1}' | rev)
diskid="NA"
else
if [ "$manufacturer" == "NVDISK" ]
then
serial=$(echo $diskfull | cut -c1-32 | tr 'A-Z' 'a-z')
diskid=""
else
serial="NA"
diskid="NA"
fi
fi
fi
fi
if [ "$verbose" == "-v" ]
then
printf "%-15s %-25s %-15s %-15s %-30s %-10s\n" $hdisk $pvid $vg $manufacturer "$serial $diskid" $type
else
echo $hdisk";"$pvid";"$vg";"$manufacturer";"${serial}${diskid}";"$type | sed 's/\ //g'
fi
done
}