Show all LUN’s on RHEL 6.5

Posted by ronald on april 29, 2015 in RHEL |

Logon as root

 

Create a script called showluns

#!/bin/bash
echo “pvscan…”
pvscan > /tmp/pvscan.out
echo “collecting mpaths”
mpathlist=$(multipath -ll -v 1 | sort)
echo “”
for mpath in $mpathlist
do
multipath -l $mpath > /tmp/multipath.$mpath.out
size=$(cat /tmp/multipath.$mpath.out | grep “size=” | awk ‘{print $1 }’ | sed “s/size=//g”)
lunid=$(cat /tmp/multipath.$mpath.out | head -n 1 | awk ‘{print $2 }’ | tr -d ‘)’ | tr -d ‘(‘ )
vgname=$(grep -w /dev/mapper/$mpath /tmp/pvscan.out | grep -w VG | awk ‘{ print $4 }’)
ispv=$(grep -w /dev/mapper/$mpath /tmp/pvscan.out | grep -w PV | awk ‘{ print $4 }’)

if [ -z “$vgname” ]

then

if [ -z “$ispv” ]

then

vgname=”FREE”

else

vgname=”FREE PV”

fi

fi

echo “$mpath $lunid $size $vgname ”
rm -f  /tmp/multipath.$mpath.out
done

Copyright © 2012-2018 Dutch Ronaldo All rights reserved.
This site is using the Desk Mess Mirrored theme, v2.5, from BuyNowShop.com.