This example is based on the environment below.

+----------------------+          |          +----------------------+
| [   iSCSI Target   ] | || [ iSCSI Initiator  ] |
|   +----------+----------+   |
|                      |                     |                      |
+----------------------+                     +----------------------+

All of the below commands take place on the initiator machine.

Install initiator utils.
[root@www ~]# yum -y install iscsi-initiator-utils

Set the initiator name in /etc/iscsi/initiatorname.iscsi

Configure /etc/iscsi/iscsid.conf:
Some strongly recommended settings:

	# if this is not set to manual, iscsi will try to connect to every target
	# it sees:
	node.startup = manual

	node.session.auth.authmethod = CHAP
	# disable these on specific targets, if the target does not support it:
	node.conn[0].iscsi.HeaderDigest = CRC32C
	# note: actually not supported in initiator yet at time of writing, but
	# recommended to enable it when it is:
	# node.conn[0].iscsi.DataDigest = CRC32C

The defaults are fine for most other settings; pay attention to the places
that mention specific settings for different types of iSCSI targets, e.g.

Do not set a CHAP username & password here, as that will result in iscsi
trying to use those credentials for every connection on every target (probably
not correct).

Connect to the target server and get a list of available targets:
iscsiadm --mode discovery --type sendtargets --portal

Depending on the target server's settings, this may produce a long list of
targets you don't want. Either delete the cached references to these targets
you don't want, or verify that their startup type is 'manual':
	List the currently cached target references:
	iscsiadm -m node

	Check its startup type (to show all startup types, just omit the
	"--targetname" parameter):
	iscsiadm -m node --targetname -o show | grep startup

	Delete a discovered target reference:
	iscsiadm -m node --targetname -o delete

Set the CHAP credentials for the target you want:
iscsiadm -m node --targetname -o update -n node.session.auth.username -v <username>
iscsiadm -m node --targetname -o update -n node.session.auth.password -v <password>

Connect the target:
iscsiadm -m node --targetname --login

See what device name it got:
ls -l /dev/disk/by-path/

Session status:
iscsiadm -m session -P 3

If you want this connection to be persistent:
	Set the startup type to automatic:
	iscsiadm -m node --targetname -o update -n node.startup -v automatic

	Use UUIDs for mounting, or the persistent device name for it from /dev/disk/by-path/

	Set the "_netdev" mount option when adding to fstab, e.g.:
	UUID=71e86162-011d-49f1-9b4a-9f95a277e6b5 /mnt/data ext4 _netdev,rw 0 0

Disconnect from a target:
iscsiadm -m node --targetname --logout
Delete the cached reference, if you do not need to connect to it again later:
iscsiadm -m node --targetname -o delete