How to setup an iSCSI target using tgtadm

转载 2015年07月10日 18:10:18

<<How to setup an iSCSI target using tgtadm>>

1.Start the tgtd service
#service tgtd start
The tgtd service is provided by the package: scsi-target-utils.x86_64

2.Define an iSCSI target name: (for example)
# tgtadm --lld iscsi --op new --mode target --tid=1 --targetname iqn.2001-04.com.example:storage.disk1.amiens.sys1.xyz

3.To view the currect configuration:
# tgtadm --lld iscsi --op show --mode target

For example, here we create a 10G file as the block device:
# dd if=/dev/zero of=/disk1 bs=1M count=10240

4.Add it as a logical unit to the target:
# tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b /disk1

5.Enable the target to accept any initiators:
# tgtadm --lld iscsi --op bind --mode target --tid 1 -I ALL

6.View the current configuration again:
# tgtadm --lld iscsi --op show --mode target
Target 1: iqn.2001-04.com.example:storage.disk1.amiens.sys1.xyz
    System information:
        Driver: iscsi
        Status: running
    I_T nexus information:
    LUN information:
        LUN: 0
            Type: controller
            SCSI ID: deadbeaf1:0
            SCSI SN: beaf10
            Size: 0
            Backing store: No backing store
        LUN: 1
            Type: disk
            SCSI ID: deadbeaf1:1
            SCSI SN: beaf11
            Size: 55G
            Backing store: /disk1
    Account information:
    ACL information:
        ALL

7.Ensure TCP port 3260 can be accessed from remote host.

8.Start from Red Hat Enterprise Linux 5.3, tgt-admin and /etc/tgt/targets.conf can be used for make the setup persistent over reboot:
# tgt-admin --dump > /etc/tgt/targets.conf
# chkconfig tgtd on

9.In releases prior to Red Hat Enterprise Linux 5.3, you have to put the "tgtadm" commands into /etc/rc.local and enable the tgtd service:

echo >> /etc/rc.local <<EOF
tgtadm --lld iscsi --op new --mode target --tid=1 --targetname iqn.2001-04.com.example:storage.disk1.amiens.sys1.xyz
tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b /disk1
tgtadm --lld iscsi --op bind --mode target --tid 1 -I ALL
EOF

# chkconfig tgtd on


<<How to configure the iscsi-initiator>>

1.First install the iscsi-initiator-utils package

#yum install iscsi-initiator-utils

2.Second start the iscsid service and enable it to start when the system boots:

#service iscsid start
#chkconfig iscsid on

3.Then obtain a listing of available targets from a given host (please note that ipaddress listed below must be replaced with the resolvable hostname or ip address of the system providing the port if different than default):

#iscsiadm -m discovery -t sendtargets -p ipaddress

4.Finally, use the following command to login to the available target (again, replace targetname with one from the output of the previous command and replace ipaddress below with that of the target system):

#iscsiadm -m node -T targetname -p ipaddress -l

 

This will enable the target to be accessed upon reboots and it stores it in a node database found in /var/lib/iscsi that is more thoroughly described in the /usr/share/doc/iscsi-initiator-utils-VERSION/README file.

For a more verbose listing of possible options for the iscsiadm command in Red Hat Enterprise Linux 5 refer to the manual page using:

#man iscsiadm













Linux tgtadm: Setup iSCSI Target ( SAN )

本文转载于 http://www.cyberciti.biz/tips/howto-setup-linux-iscsi-target-sanwith-tgt.html L...
  • MM22GG
  • MM22GG
  • 2012年08月08日 23:04
  • 3458

How To Generate An XML File As A Target Datastore Using ODI In An Integration Interface ? [ID 454268

How To Generate An XML File As A Target Datastore Using ODI In An Integration Interface ? [ID 454268...

Linux下应用tgtadm构建iSCSI Target(SAN)

原文: http://blog.csdn.net/vah101/article/details/6300197 Linux target framework(tgt)是为创建、维护SCSI ta...
  • fouweng
  • fouweng
  • 2017年02月13日 16:13
  • 70

转载:How to create an automation project using MFC and a type library

How to create an automation project using MFC and a type library
  • buyicn
  • buyicn
  • 2011年05月01日 14:52
  • 909

How to Avoid ConcurrentModificationException when using an Iterator

Java Collection classes are fail-fast which means that if the Collection will be changed while some ...

How to get Full Rom Dump / Stock ROM of MT6572 MediaTek Smartphones using SPFT and MTK Droid Root an

老外写的超级详细文章,转一下
  • zangcf
  • zangcf
  • 2014年04月15日 14:16
  • 6598

How to Send an Email Using UTL_SMTP with Authenticated Mail Server

In this Document   Goal   Solution   References ...

How to Make an HTTP Connection Using TCP/IP with RSocket

Reviewer Approved     The following code shows how to make an HTTP connection using a TCP/IP wit...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:How to setup an iSCSI target using tgtadm
举报原因:
原因补充:

(最多只允许输入30个字)