Monday, May 11, 2009

Setup SAN presentation on Linux

The steps below are to scan for new LUNs from a SAN after the LUNs have been presented from the storage side when using QLogic HBA's . This post uses the QLogic Dynamic Target and LUN Discovery utilities which can be downloaded from:

http://driverdownloads.qlogic.com/QLogicDriverDownloads_UI/SearchByProduct.aspx?ProductCategory=39&Product=935&Os=126

The steps below will work on SUSE Linux Enterprise Server (SLES) 10 and Red Hat Enterprise Linux (RHEL) 5.
You can discover what version of Linux you are on by running:

cat /etc/*ease

Create a directory to hold the utilites. In this examle we will use the /tmp/ql_utils directory:

mkdir /tmp/ql_utils

Change to the /tmp/ql_utils directory:

cd /tmp/ql_utils

Retrieve the utilities from the download above and extract them from the zip file into the /tmp/ql_utils directory.
This will put five files into /tmp/ql_utils:

ql-dynamic-tgt-lun-disc.sh
README.ql-dynamic-tgt-lun-disc.txt
Copying
revision.qldynamic.txt
sg3_utils-1.23.tgz

The file that we are going to be using is the ql-dynamic-tgt-lun-disc.sh file. We need to ensure that it is set to executable:

chmod a+x /tmp/ql_utils/ql-dynamic-tgt-lun-disc.sh


The ql-dynamic-tgt-lun-disc.sh script has several options available. You can see what these options are by running:

/tmp/ql_utils/ql-dynamic-tgt-lun-disc.sh -h

The commands to scan for new LUNs are listed below. After the commands we'll describe what each command does. These commands should be run with root priveledges while inside the /tmp/ql_utils directory.

powermt display dev=all | egrep "Pseudo|Logical" > before
./ql-dynamic-tgt-lun-disc.sh
Please make sure there is no active I/O before running this script
Do you want to continue: (yes/no)? yes
powermt config
powermt display dev=all | egrep "Pseudo|Logical" > after
diff after before
powermt save

The first line outputs the current list of LUNs to the file named before. This is optional, but, makes it easy to see what new LUNs have been discovered later on.
The second line actually does the scan for new LUNs and prompts you to make sure that it's ok to run the script. Answer yes to the prompt.
The fifth line (powermt config) creates the emcpower devices in /dev.
The sixth line outputs the new list of LUNs to the file named after.
The seventh line runs a command to compare the list of new LUNs to the list of old LUNs. The differences will be displayed on screen. Make sure that names of the new LUNs show up in the output.
The last line saves the configuration.

After this is done, the LUNs can be setup with LVM. (see LVM post)