#!/bin/sh ############################################################################### # # Dell Inc. PROPRIETARY INFORMATION # This software is supplied under the terms of a license agreement or # nondisclosure agreement with Dell Inc. and may not # be copied or disclosed except in accordance with the terms of that # agreement. # # Copyright (c) 2010 Dell Inc. All Rights Reserved. # # Module Name: rescan_dm_devs # Module Version: 14 # Environment: Linux # # Abstract/Purpose: # # Removes LUN0 prior to rescan if not attached to physical disk. # Rescans devices connected to a SAS 6GB/s, iSCSI and fibre channel host adapters. # Aggregates multipath devices. # # # Parameters: # # None. # # # Returns: # # Nothing. # ############################################################################### if [ -e /etc/redhat-release ]; then if [ "$(cat /etc/redhat-release | cut -d" " -f7 | cut -d"." -f1)" -ge 6 ];then ARG1="phy-*"; #DISTRO="RHEL6" elif [ "$(cat /etc/redhat-release | cut -d" " -f7 | cut -d"." -f1)" == "5" ]; then ARG1="port-*"; DISTRO="RHEL5" fi elif [ -e /etc/SuSE-release ]; then ARG1="phy-*"; DISTRO="SLES" fi if [ -d /sys/class/scsi_host ]; then for hostdir in /sys/class/scsi_host/host*; do hostno=${hostdir#/sys/class/scsi_host/host} hostname=`cat $hostdir/proc_name` #SAS LLD if [ $hostname == "mpt2sas" ] || [ $hostname == "mpt3sas" ]; then for ctrlr in $(ls -d /sys/class/scsi_host/host$hostno/device/$ARG1*); do strdel="/sys/class/scsi_host/host$hostno/device/$ARG1?:" ctrlrno=${ctrlr#$strdel} echo "Host adapter $hostname host$hostno controller $ctrlrno found."; result=$(find $ctrlr -type l|grep disk |grep $hostno:0:$ctrlrno:0) rv=$? echo "scanning host $hostno ctrl $ctrlrno result $result" if [ $rv -eq 0 ]; then echo "LUN 0 is mapped to a disk" # temp debug statement else echo "LUN 0 is not mapped to a disk on controller $ctrlrno" echo "scsi remove-single-device $hostname $hostno 0 $ctrlrno 0" $(echo "scsi remove-single-device $hostno 0 $ctrlrno 0" > /proc/scsi/scsi 2>/dev/null) fi echo "rescan the devices on $hostname host$hostno controller $ctrlrno ..."; echo "- - -">/sys/class/scsi_host/host$hostno/scan; sleep 20; echo "Done."; done fi #iSCSI LLD if [ $hostname == "iscsi_tcp" ]; then echo "iscsi host adapter host$hostno found"; result=$(find /sys/class/scsi_host/host$hostno/device/ -type l|grep disk |grep -F $hostno:0:0:0) if [ $? -eq 0 ]; then echo "LUN 0 is mapped to a disk" # temp debug statement else echo "LUN 0 is not mapped to a disk" echo "scsi remove-single-device $hostname $hostno 0 0 0" $(echo "scsi remove-single-device $hostno 0 0 0" > /proc/scsi/scsi 2>/dev/null) fi echo "rescan the devices on host$hostno..."; echo "- - -">/sys/class/scsi_host/host$hostno/scan; sleep 20; echo "Done."; fi done fi #FC LLD if [ -d /sys/class/fc_host ]; then if [ $(find /sys/class/fc_host -type d | wc -l) -gt 0 ]; then for fc_hostdir in $(ls -d /sys/class/fc_host/host*); do fc_hostno=${fc_hostdir#/sys/class/fc_host/host} echo "FC host adapter host$fc_hostno found"; result=$(find /sys/class/scsi_host/host$fc_hostno/device/ -type l|grep disk |grep -F $hostno:0:0:0) if [ $? -eq 0 ]; then echo "LUN 0 is mapped to a disk" # temp debug statement else echo "LUN 0 is not mapped to a disk" echo "scsi remove-single-device $hostname $hostno 0 0 0" $(echo "scsi remove-single-device $fc_hostno 0 0 0" > /proc/scsi/scsi 2>/dev/null) fi echo "rescan the devices on host$fc_hostno..."; echo "- - -" > /sys/class/scsi_host/host$fc_hostno/scan sleep 20 echo "Done."; done fi fi #Now low level scan is done, let's run multipath echo "Aggregating multipathing devices..."; multipath; sleep 20; echo "Done.";