iSCSI Initiator Sessions….

A session is a TCP connection between an initiator node port and a target node port.LUNs are not accessible until a session is established. After targets have been discovered by the initiator, the initiator needs to log in to access the LUNs. Logging in establishes a session, which is a TCP connection between an initiator node port and a target node port. Before logging in, no sessions are active. Example:

# iscsiadm -m session

iscsiadm: No active sessions

Use the following command to log in and establish a session. When a session is established, iSCSI control, data, and status messages are communicated over the session.

# iscsiadm -m node -l

To log in to a specific target:

# iscsiadm -m node –targetname iqn.2003-01.org.linux-iscsi.host02.x8664:sn.3abca38b994f –p 192.0.2.102:3260 -l

Login to [iface: default, target: iqn.2003-01.org.linux-iscsi.host02.x8664:sn.3abca38b994f, portal: 192.0.2.102:3260] successful.

To log off from all targets:

# iscsiadm -m node -u

To log off from a specific target, use the same login command as shown, except use –u.

Running the -m session command after logging in shows an active session:

# iscsiadm -m session

tcp: [1] 192.0.2.102:3260,1 iqn.2003-01.org.linux-iscsi.host02.x8664:sn.3abca38b994f (non-flash)

The TCP session includes a session ID (SID) of 1 in this example. Include –P <printlevel> for more details. Valid <printlevel> values are 1, 2, and 3.

The following example shows additional details on the session:

# iscsiadm -m session –P 1

Target: iqn.2003-01.org.linux-iscsi.host02.x8664:sn.3abca38b994f

    Current Portal: 192.168.1.102:3260,1

    Persistent Portal: 192.168.1.102:3260,1

        **********

        Interface:

        **********

        Iface Name: default

        Iface Transport: tcp

        Iface Initiatorname: iqn.2003-01.org.linux-iscsi.host02.x8664:sn.3abca38b994f:host03

        Iface IPaddress: 192.168.1.103

        Iface HWaddress: <empty>

        Iface Netdev: <empty>

        SID: 1

        iSCSI Connection State: LOGGED IN

        iSCSI Session State: LOGGED IN

        Internal iscsid Session State: NO CHANGE

The following example provides the most details, including information about the attached SCSI devices. In this example, the target defines two LUNs:

# iscsiadm -m session –P 3

Target: iqn.2003-01.org.linux-iscsi.host02.x8664:sn.3abca38b994f

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

        Attached SCSI devices:

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

        Host Number: 4 State: running

        scsi10 Channel 00 Id 0 Lun:1

        Attached scsi disk sda State: running

        scsi10 Channel 00 Id 0 Lun:2

        Attached scsi disk sdb State: running