ISCSI

From PrgmrWiki

Terms

  • Server -> target(s)
  • Individual share -> logical unit
  • Target -> Group of logical units
  • Client -> Initiator



Targets

Minimum properties

Target
  • Name
  • Target ID (may be autogenerated rather than assigned)


Logical unit
  • Target it belongs to, specified by id
  • Backing store path


Package

scsi-target-utils

Files

  • /etc/tgt/targets.conf
  • /etc/init.d/tgtd
  • /etc/sysconfig/iptables

iptables minimal editing example

-A INPUT -m state --state NEW -m tcp -p tcp --dport 3260 -j ACCEPT #please edit to further constrain

targets.conf minimal editing example

<target alice>
backing-store /dev/mapper/volume-alice
</target>

Commands

tgtadm --op show --mode target #show current targets
tgtadm --lld iscsi --op new --mode target --tid 2 --targetname bob #hot-add new target
tgtadm --op new --mode logicalunit --tid 2 --lun 1 --backing-store /dev/mapper/volume-bob --lld iscsi #hot-add new logical unit
tgtadm --lld iscsi --op bind --mode target --tid 2 -I ALL #allow all initiators to access a target
tgtadm --lld iscsi --op unbind --mode target --tid 2 -I ALL #remove all access to a target
tgtadm --lld iscsi --op bind --mode target --tid 2 -I 172.16.10.133 #allow particular ip to access, can also be accomplished using iptables
tgtadm --mode target --op delete --tid 2 #remove unused target



Initiators

Package

open-iscsi

Files

/etc/iscsi/iscsid.conf

iscsid.conf minimal editing example

node.startup = manual

Commands

iscsiadm --mode discovery -t sendtargets --portal 172.16.10.156 #required before trying to connect to a new device
iscsiadm -m node -T bob --portal 172.16.10.156 --op update -n node.startup -v automatic #make connecting to bob automatic at startup
iscsiadm --mode node --targetname bob --portal 172.16.10.156 --login
ls /dev/disk/by-path/ | grep bob #find bobs disk
iscsiadm --mode node --logout --targetname bob #logout one
iscsiadm --mode session --logout #logout all
iscsiadm -m node -T bob --portal 172.16.10.156 --op update -n node.startup -v manual #disable connecting to bob automatically at startup

Useful links