Skip to content

Instantly share code, notes, and snippets.

@leophys
Last active April 13, 2018 08:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leophys/4a0bc60d2e9c175b6087a81fa16b22d0 to your computer and use it in GitHub Desktop.
Save leophys/4a0bc60d2e9c175b6087a81fa16b22d0 to your computer and use it in GitHub Desktop.
Quick intro to iSCSI

iSCSI

TGT - Server side

Using tgt from tgt aur package. Following this guide from fedora.

Create a user

Using the tgtadm cli tool:

$ tgtadm --lld iscsi --mode account --op new --user ''username'' --password ''password''

Create a net disk and adding block devices to it

Again with tgtadm:

$ tgtadm --lld iscsi --mode target --op new --tid=1 --targetname iqn.2018-04.example.com:reminder

And adding an authorized user to it:

$ tgtadm --lld iscsi --mode account --op bind --tid 1 --user ''username''

Then adding LUN (logical units):

$ tgtadm --lld iscsi --mode logicalunit --op new --tid 1 --lun 1 -b /dev/vmpool/aVolume

Display the status

To enumerate the iSCSI disks:

$ tgtadm --lld iscsi --mode target --op show

Open-iSCSI - Client side

Using the builtin iSCSI kernel module (GNU/Linux). Following this guide from debian the content of /etc/iscsi/iscsid.conf should be:

node.sendtargets.auth.authmethod = CHAP
node.sendtargets.auth.username = username
node.sendtargets.auth.password = password

And then:

$ systemctl restart iscsi.service

Explore a target for shares:

$ iscsiadm  -m discovery -t st -p 192.168.0.20
192.168.0.1:3260,1 iqn.2007-01.org.debian.foobar:CDs
192.168.0.1:3260,1 iqn.2007-01.org.debian.foobar:USB

Mount a share:

$ iscsiadm  -m node  --targetname "iqn.2007-01.org.debian.foobar:CDs" --portal "192.168.0.1:3260" --login
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment