iSCSI, LUNs, arrays - OpenSource storage with Linux and tgt

Tags: #<Tag:0x00007f389e615de0> #<Tag:0x00007f389e615c28> #<Tag:0x00007f389e615ae8> #<Tag:0x00007f389e6158b8> #<Tag:0x00007f389e615638> #<Tag:0x00007f389e6154d0>


iSCSI, LUNs, arrays - OpenSource storage

iSCSI sounds hard… and it is hard. Storage is a mystical thing everyone needs to have anywhere, shared, centrally. Reliable, fast and secure.

This quick-tip is meant for a lab, not for a production setup. In reality, if commercial services rely on iSCSI, you need to do much more. But this is useful to play around with iSCSI. I don’t provide much background infos here, because this isn’t meant as an introduction.

tgt - OpenSource iSCSI for Linux

Linux SCSI target framework (tgt) aims to simplify various SCSI target driver (iSCSI, Fibre Channel, SRP, etc) creation and maintenance. Our key goals are the clean integration into the scsi-mid layer and implementing a great portion of tgt in user space.

Go to the source for more and better infos. There is documentation. In the following this is hands on material only.


[[email protected] all]STAGING# uname -a
Linux storage-node003 4.0.5-gentoo #7 SMP Tue Sep 22 14:12:19 UTC 2015 x86_64 Intel(R) Xeon(R) CPU E5-2620 v2 @ 2.10GHz GenuineIntel GNU/Linux

Installation via Portage

[[email protected] all]STAGING# emerge -av tgt

Preparation of partitions with GNU Parted

[[email protected] all]STAGING# parted -a optimal /dev/sdb
GNU Parted 3.2
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Model: IBM ServeRAID M5110 (scsi)
Disk /dev/sdb: 146GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number  Start   End    Size   File system  Name          Flags
 1      1049kB  146GB  146GB  ext4         iscsi_target

Ad hoc commandline setup of an iSCSI target with tgt on Linux

[[email protected] all]STAGING# tgtadm --lld iscsi --op new --mode target --tid 1 -T (--mode account --user speedy --password gonzales)
[[email protected] all]STAGING# tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b /dev/sdb1
[[email protected] all]STAGING# tgtadm --lld iscsi --op bind --mode target --tid 1 -I ALL  (--initiator-address

Verify the status of the target with tgtadm

[[email protected] all]STAGING# tgtadm --lld iscsi --op show --mode target
Target 1:
    System information:
        Driver: iscsi
        State: ready
    I_T nexus information:
        I_T nexus: 1
            Initiator: alias: because_lab01
            Connection: 0
                IP Address:
    LUN information:
        LUN: 0
            Type: controller
            SCSI ID: IET     00010000
            SCSI SN: beaf10
            Size: 0 MB, Block size: 1
            Online: Yes
            Removable media: No
            Prevent removal: No
            Readonly: No
            SWP: No
            Thin-provisioning: No
            Backing store type: null
            Backing store path: None
            Backing store flags:
        LUN: 1
            Type: disk
            SCSI ID: IET     00010001
            SCSI SN: beaf11
            Size: 145997 MB, Block size: 512
            Online: Yes
            Removable media: No
            Prevent removal: No
            Readonly: No
            SWP: No
            Thin-provisioning: No
            Backing store type: rdwr
            Backing store path: /dev/sdb1
            Backing store flags:
    Account information:
    ACL information:

Mount this at the client (initiator)

[email protected]_lab01 ~/iscsi> sudo iscsiadm --mode discovery --type sendtargets --portal -- login
[email protected]_lab01 ~/iscsi> sudo iscsiadm -m session -P 3
[email protected]_lab01 ~/iscsi> iscsiadm -m node -L all
[email protected]_lab01 ~/iscsi> sudo partprobe

Now let’s assume that’s /dev/sdb. Mount and format it.