Quick way of balancing fixed paths for multiple LUNs in ESXi

#!/bin/ash

for f in `cd /dev/disks ; ls -1 naa* | grep -v :`
do
LUN=`esxcli nmp fixed getpreferred --device $f`
LUNNUM=`echo $LUN | sed s/.*:L//`
if [ $((LUNNUM % 2)) -eq 0 ]; then
NEWLUN=`echo $LUN | sed 's/vmhba1/vmhba0/'`
else
NEWLUN=`echo $LUN | sed 's/vmhba0/vmhba1/'`
fi
esxcli nmp fixed setpreferred --device $f --path $NEWLUN
printf "$NEWLUN $f\n"
done
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: