Thursday, July 24, 2014

How to find fiber channel ID (WWN) of a LUN & how to scan new SAN LUN in Linux

type the following command to get the fiber channel address of the HBA card:
# systool -c fc_host -v

#cat /sys/class/fc_host/host?/port_name 

#cat /sys/class/scsi_host/host*/device/fc_host\:host*/port_name

type the following command to get the fiber channel target WWN:
# systool -c fc_transport -v

WWN info
=========
Acquire the WWNs (World Wide Names) of HBAs. The SAN team need to know these so that they can configure the storage correctly. 
Only two of the four ports will be used.As root, enter the following command:

e.g.
# cat /sys/class/scsi_host/host*/device/fc_host\:host*/port_name
0x10000000c9c44786
0x10000000c9c44797
0x10000000c9c4428e
0x10000000c9c4458f

You can send the above output to SAN team.

************************************************************************************************************
Scanning an operating system device after adding or removing LUNs
=======================================================

After you add or remove LUNs, scan the operating system device tree to verify that the operation completed successfully.

Linux provides several methods for rescanning the SCSI bus and identifying the devices mapped to it. These methods include the following:

The SCSI scan function in the /sys directory

HBA vendor utilities

To scan using the SCSI scan function
=============================

Enter the following command:

# echo '- - -' > /sys/class/scsi_host/host$i/scan

where the three dashes refer to the channel, target, and LUN numbers, and host$i is the host bus adapter instance. This example scans every channel, target, and LUN visible via this host bus adapter instance.


To scan using HBA vendor utilities
===========================

Follow the vendor's instructions for the HBA utility. Examples include the following:

QLogic provides a script that dynamically scans for newly-added LUNs. You can download it from the QLogic Web site. To run the script, enter the following command:

# ./ql-dynamic-tgt-lun-disc.sh

Emulex provides an HBAnywhere script. You can download it from the Emulex web site. The script has a LUN Scan Utility that dynamically scans for newly-added LUNs. also Emulex Linux LUN/target scan script enables you to dynamically (without a reboot, driver unload/reload, or HBA reset) discover new targets and LUNs (on new or existing targets) that have come online. This feature is supported via standard Linux mechanisms. The script enables you to automatically discover all new devices.To run the utility, enter the following command:

# lun_scan all

ql-dynamic-tgt-lun-disc.sh :
http://driverdownloads.qlogic.com/QLogicDriverDownloads_UI/ResourceByOS.aspx?productid=924&oemid=65&oemcatid=58604

lun_scan.sh: 
http://www.emulex.com/files/downloads/linux/linux_tools.html




************************************************************************************************************

Manually scan HBAs for Qlogic
========================

# echo "scsi-qlascan" > /proc/scsi/qla2300/0
# cat /proc/scsi/qla2300/0

Manually scan HBAs for Emulex
=========================

echo "- - -" > /sys/class/scsi_host/host0/scan
echo "- - -" > /sys/class/scsi_host/host1/scan
echo "- - -" > /sys/class/scsi_host/host2/scan
echo "- - -" > /sys/class/scsi_host/host3/scan

Further ports can be scanned using “host4” and so on.

************************************************************************************************************

for HBA Emulex or Qlogic
====================

If the server has Emulex HBAs you will see output similar to the below from the lspci command:

0e:00.0 Fibre Channel: Emulex Corporation Zephyr-X LightPulse Fibre Channel Host Adapter (rev 02)
0e:00.1 Fibre Channel: Emulex Corporation Zephyr-X LightPulse Fibre Channel Host Adapter (rev 02)
18:00.0 Fibre Channel: Emulex Corporation Zephyr-X LightPulse Fibre Channel Host Adapter (rev 02)
18:00.1 Fibre Channel: Emulex Corporation Zephyr-X LightPulse Fibre Channel Host Adapter (rev 02)

Or, if the server is using Qlogic HBAs:

10:00.0 Fibre Channel:QLogic Corp.ISP2432-based 4Gb Fibre Channel to PCI Express HBA (rev 03)
10:00.1 Fibre Channel:QLogic Corp.ISP2432-based 4Gb Fibre Channel to PCI Express HBA (rev 03)

Use the lsmod command to see if the kernel module is already loaded (to determine which driver is in use). If the server has Emulex cards the following command can be used:

lsmod |grep lpfc

You will see output similar to the below if the kernel module is loaded:

lpfc                  515109  10
scsi_transport_fc      83145  1 lpfc
scsi_mod              199001  14 

be2iscsi,ib_iser,iscsi_tcp,bnx2i,cxgb3i,libiscsi2,scsi_transport_iscsi2,scsi_dh,sg,usb_storage,lpfc,scsi_transport_fc,cciss,sd_mod

or if Qlogic cards are installed type:

lsmod |grep qla

Make sure the modprobe.conf file is configured with the correct alias for the HBA. For Emulex HBAs you should see:

alias scsi_hostadapterX lpfc

Or if the server is using Qlogic cards:

alias scsi_hostadapterX qla2xxx

Where scsi_hostadapterX is the next number after the last entry. The module name should be qla2xxx, qla2300, or qla4010 

depending on model of HBA.
************************************************************************************************************

3 comments:

TCP/UDP Protocols/Prots & important port numbers in Linux OS

TCP/UDP Protocols/Ports are ranging from 0-65535 so total we have 65536 ports & because of the limitation in TCP/IP stack where the por...