QNAPedia Community Wiki

Skip to content

Category:How to support AIX with NAS iSCSI function

From QNAPedia

Jump to: navigation, search

To support IBM AIX system with NAS iSCSI function, please upgrade to 3.4.1 or later version and add the script in the AIX manually. The content below is the scripts for creating a iscsi disk with IBM AIX unix and the recover script.

Change files:

mkiscsi.ksh
recover_iscsi_disk.ksh

cat mkiscsi.ksh
#!/bin/ksh93
################################################################################
# Versie 1.0 11-mar-2011 C.S. #
# Script: create a Qnap iscsi disk under AIX #
# #
# #
################################################################################

  1. System variables
    ENV=$HOME/.kshrc
    PATH=$PATH:/usr/local/bin:/usr/local/etc
    export ENV PATH DSHPATH
  1. Script variables
    datum=`date +%T_%m_%d_%y`
  1. Debugging on/off
    # set -x

print '========= configuring iSCSI qnap disk now ========='
echo \\n

userid=`id |awk '{print $1}'`

case ${userid} in

"uid=0(root)") echo "lun id example: iqn.2004-04.com.qnap:ts-459:iscsi.aix53lun.c564e5 "
print 'copy and paste your Qnap lun id here: \c'
read lunid
headlunid=`echo ${lunid} | awk 'FS="."{print$1}'`

echo \\n

print 'what is the ip address of your Qnap nas: \c'
read ipaddr
echo \\n

case ${headlunid} in

iqn) echo "lun id is "${lunid}
echo "ip address is "${ipaddr}
print 'is this correct ? <y/n> : \c'
read answer
case ${answer} in
y) echo "Script appends now >" ${ipaddr} "3260" ${lunid} "< to /etc/iscsi/targets"
echo ${ipaddr} "3260" ${lunid} >> /etc/iscsi/targets
echo \\n
echo " setting inatiator name to iqn.2004-04.com.qnap.ibm:aix-rtp.00000000 "
chdev -l iscsi0 -a initiator_name=iqn.2004-04.com.qnap.ibm:aix-rtp.00000000

echo " running config manager for iscsi0 device"
cfgmgr -v -l iscsi0
lsdev -Cc disk |grep iSCSI
if [ $? -ne 0 ]
then
echo \\n
echo \\n
echo " No valid iSCSI disk found !"
echo " check ip address and lun id again and rerun this script "
exit 1
fi

hdisk=`lsdev -Cc disk |grep iSCSI |awk '{ print $1 }'`

echo " now have new iscsi disk "${hdisk} "available"
sleep 5
echo \\n
lsattr -EHl ${hdisk}
echo \\n


  1. to clear pv identifier uncommend line below
    #chdev -l ${hdisk} -a pv=clear

lspv |grep ${hdisk}
sleep 5
# if existing vg identifier exists try to get it form disk
chdev -l ${hdisk} -a pv=yes
sleep 5
# set new que depth to disk
lspv |grep ${hdisk}
chdev -l ${disk} -a queue_depth=64 ;;

  • ) echo "aborting"
    exit 1;;
    esac;;
  • ) echo "not a valid lunid should start with iqn.xxxx.xxxxx.xxxx:xxxx "
    exit 1;;
    esac;;
  • ) echo "please run this script as root user ! now running with "${userid}
    exit 1;;

esac


==================================================================

Below the recover script:

cat recover_iscsi_disk.ksh


#!/bin/ksh93
# set -x
################################################################################
# Versie 1.0 11-mar-2011 C.S. #
# Script: repair script to get Qnap iscsi disk online again. #
# and to get disk with pvid back #
################################################################################

cfgmgr -l iscsi0

lsdev -Cc disk |grep iSCSI

hdisk=`lsdev -Cc disk |grep iSCSI |awk '{ print $1 }'`

  1. repeat the dd command serveral times until it is reading.

while true
do
dd if=/dev/${hdisk} count=1000 of=/dev/null
if [ $? -ne 0 ]
then
echo \\n
echo "The disk "${disk} "is not readable"
print 'try again ? <y/n> : \c'
read answer
case ${answer} in
y) echo "try again now";;


  • ) exit 1;;
    esac
    else
    echo "The disk " ${disk} "is now readable again"
    chdev -l ${hdisk} -a pv=yes
    lspv |grep ${hdisk}
    exit 0
    fi
    done

===================================================

This category currently contains no pages or media.

Personal tools
Language