Tag Archives: LUN

Retrieving SCSI/LUN IDs from Linux /dev/sd*

Useful to identify disks present before/after a rescan of LUNs:-

for x in `ls -1 /dev/sd*`; do echo -n "$x:"; sudo /sbin/scsi_id -g $x; done > file.txt

The output is then in the format:-


Capture output before/after rescan of SCSI bus then use something like this to reveal the newly added LUNs (SCSI IDs):-

sdiff prescan.txt postscan.txt | grep ">"  | awk '{ print $2 }' | cut -d":" -f2 | sort -n | uniq

Correlate devices and LUNs with powerpath pseudo-devices

Quick bash snippet to list powerpath pseudo-devices, LUNs and underlying devices.  This takes the raw output of ‘powermt display dev-all’ and massages it into a parseable list:-


Pseudo name=emcpowera
Symmetrix ID=000192600720
Logical device ID=047C
Device WWN=60000970000192600720533030343743
state=alive; policy=SymmOpt; queued-IOs=0
--------------- Host ---------------   - Stor -  -- I/O Path --   -- Stats ---
###  HW Path               I/O Paths    Interf.  Mode     State   Q-IOs Errors
   3 lpfc                   sdadq      FA 10f:00 active   alive      0      0
   1 lpfc                   sdrj       FA 12f:00 active   alive      0      0
   0 lpfc                   sdaw       FA  5f:00 active   alive      0      0


emcpowera 60000970000192600720533030343743 sdadq sdrj sdaw

Note: the sed may need to be adjusted to to match your storage solution / HW Path.

for field in $(sudo powermt display dev=all | egrep "Pseudo|lpfc|WWN" | awk '{ print $2" "$3 }' | cut -d"=" -f2 | sed 's/lpfc //g'); do
    if [[ $field = "emcpower"* ]]; then
      echo -en "\n$field "
      echo -n "$field ";