#!/bin/sh SCRIPT_NAME=$0 if [ $# -lt 2 ]; then cat < EOF exit fi vtd=$1 lun=$2 # Check the vtd if ! lsdev -l $vtd | grep -q "Virtual Target Device"; then echo "$SCRIPT_NAME: The device '$vtd' does not exists or is not a Virtual Target Device" 1>&2 exit 1 fi # Check the lun number lun=$(echo $lun | tr a-f A-F | awk '/0x[0-9A-F]{16}/ {print}') if [ -z "$lun" ]; then echo "$SCRIPT_NAME: Lun must have format "0xNNNNNNNNNNNNNNNN" (16 digits)" 1>&2 exit 1 fi # check that lun changes actual_lun=$(odmget -q "name=$vtd and attribute=LogicalUnitAddr" CuAt| \ sed -n 's/.*value = "\(.*\)"/\1/p' | tr a-f A-F) if [ "$lun" == "$actual_lun" ]; then echo "$SCRIPT_NAME: lun already is $lun for '$vtd'. No change." 1>&2 exit 0 fi # change the lun. # 1. set the VTD to defined # 2. update odm # 4. cfgmgr vadapter vadapter=$(lsdev -Cl $vtd -F parent) echo "Updating the lun of $vadapter.$vtd..." rmdev -l $vtd > /dev/null odmget -q "name=$vtd and attribute=LogicalUnitAddr" CuAt | \ sed "s/value =.*/value = \"$lun\"/" | \ odmchange -q "name=$vtd and attribute=LogicalUnitAddr" -o CuAt cfgmgr -l $vadapter lsattr -El $vtd