Setting up iSCSI: Difference between revisions

From Alpine Linux
(note about open-iscsi broken on alpine 2.2. Provided roadmap about iscsi initiators on future alpine releases)
(replace /etc/init.d with rc-service)
 
(11 intermediate revisions by 5 users not shown)
Line 1: Line 1:
trocorviboc
{{Tip|Consider using [[Linux_iSCSI_Target_(TCM)|TCM]] instead of iscsitarget}}
== Introduction ==


iSCSI consists of two pieces:  A target (server) and an initiator (client).  A target is a large pool of disk space that can be accessed over IP by the initiators. Initiators use the disk space, formatting it and mounting it the same as local disk.  When an initiator connects to a target a scsi device node is created (e.g. /dev/sda, /dev/sdb, etc)
iSCSI consists of two components:  A target (server) and an initiator (client).  A target is a large pool of disk space that can be accessed over IP by the initiators. Initiators use the disk space, formatting it and mounting it the same as local disk.  When an initiator connects to a target, a SCSI device node is created (e.g. /dev/sda, /dev/sdb, etc).


== iSCSI Target ==
= iSCSI Target =


The ''iscsitarget-X.X.apk'' package provides the target functionality.  It includes the ietd service (ietd is the iSCSI Enterprise Target Daemon). The ''iscitarget-grsec'' package includes the kernel drivers for the ''grsec'' flavor of linux kernel.
The ''iscsitarget-X.X.apk'' package provides the target functionality.  It includes the ietd service (ietd is the iSCSI Enterprise Target Daemon). The ''iscitarget-grsec'' package includes the kernel drivers for the ''grsec'' flavor of linux kernel.
Line 17: Line 16:
               Lun 0 Path=/dev/sda1, Type=fileio
               Lun 0 Path=/dev/sda1, Type=fileio


The iSCSI Qualified Name is documented in [http://www.ietf.org/rfc/rfc3720.txt  RFC 3720], with further examples of names in [http://www.ietf.org/rfc/rfc3721.txt RFC 3721]. Briefly, the fields are:
The iSCSI Qualified Name is documented in [https://www.ietf.org/rfc/rfc3720.txt  RFC 3720], with further examples of names in [https://www.ietf.org/rfc/rfc3721.txt RFC 3721]. Briefly, the fields are:


* literal '''iqn'''
* literal '''iqn'''
Line 34: Line 33:
       iqn.2001-04.com.example:storage.tape1.sys1.xyz
       iqn.2001-04.com.example:storage.tape1.sys1.xyz
       iqn.2001-04.com.example:storage.disk2.sys1.xyz
       iqn.2001-04.com.example:storage.disk2.sys1.xyz


The "Target" line above is an example.  This line really just needs to be unique.  /dev/sdx refers to the disk and partition that will be presented to the initiator.   
The "Target" line above is an example.  This line really just needs to be unique.  /dev/sdx refers to the disk and partition that will be presented to the initiator.   
Line 40: Line 38:
In the /etc/initiators.allow file, add the following line:
In the /etc/initiators.allow file, add the following line:


    iqn.2006-01.com.example:disk2.vol1 10.1.194.111
iqn.2006-01.com.example:disk2.vol1 10.1.194.111


The IP address in the line above will be the initiator's ip address.  Now only this ip address is allowed to access this specific target.  You must use IP addresses, not hostnames.
The IP address in the line above will be the initiator's ip address.  Now only this ip address is allowed to access this specific target.  You must use IP addresses, not hostnames.
Line 46: Line 44:
If you don't care where the initiator is connecting from, you can use the keyword '''ALL'':
If you don't care where the initiator is connecting from, you can use the keyword '''ALL'':


    iqn.2006-01.com.example:disk2.vol1 ALL
iqn.2006-01.com.example:disk2.vol1 ALL


== iSCSI Initiator ==
= iSCSI Initiator =


'''N.B. Please note that Open-iSCSI is broken on Alpine 2.2. See http://groups.google.com/group/open-iscsi/browse_thread/thread/156e938d21f01275#. Therefore you have to use Alpine 2.1 in order to have a working and reliable initiator. Also Open-iSCSI does not provide support for kernels 3.x yet and [http://groups.google.com/group/open-iscsi/browse_thread/thread/7e7de1c0ac95d854/2a258068cdfcba7b?lnk=gst&q=performance#2a258068cdfcba7b some users reports very slow performance since 2.6.38]. However it has been patched to compile for kernel 3.0.4 that will be released in Alpine 2.3. Feedbacks are welcome at bugs.alpinelinux.org. Please note that for future Alpine versions (2.4 and above) Open-iSCSI support will be dropped and we will move to [http://www.linux-iscsi.org/wiki/Core-iSCSI Core-iSCSI] that has been merged into vanilla kernel since 2.6.38. Core-iSCSI will be available later as option also in Alpine 2.3.'''
{{Warning|1=Please note that Open-iSCSI is broken on Alpine 2.2. See http://groups.google.com/group/open-iscsi/browse_thread/thread/156e938d21f01275#. It works on Alpine 2.1, 2.3 and 2.4 instead.}}


The initator is in the ''open-iscsi'' package.  Load this package on the client.
The initiator is in the ''open-iscsi'' package.  Load this package on the client.


To configure the iSCSI initiator, add the initiator name to the file /etc/iscsi/initiatorname.iscsi  The initator name follows the same iqn naming scheme as the target; but this is iderntifing the initator (client).
To configure the iSCSI initiator, add the initiator name to the file /etc/iscsi/initiatorname.iscsi  The initiator name follows the same iqn naming scheme as the target, but this is identifing the initiator (client).


    InitiatorName=iqn.2007-11.org.alpinelinux.client:01
InitiatorName=iqn.2007-11.org.alpinelinux.client:01


or  
or  
    InitiatorName=iqn.2007-11.com.example.me:foo:bar:baz
InitiatorName=iqn.2007-11.com.example.me:foo:bar:baz




The ''01'', ''foo:bar:baz'' are arbitrary.  You can enter anything (or nothing)- as long as the intiator name is a valid iqn.
The ''01'', ''foo:bar:baz'' are arbitrary.  You can enter anything (or nothing)- as long as the intiator name is a valid iqn.


Start the initiator daemon with
Start the initiator daemon with
/etc/init.d/iscsid start
{{Cmd|rc-service iscsid start}}


== Connecting the Initiator to the Target ==
= Connecting the Initiator to the Target =


From the iSCSI initiator, first run this command:
From the iSCSI initiator, first run this command:


    iscsiadm --mode discovery --type sendtargets --portal IP_OF_TARGET
{{Cmd|iscsiadm --mode discovery --type sendtargets --portal IP_OF_TARGET}}


This command contacts the target to determine which disks are available.  If all is configured correctly, the target name iqn.2006-01.com.example:disk2.vol1 (from the example above) will be returned.
This command contacts the target to determine which disks are available.  If all is configured correctly, the target name iqn.2006-01.com.example:disk2.vol1 (from the example above) will be returned.
Line 78: Line 75:
After the target is discovered, run this command to connect:
After the target is discovered, run this command to connect:


    iscsiadm --mode node --targetname NAME_OF_TARGET --portal IP_OF_TARGET --login
{{Cmd|iscsiadm --mode node --targetname NAME_OF_TARGET --portal IP_OF_TARGET --login}}


Replacing --login with --logout will end the connection.   
Replacing --login with --logout will end the connection.   
Line 84: Line 81:
To make this connection persistent (so that it will reconnect after reboot), run this command:
To make this connection persistent (so that it will reconnect after reboot), run this command:


    iscsiadm -m node -T NAME_OF_TARGET -p IP_OF_TARGET --op update -n node.conn[0].startup -v automatic
{{Cmd|iscsiadm -m node -T NAME_OF_TARGET -p IP_OF_TARGET --op update -n node.conn[0].startup -v automatic}}


''Any references/links to where to find more details about it?''--[[User:Ncopa|Ncopa]] 16:04, 8 November 2007 (UTC)
''Any references/links to where to find more details about it?''--[[User:Ncopa|Ncopa]] 16:04, 8 November 2007 (UTC)
[[Category:Storage]]

Latest revision as of 10:40, 17 November 2023

Tip: Consider using TCM instead of iscsitarget

iSCSI consists of two components: A target (server) and an initiator (client). A target is a large pool of disk space that can be accessed over IP by the initiators. Initiators use the disk space, formatting it and mounting it the same as local disk. When an initiator connects to a target, a SCSI device node is created (e.g. /dev/sda, /dev/sdb, etc).

iSCSI Target

The iscsitarget-X.X.apk package provides the target functionality. It includes the ietd service (ietd is the iSCSI Enterprise Target Daemon). The iscitarget-grsec package includes the kernel drivers for the grsec flavor of linux kernel. Install with:

apk add iscsitarget iscsitarget-grsec

Once the packages are installed, you can set up a target by editing two conf files.


In /etc/ietd.conf, add the following information:

       Target iqn.2006-01.com.example:disk2.vol1
              Lun 0 Path=/dev/sda1, Type=fileio

The iSCSI Qualified Name is documented in RFC 3720, with further examples of names in RFC 3721. Briefly, the fields are:

  • literal iqn
  • date (yyyy-mm) that the naming authority took ownership of the domain
  • reversed domain name of the authority (org.alpinelinux, com.example, to.yp.cr)
  • Optional ":" prefixing a storage target name specified by the naming authority.

From the RFC:

                   Naming     String defined by
      Type  Date    Auth      "example.com" naming authority
     +--++-----+ +---------+ +--------------------------------+
     |  ||     | |         | |                                |     

     iqn.2001-04.com.example:storage:diskarrays-sn-a8675309
     iqn.2001-04.com.example
     iqn.2001-04.com.example:storage.tape1.sys1.xyz
     iqn.2001-04.com.example:storage.disk2.sys1.xyz

The "Target" line above is an example. This line really just needs to be unique. /dev/sdx refers to the disk and partition that will be presented to the initiator.

In the /etc/initiators.allow file, add the following line:

iqn.2006-01.com.example:disk2.vol1 10.1.194.111

The IP address in the line above will be the initiator's ip address. Now only this ip address is allowed to access this specific target. You must use IP addresses, not hostnames.

If you don't care where the initiator is connecting from, you can use the keyword 'ALL:

iqn.2006-01.com.example:disk2.vol1 ALL

iSCSI Initiator

Warning: Please note that Open-iSCSI is broken on Alpine 2.2. See http://groups.google.com/group/open-iscsi/browse_thread/thread/156e938d21f01275#. It works on Alpine 2.1, 2.3 and 2.4 instead.


The initiator is in the open-iscsi package. Load this package on the client.

To configure the iSCSI initiator, add the initiator name to the file /etc/iscsi/initiatorname.iscsi The initiator name follows the same iqn naming scheme as the target, but this is identifing the initiator (client).

InitiatorName=iqn.2007-11.org.alpinelinux.client:01

or

InitiatorName=iqn.2007-11.com.example.me:foo:bar:baz


The 01, foo:bar:baz are arbitrary. You can enter anything (or nothing)- as long as the intiator name is a valid iqn.

Start the initiator daemon with

rc-service iscsid start

Connecting the Initiator to the Target

From the iSCSI initiator, first run this command:

iscsiadm --mode discovery --type sendtargets --portal IP_OF_TARGET

This command contacts the target to determine which disks are available. If all is configured correctly, the target name iqn.2006-01.com.example:disk2.vol1 (from the example above) will be returned.

After the target is discovered, run this command to connect:

iscsiadm --mode node --targetname NAME_OF_TARGET --portal IP_OF_TARGET --login

Replacing --login with --logout will end the connection.

To make this connection persistent (so that it will reconnect after reboot), run this command:

iscsiadm -m node -T NAME_OF_TARGET -p IP_OF_TARGET --op update -n node.conn[0].startup -v automatic

Any references/links to where to find more details about it?--Ncopa 16:04, 8 November 2007 (UTC)