앞장에서 FCP 영역에 대한 SCSI 디스크들을 모두 Remove 했다면.. 그와 관련된 FCP 디바이스들에 대한

Sysfs들 모두를 Remove 해줄 필요도 있다...굳이 재부팅 하지 않아도 된다는...^^

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

#!/bin/sh
#
# ------------------------------------------------------------------
# | REMOVES ALL ZFCP-RELATED SYSFS ENTRIES |
# | |
# | Author: Marc Beyerle (marc.beyerle@de.ibm.com), 12/12/2008 |
# | Copyright IBM Corp. 2008 |
# ------------------------------------------------------------------

SYSFS_DIRECTORY="/sys/bus/ccw/drivers/zfcp"

if [ -e "${SYSFS_DIRECTORY}" ]; then
 
   # change to the sysfs directory containing all zfcp adapters
     cd "${SYSFS_DIRECTORY}"
 
 # find all zfcp adapters
   ADAPTERS=$(find . -maxdepth 1 -name "0.0.*" | cut -c 3-)
else
   # the sysfs directory for the zfcp adapters does not exist
   ADAPTERS=""
fi

if [ -z "${ADAPTERS}" ]; then
   # print information
   echo -e "\nNo zfcp adapters found."
fi

# iterate over all zfcp adapters found
for ADAPTER in ${ADAPTERS}; do
    # change to this zfcp adapter's directory
    cd "${SYSFS_DIRECTORY}/${ADAPTER}"

# print information
echo -e "\nNow removing all sysfs entries of zfcp adapter ${ADAPTER}."

# find all wwpns of this zfcp adapter
WWPNS=$(find . -maxdepth 1 -name "0x*" | cut -c 3-)

if [ -z "${WWPNS}" ]; then
   # print information
   echo "No WWPNs found for zfcp adapter ${ADAPTER}."
fi

# iterate over all wwpns found
for WWPN in ${WWPNS}; do
   # change to this wwpn's directory
cd "${SYSFS_DIRECTORY}/${ADAPTER}/${WWPN}"

# find all luns of this wwpn
LUNS=$(find . -maxdepth 1 -name "0x*" | cut -c 3-)

if [ -z "${LUNS}" ]; then
   # print information
   echo "No LUNs found for WWPN ${WWPN}."
fi

# iterate over all luns found
for LUN in ${LUNS}; do
   # print information
   echo -n "Removing LUN ${LUN}... "

# remove this lun
echo ${LUN} > unit_remove

 if [ "${?}" -eq "0" ]; then
    # print success message (otherwise the error is printed above)
    echo "OK"
  fi
done

# change (again) to this zfcp adapter's directory
cd "${SYSFS_DIRECTORY}/${ADAPTER}"

# print information
echo -n "Removing WWPN ${WWPN}... "

# remove this wwpn
echo ${WWPN} > port_remove

  if [ "${?}" -eq "0" ]; then
      # print success message (otherwise the error is printed above)
      echo "OK"
  fi
   done
done
# print an empty line
echo
==================================================================

그냥 가져다 써도..잘 작동하네..
신고

+ Recent posts