Wednesday, October 5, 2016

configrue iscsi target and initiator on linux network

terminology
 - target: the one who share the disk, partition, etc
 - initiator: client that connect to server to get resources, disk, partition, etc

*** on server
1- install packages
$ sudo apt-get install tgt

2- create configuration to share disk /dev/sdb, by creating new file call /etc/tgt/conf.d/disk2.conf  with the following content
<target iqn.2008-09.test.domain1:siscsi.target5>

#    <direct-store /dev/sdd>
#    vendor_id VENDOR1
#    removable 1
#    device-type cd
#    lun 1
#    </direct-store>

    <direct-store /dev/sdb>
    vendor_id VENDOR2
    lun 1
    write-cache on
    initiator-address ALL
    </direct-store>
</target>



3- restart on iscsi target and it finished on server part
$ sudo /etc/init.d/tgt restart

*** on client

1- install packages
$ sudo apt-get install open-iscsi

2- discovery  resources that the server share, with the following command, 192.168..202.44 is the server ip address
$ sudo iscsiadm -m discovery -t st -p 192.168.202.44
192.168.202.44:3260,1 iqn.2008-09.test.domain1:siscsi.target5

- we got one resource shared call iqn.2008-09.test.domain1:siscsi.target5

3- login to the iscsi target with the command below
$ sudo iscsiadm -m node --login
Logging in to [iface: default, target: iqn.2008-09.test.domain1:siscsi.target5, portal: 192.168.202.44,3260] (multiple)
Login to [iface: default, target: iqn.2008-09.test.domain1:siscsi.target5, portal: 192.168.202.44,3260] successful


 - and we can see the syslogd the new disk is attached to the system


- or use ls to list disk files, we also see the new disk file created,
$ ls /dev/sd*
/dev/sda  /dev/sda1  /dev/sda2  /dev/sda5  /dev/sdb




4- so now we can do anything to the disk as if it is the physically attached to our computer.

No comments:

Post a Comment