ISCSI

iSCSI is a protocol that uses the TCP/IP stack to transport scsi calls over a network, it uses "Initiators" on the client to connect to the "Targets" (data server). The purpose of iSCSI is to use existing Gigabit Ethernet networks to make SANs, reducing the costs of implementation compared to fibre-channel or other I/O protocol. This is actually possible by the large adoption and low cost of Gigabit Ethernet in comparison with another protocols like Infiniband and Fibre-Channel. When choosing Ethernet switches and NICs for iSCSI make sure they support Jumbo Frames (MTU 9000). It uses a method called "Discovery" once you input the IP of the server in the initiator it looks for all the targets on that server. It treats these targets as block devices that you can appear as local disks. You can then have your way with it! The local server will still be read as a raw disk.

iSCSI uses IQN (iSCSI qualified name) for target and initiator identification. IQN format is specified by IETF RFC 3721. For example: iqn.2001-04.org.gentoo:iSCSI.test.disk1


 * iqn - type (always "iqn")
 * 2001-01 - year and month on which the domain has been registered
 * org.gentoo - reversed domain (naming authority)
 * iSCSI.test.disk1 - unique identifier (i.e. hostname and disk for targets)

Kernel Configuration
Make sure your kernel is ready to run iSCSI, activate the following options:

Emerging iSCSI-target
Emerge iSCSI-target:

And then add the iscsi_trgt to the modules autoload (if you want to start it at boot time):

Configuration for the iSCSI-target
Create the configuration file for the iSCSI-target /etc/ietd.conf.

In order to allow an Ethernet card transmit Jumbo Frames run

or add the following line to /etc/conf.d/net:

/etc/conf.d/net

where eth0 is the network device you want to use to expose the iSCSI target over. Note that not all NIC support 9000 as a value for MTU. Work your way down by 1000 to find a value that works, then work up to find the maximum. To start the server, start the init:

Configuring the iSCSI initiator (client)
Connect to the target with a iSCSI initiator from a different machine on the network.

Kernel Configuration
Make sure you have the following options:

Emerging iSCSI initiator
The iSCSI initiator package may be masked in portage. If so, add it to the keywords list first.

Then emerge it.

Configuration for the iSCSI initiator
Set the initiator name and alias in /etc/iscsi/initiatorname.iscsi.

Now you can start the iscsid with:

Before attaching iSCSI targets we must tell iscsid what interface in the system should be used. The interface is specified by the MAC address and can be obtained by running:

Please note that iSCSI does not set an IP address on the interface... you have to do it by running ifconfig or through /etc/conf.d/net. Let us assume that eth1 MAC address is AA:BB:CC:DD:EE:FF, and we want to use this interface, we type:

Also allow Ethernet card to transmit Jumbo Frames; run: Or add the following line into /etc/conf.d/net:

Note that not all NIC support 9000 as a value for MTU. Work your way down by 1000 to find a value that works, then work up to find the maximum.

To discover targets exported by the iSCSI-target with IP address 192.168.1.100 run the following command:

Finally you can attach some of the exported targets with and display partitions on them:

To disconnect the target from the system type the following (after you unmount it :)

udev creating useful symlinks
If you need consistent device naming for your iSCSI targets then you can use udev rules to generate these. The following example will create a /dev/iscsi/iqn... link to the device allocated by the kernel.

This will create a devicenode for every LUN you defined in the schema "/dev/iscsi//[-partX]" or if you did not specify a ScsiSN in the schema "/dev/iscsi//lunX[-partX]". Define the serial name in your ietd.conf. This will lead to no /dev/sda or something, beware!

This script will generate the appropriate device name. Don't forget to make it executable!

Iscsi targets autologin / Autostart
Find your target:

Login to your target:

Register your target to autostart:

Test:

Windows Client
You can also use a windows machine as an iSCSI initiator, of which the software is found here.


 * General Tab
 * Change -> Choose a name for your initiator
 * Discovery Tab
 * Add -> Enter the ip address for your target
 * Targets Tab
 * Log On -> Choose "Automatically restore this connection when the system boots"

Under disk management (Right Click on "My Computer" -> Manage -> Disk Management) you should see your new SCSI hard drive.

Authentication
This is a basic setup with no authentication. CHAP is the name of the Authentication used in iSCSI read more about that in the ietd.conf manual.

Credits
(This wiki page is a modified and augemented version of: http://forums.gentoo.org/viewtopic-t-469920.html)