ADVERTISE HERE

Script to Rescan HBA and iSCSI Adapters

Title: Script to Rescan HBA and iSCSI Adapters
Author(s): Xtravirt (Paul Davey)
Target Audience: Technical - Novice
Current Revision: 1.0 April 2008
First Published: 1 April 2008
Products: VMware ESX, Perl
UID: XD10067
Information
Title: 
Script to Rescan HBA and iSCSI Adapters
Author(s): 
Xtravirt (Paul Davey)
Target Audience: 
Technical - Novice
First Published: 
1 April 2008
Products: 
VMware ESX, Perl
UID: 
XD10067

A script to rescan HBA and iSCSI adapters in an ESX host

1.0 Overview

Here's a useful script to rescan ESX host LUN's or iSCSI targets that you could schedule as needed.

#!/usr/bin/perl -w
#Filename: rescan-hbas.pl
#No warranty is provided with this script

use strict;
my @hbas = `/usr/sbin/esxcfg-info \| grep vmkernel -i \| grep hba \| awk -F\. \{\'print \$29\'\}`;
print "The following HBAs were detected on this system:\n";
print "\t@hbas";
foreach my $hba (@hbas) {
system("/usr/sbin/esxcfg-rescan $hba");
}
print "Checking to see if SW iSCSI is in use....";
my $iscsi = `/usr/sbin/esxcfg-swiscsi -q`;
chomp ($iscsi);
print "$iscsi\n";
if ($iscsi eq "Software iSCSI is enabled") {
system("/usr/sbin/esxcfg-swiscsi -s")
}

References
References: 
  1. Nil
References
  1. Nil
Tags
HBA
iSCSI
perl
Rescan
script
Storage
Storage

Spotlight:

VMware Documentation Downloader v11.08.30

Updated for vSphere 5 - A free tool for those on the move who need information FAST

vSphere 5 License Entitlement Changes

See what has changed in the license entitlement in vSphere 5?

Thin Client vs Zero Client

The differences between Thin and Zero desktop clients for VDI

Technology Exchange: