IBM AIX VIO server: diskinfo script to rebuild disk mappings
On the VIO server, as root/oem_setup_env place the script in /usr/ios/utils. Alternativly you can place the script in another directory and link to it from /usr/ios/utils.
This script also requires that a few additional commands be given to the padmin user id:
Add the following symbolic links in /usr/ios/utils directory.
cut -> /usr/bin/cut
tr -> /usr/bin/tr
Place the following code into the main script – diskinfo is what I’ve called it.
hostname=$(ioscli hostname)
mapall=$(ioscli lsmap -all -type disk -field backing vtd |cut -c 22- | sed 's/^$/:/' |tr '\n' ' ')
for disk in $(ioscli lsdev -type disk |grep -v "Virtual Target Device" |grep -v ^name |awk '{print $1}')
do
presentedas=unpresented
vhostadapter=novhost
wwn=WWNNOTAPPLICABLE
disksn=NONE
parent1=$(ioscli lsdev -dev $disk -parent |tail +3)
parent2=$(ioscli lsdev -dev $parent1 -parent |tail +3)
echo $parent2 |grep -q ^pci
if [ $? == 1 ]; then
wwn=$(ioscli lsdev -dev $parent2 -vpd |grep "Network Address" \
|awk -F. '{print $NF}')
disksn=$(ioscli lsdev -dev $disk -vpd | awk '/Z1/ { print substr($2,length($2)-3,4)}')
disksize=$(ioscli lspv -size $disk)
fi
presentedas=$(echo $mapall |tr ':' '\n' |grep "$disk "|awk '{print $2}')
if [ ! -z $presentedas ];then
vhostadapter=$(ioscli lsdev -dev $presentedas -parent |grep ^v)
else
presentedas=unpresented
vhostadapter=novhost
fi
echo $hostname,$wwn,$parent1:$parent2,$disksn,$disk,$disksize,$vhostadapter,$presentedas
done
As the standard padmin user id, run ‘diskinfo’ or whatever you have called the script.
hostname,primary_wwn,adapter_name,hdisk,size,vhost,device
myvio01,10000000D999D999,fscsi0:fcs0,E1E1,hdisk99,25000,vhost1,mylpar01
Now you may have noticed the WWNNOTAPPLICABLE, … as is the case in some instances, if you have asymmetrical presentation, eg 10 disks on one vio and 8 on another… the hdisk#’s can get out of sync between the two VIOs.
A workaround I have been using is to create dummy disks as filers, so the same mkvdev commands can be run on both VIO servers….
This script presumes that you have defined a device label during the creation of the VTD eg. mylpar01 in the following line.
mkvdev -vdev hdisk99 -vadapter vhost1 -dev mylpar01
This script looks like it can be refined and made much faster, but keep in mind that this script is written to run as the padmin user id and not root. The padmin account has many restrictions, and writing out files for use in scripts is one of them.
I have attempted to make the script run as quickly as possible by working on the outputs stored in variables.
What I have been doing is running this script, then using excel, data>import data>import data, and selecting the text file containing the output of the above script.
Then using the following excel command to build the mkvdev commands to rebuild.
=CONCATENATE(“mkvdev -vdev “,F2,” -vadapter “,G2,” -dev “,H2)
Hope this helps someone
- Posted by admin at 03:43 pm
- Permalink for this entry
- Filed under: Uncategorized
- RSS comments feed of this entry
- TrackBack URI
No comments
Leave a comment