Discovering iSCSI Targets
To determine how local SCSI device names map to iSCSI targets' host IDs and LUNs use the dmesg command:
# dmesg | sort | grep '^Attached scsi disk'
Attached scsi disk sda at scsi0, channel 0, id 0, lun 0
Attached scsi disk sdb at scsi2, channel 0, id 0, lun 0
Attached scsi disk sdc at scsi3, channel 0, id 0, lun 0
Attached scsi disk sdd at scsi1, channel 0, id 0, lun 0
Attached scsi disk sde at scsi4, channel 0, id 0, lun 0

We now have to work out the mapping of iSCSI target names to local SCSI IDs (which gets displayed as HOST ID below), by running the iscsi-ls command on the client (linux1):
# iscsi-ls
Using the mapping information from local SCSI ID to the iSCSI targets' host IDs / LUNs along with the iSCSI targets' name to SCSI ID, we can then generate a full mapping from iSCSI target name to local SCSI device name for the host linux1:
iSCSI Target Name to local SCSI Device Name
iSCSI Target Name ---------------------Host / SCSI ID------------SCSI Device Name
iqn.2006-01.com.openfiler:linx.strg1 ---------- 0 -------------------------- /dev/sda
iqn.2006-01.com.openfiler: linx.strg2 --------- 1 -------------------------- /dev/sdd
iqn.2006-01.com.openfiler: linx.strg3 --------- 2 -------------------------- /dev/sdb
iqn.2006-01.com.openfiler: linx.strg4 --------- 3 -------------------------- /dev/sdc
iqn.2006-01.com.openfiler: linx.strg5 --------- 4 -------------------------- /dev/sde
Create Partitions on iSCSI Volumes
Run the fdisk command from linux1 to create a single primary partition for each of the local SCSI devices identified in the previous section:
/dev/sda
/dev/sdb
/dev/sdc
/dev/sdd
/dev/sde
# ---------------------------------------

# fdisk /dev/sda
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-15134, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-15134, default 15134): 15134

Command (m for help): p

Disk /dev/sda: 124.4 GB, 124486942720 bytes
255 heads, 63 sectors/track, 15134 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 1 15134 121563823+ 83 Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

Do the same for the remaining of the partitions.

After creating all required partitions,we need to label each of the partitions for the purpose to mount on every startup. Because this mapping, however, may change every time the node is rebooted. For example for first iscsi target the mapping was /dev/sda1 and on next boot it could become /dev/sde1. So we need to fix this issue by labeling the disks and putting the entry in the /etc/fstab.

# e2label /dev/sda1 storage11
# e2label /dev/sdb1 storage12
# e2label /dev/sdc1 storage13
# e2label /dev/sdd1 storage14
# e2label /dev/sde1 storage15

Format all the partions as

mkfs.ext3 /dev/sda1
mkfs.ext3 /dev/sdb1
mkfs.ext3 /dev/sdc1
mkfs.ext3 /dev/sdd1
mkfs.ext3 /dev/sde1

NOTE: You can leave the formatting at this stage if you plan to use ASM or OCFS2 file system.

Make five directories in root file system as /u01,/u02,/u03,/u04,/u05

Add entry in the /etc/fstab as
LABEL=storage1 /u01 ext3 _netdev 0 0
LABEL=storage2 /u02 ext3 _netdev 0 0
LABEL=storage3 /u03 ext3 _netdev 0 0
LABEL=storage4 /u04 ext3 _netdev 0 0
LABEL=storage5 /u05 ext3 _netdev 0 0

Check this carefully and reboot the system and you are done with storage drives delivered from network storage system SAN.


FOR LINUX 5 USERS
Installing the iSCSI (initiator) service
perform the following commands on the nodes:
# rpm -qa --queryformat "%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n"| grep iscsi-initiator-utils
If the iscsi-initiator-utils package is not installed, load CD #1 into the nodes and perform the following:
# rpm -Uvh iscsi-initiator-utils-*
Configure the iSCSI (initiator) service
Start the iscsi service and configure to start automatically.

# service iscsid start
Turning off network shutdown. Starting iSCSI daemon: [ OK ]
[ OK ]

# chkconfig iscsid on
# chkconfig iscsi on
Now discover all the iSCSI target by invoking this command.
# iscsiadm -m discovery -t sendtargets -p openfiler1-priv
It will show all the target we configured on open filer.
Manually Log In to iSCSI Targets
We should try to manually login to iscsi targets we had discovered by giving this command.
# iscsiadm -m node -T iqn.2006-01.com.openfiler:linx.strg1 -p (192.168.1.195) -l
# iscsiadm -m node -T iqn.2006-01.com.openfiler:linx.strg2 -p 192.168.1.195 -l
# iscsiadm -m node -T iqn.2006-01.com.openfiler:linx.strg3 -p 192.168.1.195 -l
# iscsiadm -m node -T iqn.2006-01.com.openfiler:linx.strg4 -p 192.168.1.195 -l
# iscsiadm -m node -T iqn.2006-01.com.openfiler:linx.strg5 -p 192.168.1.195 -l
NOTE: the IP 192.168.1.195 is open filer node IP, it could be different in your scenario.
Configure Automatic Log In
The next step is to ensure the client will automatically log in to each of the targets listed above when the machine is booted.
# iscsiadm -m node -T iqn.2006-01.com.openfiler:linx.strg1 -p 192.168.1.195 --op update -n node.startup -v automatic
# iscsiadm -m node -T iqn.2006-01.com.openfiler:linx.strg2 -p 192.168.1.195 --op update -n node.startup -v automatic
# iscsiadm -m node -T iqn.2006-01.com.openfiler:linx.strg3 -p 192.168.1.195 --op update -n node.startup -v automatic
# iscsiadm -m node -T iqn.2006-01.com.openfiler:linx.strg4 -p 192.168.1.195 --op update -n node.startup -v automatic
# iscsiadm -m node -T iqn.2006-01.com.openfiler:linx.strg5 -p 192.168.1.195 --op update -n node.startup -v automatic
Create Persistent Local SCSI Device Names
When the nodes boot and the iSCSI initiator service is started, it will automatically log in to each of the targets configured in a random fashion and map them to the next available local SCSI device name. For example, the target iqn.2006-01.com.openfiler:linx.strg1 may get mapped to /dev/sda. I can actually determine the current mappings for all targets by looking at the /dev/disk/by-path directory:
# (cd /dev/disk/by-path; ls -l *openfiler* | awk '{FS=" "; print $9 " " $10 " " $11}')
we get the result similar to this table:
Current iSCSI Target Name to local SCSI Device Name Mappings
iSCSI Target Name SCSI Device Name
iqn.2006-01.com.openfiler:linx.strg1 /dev/sda
iqn.2006-01.com.openfiler:linx.strg2 /dev/sdb
iqn.2006-01.com.openfiler:linx.strg3 /dev/sdc
iqn.2006-01.com.openfiler:linx.strg4 /dev/sdd
iqn.2006-01.com.openfiler:linx.strg5 /dev/sde
This mapping, however, may change every time the node is rebooted. For example, after a reboot it may be determined that the iSCSI target iqn.2006-01.com.openfiler:linx.strg1 gets mapped to the local SCSI device /dev/sdd.
To avoid these inconsistencies and to get persistent device mapping we use udev scripting.
The first step is to create a new rules file. The file will be named /etc/udev/rules.d/55-openiscsi.rules and contain only a single line of name=value pairs used to receive events we are interested in. It will also define a call-out SHELL script (/etc/udev/scripts/iscsidev.sh) to handle the event.
Create the following rules file /etc/udev/rules.d/55-openiscsi.rules on the nodes:

# vi /etc/udev/rules.d/55-openiscsi.rules
Type the below given command in this file:

KERNEL=="sd*", BUS=="scsi", PROGRAM="/etc/udev/scripts/iscsidev.sh %b",SYMLINK+="iscsi/%c/part%n"

We now need to create the UNIX SHELL script that will be called when this event is received. Let's first create a separate directory on the nodes where udev scripts can be stored:
# mkdir -p /etc/udev/scripts
Next, create the UNIX shell script /etc/udev/scripts/iscsidev.sh on the nodes:
# vi /etc/udev/scripts/iscsidev.sh
And type the below given command
#!/bin/sh

# FILE: /etc/udev/scripts/iscsidev.sh

BUS=${1}
HOST=${BUS%%:*}

[ -e /sys/class/iscsi_host ] || exit 1

file="/sys/class/iscsi_host/host${HOST}/device/session*/iscsi_session*/targetname"

target_name=$(cat ${file})

# This is not an open-scsi drive
if [ -z "${target_name}" ]; then
exit 1
fi

# Check if QNAP drive
check_qnap_target_name=${target_name%%:*}
if [ $check_qnap_target_name = "iqn.2004-04.com.qnap" ]; then
target_name=`echo "${target_name%.*}"`
fi

echo "${target_name##*.}"

After creating the UNIX SHELL script, change it to executable:
# chmod 755 /etc/udev/scripts/iscsidev.sh
Now that udev is configured, restart the iSCSI service on the nodes:
# service iscsi stop
Stopping iSCSI daemon: [ OK ]

# service iscsi start
iscsid dead but pid file exists
Turning off network shutdown. Starting iSCSI daemon: [ OK ]
[ OK ]
successful
[ OK ]
Let's see if our hard work paid off:
# ls -l /dev/iscsi/*

And now it will always show persistent local device mapping for example:
iqn.2006-01.com.openfiler:linx.strg1 to /dev/sda1 and so on for all local devices.

After this we can create partitions and format the devices. If these devices are to be used for ASM and OCFS partitions plz dont format at this stage.