How to setup an IPSAN server

Created by Cyvan Oort at 05-05-2021 10:46:38 +0200

IPSAN or ISCSI server is an internet storage area network server, this means you could share disk blocks to other servers. 

Preparations


For this example we created a small HDD Virtual Machine running Debian.

First of all you should update the VM:

$ apt update
$ apt dist-upgrade


Install TGT


The IPSAN sevice we are using is  TGT(Target Framework). You can install it with:

apt install tgt


Now that we have the service installed we need a disk to share. We are making a 50GB file that can be used as a disk:

$ mkdir /opt/iscsi
$ dd if=/dev/zero of=/opt/iscsi/disk01.img count=0 bs=1 seek=50G


Configure


The configurations for tgt can be set in /etc/tgt/conf.d/disk1.conf (for another disk you could create a new file in the /etc/tgt/conf.d directory) and should look like this:

# Provided device as an iSCSI target
backing-store /opt/iscsi/disk01.img
initiator-address 10.0.0.0/24
#incominguser user password
#outgoinguser debian-iscsi-target secretpass


Here the first line contains the LUN, this is an unique address for each disk and can only be in use by one client.
All rules starting with # are comments. The initiator address makes sure that only that ip or network could connect with this ipsan. The incoming and outgoing user can be used to setup authentication for ipsan, for ease of use and because we have implemented an internal network we are going to skip that here.

Restart and test


now that configuration is done, we could restart the tgt service

$ systemctl restart tgt.service


next verify that it is working

$ tgtadm --mode target --op show


output should look like this:

Target 1: iqn.2021-05.debian-disk01:lun1
System information:
Driver: iscsi
State: ready
I_T nexus information:
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: 751619 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: /opt/iscsi/disk01.img
Backing store flags:
Account information:
ACL information:
10.0.0.0/24



Comments

Comments are turned off.