iscsi notes

iscsi target

  • Install iscsi utils:
    yum install scsi-target-utils
  • Bring up tgtd:
    chkconfig tgtd on
    service tgtd start
  • Define an iscsi target name:
    # tgtadm --lld iscsi --op new --mode target --tid 1 -T
  • Delete specific iscsi target:
    # tgtadm --lld iscsi --op delete --mode target --tid 1
  • Add a logical unit to the target:
    # tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b /dev/vg1/lv1_iscsi0
  • Delete logical unit:
    # tgtadm --lld iscsi --op delete --mode logicalunit --tid 1 --lun 1
  • Enable the target to accept any initiators:
    # tgtadm --lld iscsi --op bind --mode target --tid 1 -I ALL
  • View configuration:
    # tgtadm --lld iscsi --op show --mode target
  • Save the tgt conf:
    # tgt-admin --dump >/etc/tgt/targets.conf

iscsi initiator

  • install the initiator client:
    # yum install iscsi-initiator-utils
  • startup the iscsi daemon so all kernel modules get loaded:
    # chkconfig iscsid on
    # chkconfig iscsi on
    # service iscsid start
  • Discover targets:
    # iscsiadm --mode discovery --type sendtargets --portal
  • Login to target:
    # service iscsi restart
  • To manually login:
    # iscsiadm --mode node --targetname --portal --login
  • To manually logout:
    # iscsiadm --mode node --targetname --portal --logout
  • To delete targets:
    # iscsiadm --mode node --targetname --portal -o delete
  • List sessions:
    # iscsiadm -m session
  • List nodes:
    # iscsiadm -m node