From Fedora Project Wiki

m (Use admon template)
(Remove forbidden h1 and demote headings appropriately)
Line 1: Line 1:
= About =
== About ==


This page is intended to outline a series of steps need to quickly get a '''scsi-target-utils''' based iSCSI software target working.   
This page is intended to outline a series of steps need to quickly get a '''scsi-target-utils''' based iSCSI software target working.   
Line 5: Line 5:
Most of these instructions can also be found in a README provided by the scsi-target-utils package (see ''/usr/share/doc/scsi-target-utils-0.9.2/README.iscsi'').
Most of these instructions can also be found in a README provided by the scsi-target-utils package (see ''/usr/share/doc/scsi-target-utils-0.9.2/README.iscsi'').


= Installation =
== Installation ==


Start by installing the '''scsi-target-utils''' package.  
Start by installing the '''scsi-target-utils''' package.  
Line 13: Line 13:
</pre>
</pre>


= Configuration =
== Configuration ==


== Firewall ==
=== Firewall ===


Ensure, port 3260 is available for incoming connection and there is no firewall in the way between target and test machine.  
Ensure, port 3260 is available for incoming connection and there is no firewall in the way between target and test machine.  
Line 25: Line 25:
*# Then restarting ''iptables'': <pre># service iptables restart</pre>
*# Then restarting ''iptables'': <pre># service iptables restart</pre>


== Backing Store ==
=== Backing Store ===


When configured, the tgtd service will present a block device to iSCSI initiators.  You may use a LVM logical volume, a disk partition, a whole disk, or a loop back partition.  For this document, we will create a ''/dev/loop0'' loop back device.
When configured, the tgtd service will present a block device to iSCSI initiators.  You may use a LVM logical volume, a disk partition, a whole disk, or a loop back partition.  For this document, we will create a ''/dev/loop0'' loop back device.
Line 32: Line 32:
# Next, create a loopback device: <pre># losetup /dev/loop0 /tmp/iscsi-disk1</pre>
# Next, create a loopback device: <pre># losetup /dev/loop0 /tmp/iscsi-disk1</pre>


== Selinux ==
=== Selinux ===


{{admon/warning|FIXME|Detail any SELinux considerations here.}}
{{admon/warning|FIXME|Detail any SELinux considerations here.}}


== Service startup ==
=== Service startup ===


Configure the tgtd service to start on boot.  Type:
Configure the tgtd service to start on boot.  Type:
Line 45: Line 45:
</pre>
</pre>


= Up and running in 3 steps =
== Up and running in 3 steps ==


For the fastest way to present a target device with 1 logical unit to any initiator ... follow these three steps:
For the fastest way to present a target device with 1 logical unit to any initiator ... follow these three steps:
Line 55: Line 55:
That's it!
That's it!


= How to ... =
== How to ... ==


The following sections detail common actions you might perform using the ''tgtadm'' utility with the configuration used above.  All of the following steps are also detailed in the ''README.iscsi'' included in the ''scsi-target-utils'' package.
The following sections detail common actions you might perform using the ''tgtadm'' utility with the configuration used above.  All of the following steps are also detailed in the ''README.iscsi'' included in the ''scsi-target-utils'' package.


== List active targets ==
=== List active targets ===


At any time you can list the active targets by typing: <pre># tgtadm --lld iscsi --op show --mode target</pre>
At any time you can list the active targets by typing: <pre># tgtadm --lld iscsi --op show --mode target</pre>


== Create a new target device ==
=== Create a new target device ===


Create a target device: <pre># tgtadm --lld iscsi --op new --mode target --tid=1 --targetname iqn.2009-02.com.example:for.all</pre>
Create a target device: <pre># tgtadm --lld iscsi --op new --mode target --tid=1 --targetname iqn.2009-02.com.example:for.all</pre>


== Add a logical unit ==
=== Add a logical unit ===


You can add a logical unit to an existing target device by typing:
You can add a logical unit to an existing target device by typing:
Line 77: Line 77:
Repeat this process while changing the '''-b''' parameter to add more logical units.
Repeat this process while changing the '''-b''' parameter to add more logical units.


== Permissions ==
=== Permissions ===


The following sections detail various authentication and restrictions you can enabled using ''tgtadm''.
The following sections detail various authentication and restrictions you can enabled using ''tgtadm''.


=== List all user accounts ===
==== List all user accounts ====


To display a list of all configured user accounts, type:
To display a list of all configured user accounts, type:
<pre># tgtadm --lld iscsi --op show --mode account</pre>
<pre># tgtadm --lld iscsi --op show --mode account</pre>


=== Allow all initiators ===
==== Allow all initiators ====


<pre>
<pre>
Line 92: Line 92:
</pre>
</pre>


=== IP-based restrictions ===
==== IP-based restrictions ====


If you've previously configured this target to accept '''ALL''' initiators, you'll need to remove that first.
If you've previously configured this target to accept '''ALL''' initiators, you'll need to remove that first.
Line 112: Line 112:
</pre>
</pre>


=== User/Password authentication (CHAP) ===
==== User/Password authentication (CHAP) ====


# First, create a user and password: <pre># tgtadm --lld iscsi --op new --mode account --user ''consumer'' --password ''Longsw0rd''</pre>
# First, create a user and password: <pre># tgtadm --lld iscsi --op new --mode account --user ''consumer'' --password ''Longsw0rd''</pre>
# Next, add the users to an existing target device: <pre># tgtadm --lld iscsi --op bind --mode account --tid 1 --user ''consumer''</pre>
# Next, add the users to an existing target device: <pre># tgtadm --lld iscsi --op bind --mode account --tid 1 --user ''consumer''</pre>


=== Reverse User/Password authentication (CHAP) ===
==== Reverse User/Password authentication (CHAP) ====


{{admon/warning|FIXME|What's the different between one-way and two-way ... and reverse CHAP?}}
{{admon/warning|FIXME|What's the different between one-way and two-way ... and reverse CHAP?}}

Revision as of 14:04, 12 February 2009

About

This page is intended to outline a series of steps need to quickly get a scsi-target-utils based iSCSI software target working.

Most of these instructions can also be found in a README provided by the scsi-target-utils package (see /usr/share/doc/scsi-target-utils-0.9.2/README.iscsi).

Installation

Start by installing the scsi-target-utils package.

# yum install scsi-target-utils

Configuration

Firewall

Ensure, port 3260 is available for incoming connection and there is no firewall in the way between target and test machine.

  • Either stop your firewall:
    # service iptables stop
  • Or, open up port 3260 for traffic using:
    # system-config-firewall
  • Or, modify your iptables configuration manually by
    1. editing /etc/sysconfig/iptables
    2. Then restarting iptables:
      # service iptables restart

Backing Store

When configured, the tgtd service will present a block device to iSCSI initiators. You may use a LVM logical volume, a disk partition, a whole disk, or a loop back partition. For this document, we will create a /dev/loop0 loop back device.

  1. First, create a 8Gib file:
    # dd if=/dev/zero of=/tmp/iscsi-disk1 bs=1M count=8000
  2. Next, create a loopback device:
    # losetup /dev/loop0 /tmp/iscsi-disk1

Selinux

FIXME
Detail any SELinux considerations here.

Service startup

Configure the tgtd service to start on boot. Type:

# service tgtd start
# chkconfig tgtd on

Up and running in 3 steps

For the fastest way to present a target device with 1 logical unit to any initiator ... follow these three steps:

  1. First, create a target device
  2. Next, add a logical unit
  3. Finally, enable the target to accept initiators

That's it!

How to ...

The following sections detail common actions you might perform using the tgtadm utility with the configuration used above. All of the following steps are also detailed in the README.iscsi included in the scsi-target-utils package.

List active targets

At any time you can list the active targets by typing:

# tgtadm --lld iscsi --op show --mode target

Create a new target device

Create a target device:

# tgtadm --lld iscsi --op new --mode target --tid=1 --targetname iqn.2009-02.com.example:for.all

Add a logical unit

You can add a logical unit to an existing target device by typing:

# tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b /dev/loop0

Repeat this process while changing the -b parameter to add more logical units.

Permissions

The following sections detail various authentication and restrictions you can enabled using tgtadm.

List all user accounts

To display a list of all configured user accounts, type:

# tgtadm --lld iscsi --op show --mode account

Allow all initiators

# tgtadm --lld iscsi --op bind --mode target --tid 1 -I ALL

IP-based restrictions

If you've previously configured this target to accept ALL initiators, you'll need to remove that first.

# tgtadm --lld iscsi --op unbind --mode target --tid 1 -I ALL

Now, restrict access to a specific IP ...

# tgtadm --lld iscsi --op bind --mode target --tid 1 -I 10.10.0.24

Or, restrict access to a subnet ...

# tgtadm --lld iscsi --op bind --mode target --tid 1 -I 10.10.0.0/24

User/Password authentication (CHAP)

  1. First, create a user and password:
    # tgtadm --lld iscsi --op new --mode account --user ''consumer'' --password ''Longsw0rd''
  2. Next, add the users to an existing target device:
    # tgtadm --lld iscsi --op bind --mode account --tid 1 --user ''consumer''

Reverse User/Password authentication (CHAP)

FIXME
What's the different between one-way and two-way ... and reverse CHAP?
  1. First, create a user and password:
    # tgtadm --lld iscsi --op new --mode account --user ''provider'' --password ''Shortsw0rd''
  2. Next, add the users to an existing target device:
    # tgtadm --lld iscsi --op bind --mode account --tid 1 --user ''provider'' --outgoing