iSCSI quickstart: target
1: Installation
Install scsi-target-utils package
# yum install scsi-target-utils
Open firewall port 3260. SELinux?
Start tgtd daemon
# /etc/init.d/tgtd start # service tgtd start? # chkconfig tgtd on?
2: Create target device
Define an iscsi target name/Create a new target device
# tgtadm --lld iscsi --op new --mode target --tid 1 -T iqn.2001-04.com.example:storage.disk2.amiens.sys1.xyz # tgtadm --lld iscsi --op new --mode target --tid=1 --targetname iqn.2009-02.com.example:for.all # tgtadm --lld iscsi --op new --mode target --tid 1 -T iqn.2009-05.com.jarvisstreet:storage.disk1
To view the current configuration, enter:
tgtadm --lld iscsi --op show --mode target
Sample output:
Target 1: iqn.2009-05.com.jarvisstreet:storage.disk1
System information:
Driver: iscsi
State: ready
I_T nexus information:
LUN information:
LUN: 0
Type: controller
SCSI ID: deadbeaf1:0
SCSI SN: beaf10
Size: 0 MB
Online: Yes
Removable media: No
Backing store: No backing store
Account information:
ACL information:
3: Add logical unit
Add a logical unit .Repeat this process while changing the -b parameter to add more logical units.
# tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b /dev/sda3
# tgtadm --lld iscsi --op show --mode target
Target 1: iqn.2009-05.com.jarvisstreet:storage.disk1
System information:
Driver: iscsi
State: ready
I_T nexus information:
LUN information:
LUN: 0
Type: controller
SCSI ID: deadbeaf1:0
SCSI SN: beaf10
Size: 0 MB
Online: Yes
Removable media: No
Backing store: No backing store
LUN: 1
Type: disk
SCSI ID: deadbeaf1:1
SCSI SN: beaf11
Size: 100011 MB
Online: Yes
Removable media: No
Backing store: /dev/sda3
Account information:
ACL information:
4: Accept initiators
To enable the target to accept any initiators, enter:
# tgtadm --lld iscsi --op bind --mode target --tid 1 -I ALL
This should open network port # 3260:
# netstat -tulpn | grep 3260
tgt-setup-lun utility
tgt-setup-lun(8) tgt-setup-lun(8)
NAME
tgt-setup-lun - creates a target, adds a device to the target and
defines initiators that can connect to the target
SYNOPSIS
tgt-setup-lun -d device -n target_name [initiator_IP1 initiator_IP2
...] [-h]
DESCRIPTION
Starts tgtd if necessary and creates a target according to the supplied
target_name. The format of the target name is as follows:
iqn.2001-04.com.hostname-target_name The target name must be
unique.
The script then adds the requested device to the target. If specific IP
addresses are defined, it adds them to the list of allowed initiators
for that target. If no IP addresses is defined, it defines that the
target accepts any initiator.
EXAMPLES
Create a target that uses /dev/sdb1 and allows connections only from
192.168.10.81:
tgt-setup-lun -d /dev/sdb1 -n my_target 192.168.10.81
Create a target that uses /dev/sdb1 and allows connections only from
192.168.10.81 and 192.168.10.82:
tgt-setup-lun -d /dev/sdb1 -n my_target 192.168.10.81 192.168.10.82
Create a target that uses /dev/sdb1 and allows connections from any
initiator:
tgt-setup-lun -d /dev/sdb1 -n my_target
Display help:
tgt-setup-lun -h
