Table of Contents

iSCSI

iSCSI Target tgtd (old method)

chkconfig tgtd on
systemctl start tgtd
systemct stop tgtd
systemctl status tgtd.service

iSCSI Target targetcli (new method)

Zapnutí služby:

systemctl enable target
systemctl start target

targetcli

# přidání blokových zařízení
backstores/block create hdd4T /dev/md0
backstores/block create ssd2T /dev/md1
 
ls
 
# vytvoření iqn:
iscsi/ create
 
ls
 
cd iscsi/iqn.2003-01.org.linux-iscsi.fuvs-sn1.x8664:sn.df6ca5504755/
 
# vytvoření LUNů
cd luns
create /backstores/block/hdd4T
create /backstores/block/ssd2T
 
# Vypnutí autentizace a autorizace:
cd tpg1
set attribute authentication=0
set attribute generate_node_acls=1
cd /iscsi
set discovery_auth enable=0
 
# vypnutí výchozího read-only:
cd tpg1
set attribute demo_mode_write_protect=0

iSCSI Initiator

systemctl status iscsi.service

Discovery:

iscsiadm --m discovery -t sendtargets --p 192.168.122.10 --discover

Login:

iscsiadm -m node --login
iscsiadm -m session -o show
 
tcp: [1] 10.53.0.10:3260,1 iqn.2017-03.cz.dragon.ovirt:ovirtengine (non-flash)
tcp: [2] 10.53.0.201:3260,1 iqn.2017-03.cz.dragon.ovirt.fudi-sn1:10T (non-flash)
tcp: [5] 10.53.0.202:3260,1 iqn.2017-03.cz.dragon.ovirt.fudi-sn2:4T-2Tssd (non-flash)
lsscsi
 
[4:0:0:0]    disk    ATA      WDC WD7500BPKX-0 1A01  /dev/sda 
[5:0:0:0]    disk    ATA      WDC WD7500BPKX-0 1A01  /dev/sdb 
[10:0:0:0]   cd/dvd  ATEN     Virtual CDROM    YS0J  /dev/sr0 
[11:0:0:0]   storage IET      Controller       0001  -        
[11:0:0:1]   disk    IET      VIRTUAL-DISK     0001  /dev/sdc 
[12:0:0:0]   storage IET      Controller       0001  -        
[12:0:0:1]   disk    IET      VIRTUAL-DISK     0001  /dev/sdd 
[15:0:0:0]   storage IET      Controller       0001  -        
[15:0:0:1]   disk    IET      VIRTUAL-DISK     0001  /dev/sdf 
[15:0:0:2]   disk    IET      VIRTUAL-DISK     0001  /dev/sdg
iscsiadm -m discoverydb -P1
 
SENDTARGETS:
DiscoveryAddress: 10.53.0.201,3260
Target: iqn.2017-03.cz.dragon.ovirt:ovirtengine
        Portal: 10.53.0.201:3260,1
                Iface Name: default
Target: iqn.2017-03.cz.dragon.ovirt.fudi-sn1:10T
        Portal: 10.53.0.201:3260,1
                Iface Name: default
iSNS:
No targets found.
STATIC:
Target: iqn.2017-03.cz.dragon.ovirt.fuvs-sn1:10T
        Portal: 10.53.1.201:3260,1
                Iface Name: default
Target: iqn.2017-03.cz.dragon.ovirt:ovirtengine
        Portal: 10.53.0.10:3260,1
                Iface Name: default
Target: iqn.2017-03.cz.dragon.ovirt.fudi-sn2:pokus1
        Portal: 10.53.0.202:3260,1
                Iface Name: default
FIRMWARE:
No targets found.

Logout session

iscsiadm -m node -T iqn.2017-03.cz.dragon.ovirt.fudi-sn2:pokus1 -p 10.53.0.202:3260 -u
 
Logging out of session [sid: 6, target: iqn.2017-03.cz.dragon.ovirt.fudi-sn2:pokus1, portal: 10.53.0.202,3260]
Logout of [sid: 6, target: iqn.2017-03.cz.dragon.ovirt.fudi-sn2:pokus1, portal: 10.53.0.202,3260] successful.

Delete target

iscsiadm -m node -o delete -T iqn.2017-03.cz.dragon.ovirt.fudi-sn2:pokus1 -p 10.53.0.202:3260