The 2 following scripts will list disk mapping on VIOS if you use Virtual SCSI on LPAR. And the second will recreate the disk mapping (will only print the commands to run as padmin after having deleted the VTD that you want to recreate. If you have mismatch on LPAR, with path connected to VTD in bad order (Ex: a disk hdisk0 on LPAR connected on vios1 with VTD address 0x8100000000000000 and on the other vios2 with address 0x8200000000000000). Then first list the mapping on the first vios, and copy the map output to the other vios to remap all disks in the same order using the disk serial number.
Run this script as root (oem_setup_env).
The first script will list all vhost, if no vhost<x> parameter is add, this will order disks in the order of VTD creation, with the disk serial number.
I always use a .env in scripts to set log path
[root@vios1]/home/padmin/scripts# cat .env
# global variables for all scripts export binpath=/home/padmin/scripts export sn=`basename $0 | cut -d. -f1` export HOSTNAME=`/usr/bin/hostname` export logpath=/home/padmin/scripts/log export logname=$logpath/$sn.log export configfile=$binpath/$sn.cfg export destination="test@test.com"
[root@vios1]/home/padmin/scripts# cat list_maps.ksh
#!/bin/ksh #@(#) List all vhost and maps dir=$(dirname $0) . $dir/.env vhost=$1 log_serial=$logpath/list_serial_disk.txt #------------------------------- list_hdisk_serial() { pcmpath query device | egrep "SERIAL|DEVICE" | sed '/DEV/{x;p;x;}' | sed 's/DEV#://g' | sed 's/DEVICE NAME://g' | awk '{print $2}' | sed '/^$/d' | while read word do if [ $(echo $word | grep hdisk > /dev/null 2>&1;echo $?) -eq 0 ] then hd=$word else echo $hd";\c" echo $word fi done } #------------------------------- read_map() { hostid=$1 slot_nbr=$(/usr/ios/cli/ioscli lsmap -vadapter $hostid | grep "vhost" | head -1 | awk '{print $2}' | cut -d'-' -f3) /usr/ios/cli/ioscli lsmap -vadapter $hostid | egrep "VTD|LUN|Backing" | sed 's/Backing//g' | awk '{print $2}' | while read line do echo $line | grep hdisk > /dev/null 2>&1 if [ $? -eq 0 ] then lunid=$(grep "$line;" $log_serial | cut -d";" -f2) echo "$hostid:$hd_id:$vtd:$line:$lunid:$slot_nbr:" else echo $line | grep "000000000000" > /dev/null 2>&1 if [ $? -eq 0 ] then hd_id=$line else vtd=$line fi fi done } ############################### main () { v_host=$1 list_hdisk_serial > $log_serial if [ "$v_host" == "" ] then for host in $(lsdev -C | grep vhost | awk '{print $1}') do read_map $host | sort done else read_map $v_host | sort fi } main $vhost | tee $logname
Run this script as root (oem_setup_env).
This script will generate commands for disk mapping that have to be created as padmin user. This will not do it automatically. Before remap disks, use the command rmvdev -vtd <VTD_name> to delete all VTD that you want to recreate with right ID.
[root@vios1]/home/padmin/scripts# cat recreate_map.ksh
#!/bin/ksh #@(#) Recreate padmin command to create maps # The reference file is the map from existing host or another host: /home/script/log/list_map.log # If you want to generate the command for map from another host, please change the name to have the correct reference file #set -x dir=$(dirname $0) . $dir/.env ref_file=$logpath/list_maps.log log_serial=$logpath/list_serial_disk.txt #------------------------------- list_hdisk_serial() { pcmpath query device | egrep "SERIAL|DEVICE" | sed '/DEV/{x;p;x;}' | sed 's/DEV#://g' | sed 's/DEVICE NAME://g' | awk '{print $2}' | sed '/^$/d' | while read word do if [ $(echo $word | grep hdisk > /dev/null 2>&1;echo $?) -eq 0 ] then hd=$word else echo $hd";\c" echo $word fi done } test ! -e $ref_file && echo "ERROR: The map file $ref_file doesn't exist" && exit 1 echo "Are you sure you want to use the map file: " ls -l $ref_file echo "[y or n]" read answer if [ "$answer" != "y" ] then exit 0 fi # Generate disk serial number list list_hdisk_serial > $log_serial for line in $(cat $ref_file) do vhost=$(echo $line | cut -d':' -f1) vtd=$(echo $line | cut -d':' -f3) lunid=$(echo $line | cut -d':' -f5) hd=$(echo $line | cut -d':' -f4) hdnew=$(grep ";$lunid" $log_serial | cut -d';' -f1) echo " mkvdev -f -vdev $hdnew -vadapter $vhost -dev $vtd" done echo "\nNow you can copy/paste directly this VIOS as padmin user"
I use the following script to check if path are set in the same order on dual VIOS servers. This script runs on LPARs with VSCSI adapters. Without argument, it will print only errors, with -v verbose mode with full output. I use dsh command from NIM to run it in parallel on all LPARs.
root@nim - /root/scripts > cat show_path_mismatch.sh
#!/usr/bin/ksh #set -x ############################################# #@(#) Check if path are correctly set on VIOS ############################################# # check if a disk on LPAR has the same path # ID on both VIOS # version 1.0 2-10-2012 Manu ############################################# dir=`dirname $0` . $dir/.env #------------------------------------------------ # usage () #------------------------------------------------ usage() { rep=$* case "$rep" in * ) echo "Usage: "$0 echo "\tNo parameter required" echo "\tOption -v verbose" echo "\tCheck virtual disk address on each path print an error if the paths have different connection address" exit 1 ;; esac } #------------------------------------------------ # dmsg () #------------------------------------------------ dmsg() { if [ $debug == "yes" ] then echo "$1" fi } #------------------------------------------------ # check_path () #------------------------------------------------ check_path() { hdisk=$1 VSCSI0=`lspath -l $hdisk -F"parent" | head -1` VSCSI1=`lspath -l $hdisk -F"parent" | tail -1` if [[ "$VSCSI0" == "$VSCSI1" ]] then echo $hdisk: type=$(lsattr -El sys0 -a modelname | cut -d " " -f2 | sed 's/IBM,//g') if [[ "$type" == "8406-70Y" ]] then echo "******** $hdisk single path disk on IVM *********" else echo "******** ERROR $hdisk single path disk on dual VIOS Server *********" fi else CONNECT0=`odmget -q "name=$hdisk and parent=$VSCSI0 and path_status=1" CuPath | grep connection | awk '{print $3}'` PRIO0=`lspath -AEH -l $hdisk -p $VSCSI0 | grep priority | awk '{print $2}'` CONNECT1=`odmget -q "name=$hdisk and parent=$VSCSI1 and path_status=1" CuPath | grep connection | awk '{print $3}'` PRIO1=`lspath -AEH -l $hdisk -p $VSCSI1 | grep priority | awk '{print $2}'` if [[ "$CONNECT0" != "$CONNECT1" ]] then echo $hdisk: echo "******** ERROR on disk $hdisk paths missmatch on the 2 VIOS *********" dmsg "vscsi= $VSCSI0 connection= $CONNECT0 priority= $PRIO0 " dmsg "vscsi= $VSCSI1 connection= $CONNECT1 priority= $PRIO1 " echo "########################" else dmsg "$hdisk:" dmsg "vscsi= $VSCSI0 connection= $CONNECT0 priority= $PRIO0 " dmsg "vscsi= $VSCSI1 connection= $CONNECT1 priority= $PRIO1 " dmsg "########################" fi fi } ########################################################################### # main () # # Check if a disk is mapped on both VIOS with the same adress 0x8100000000000000 # #root@nim]/root# ssh padmin@vio1 ioscli lsmap -vadapter vhost3 #SVSA Physloc Client Partition ID #--------------- -------------------------------------------- ------------------ #vhost3 U9117.MMA.10579F0-V1-C16 0x00000006 # #VTD vtscsi3 #Status Available #LUN 0x8100000000000000 # ########################################################################### main () { debug=no while [ $# -gt 0 ] do case "$1" in -v) debug=yes ;; -h|help) usage exit 1;; esac shift done dmsg "`date` : Begin of $sn $(hostname)" dmsg "########################" for HDISK in $(lsdev -Cc disk | grep "Virtual" | awk '{print $1}') do check_path $HDISK done dmsg "`date` : Begin of $sn $(hostname)" } main $* 2>&1 | tee $logname