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

quick-tip
lab-building
it-infrastructure
storage
iscsi
linux
Tags: #<Tag:0x00007f0cac0925a8> #<Tag:0x00007f0cac092468> #<Tag:0x00007f0cac092300> #<Tag:0x00007f0cac092120> #<Tag:0x00007f0cac091f90> #<Tag:0x00007f0cac091dd8>

#1

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.

Environment

[[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
(parted)

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 storage-node003.data (--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 10.1.1.0/24)

Verify the status of the target with tgtadm

[[email protected] all]STAGING# tgtadm --lld iscsi --op show --mode target
Target 1: storage-node003.data
    System information:
        Driver: iscsi
        State: ready
    I_T nexus information:
        I_T nexus: 1
            Initiator: iqn.2005-03.org.open-iscsi:c04e8f17af18 alias: because_lab01
            Connection: 0
                IP Address: 10.1.1.164
    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:
        ALL

Mount this at the client (initiator)

[email protected]_lab01 ~/iscsi> sudo iscsiadm --mode discovery --type sendtargets --portal 10.1.1.148 -- 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.