Pages

Find dead luns PowerPath

This script compares the list of LUNs managed by PowerPath with all storage devices known to AIX. It identifies and prints any “dead” LUNs—devices recognized by the OS but not managed by PowerPath—helping to detect stale or orphaned disks that may require cleanup.

How It Works:
  • powermt check refreshes PowerPath’s internal state.
  • powermt display dev=all lists all active PowerPath devices.
  • lsdev -Cc disk | grep EMC lists all EMC disks AIX knows about.
  • comm -23 compares the two sorted lists and shows the LUNs missing from PowerPath (dead).
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#!/bin/ksh
# ------------------------------------------------------------------------------
# Script Name : find_dead_luns_powermt.ksh
# Purpose     : Identify EMC disks defined in AIX but not managed by PowerPath
# Platform    : AIX
# Author      : Tasleem A Khan
# ------------------------------------------------------------------------------

echo ">>> Running powermt check....................................................................."
powermt check
sleep 2

# Temporary files
POWER=/tmp/power_active.list
DISK=/tmp/aix_defined.list
DEAD=/tmp/dead_luns.list

# Clean up old files
> $POWER
> $DISK
> $DEAD

echo ">>> Collecting active PowerPath LUNs........................................................"
# Extract device names from PowerPath output (e.g., hdiskpowerX)
powermt display dev=all | grep fscsi | awk '{print $3}' | sort -u > $POWER

echo ">>> Collecting all EMC-defined disks from AIX................................................"
# Extract EMC hdisk devices from lsdev
lsdev -Cc disk | grep EMC | awk '{print $1}' | sort -u > $DISK

echo ">>> Comparing AIX-defined EMC disks against PowerPath-managed disks.........................."
# Find disks defined in AIX but missing from PowerPath
comm -23 $DISK $POWER > $DEAD

echo ""
if [ -s $DEAD ]; then
  echo ">>> Dead LUNs detected (present in AIX but not managed by PowerPath):"
  cat $DEAD
  echo ""
  echo "These disks may be stale or unconfigured LUNs no longer visible to PowerPath."
else
  echo ">>> No dead LUNs found — all EMC disks are managed by PowerPath."
fi

echo ""
echo ">>> Summary:"
echo " - Total AIX EMC disks : $(wc -l < $DISK)"
echo " - PowerPath disks     : $(wc -l < $POWER)"
echo " - Dead LUNs detected  : $(wc -l < $DEAD)"

echo ""
echo ">>> Dead LUN discovery complete."
exit 0

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1. Add the above script contents
# vi find_dead_luns_powermt.ksh
2. Make it executable
# chmod +x find_dead_luns_powermt.ksh
3. Run script
# ./find_dead_luns_powermt.ksh
or
# sh find_dead_luns_powermt.ksh

Script Output:

>>> Running powermt check.....................................................................
>>> Collecting active PowerPath LUNs........................................................
>>> Collecting all EMC-defined disks from AIX................................................
>>> Comparing AIX-defined EMC disks against PowerPath-managed disks..........................
>>> Dead LUNs detected (present in AIX but not managed by PowerPath):
hdisk12
hdisk14
These disks may be stale or unconfigured LUNs no longer visible to PowerPath.
>>> Summary:
- Total AIX EMC disks : 16
- PowerPath disks : 14
- Dead LUNs detected : 2
>>> Dead LUN discovery complete.

No comments:

Post a Comment