SCST: An Enterprise-Class SCSI Target Framework for Linux

0
10674

Visual Database with magnifying Glass

SCST is an SCSI target software framework. The objectives of this framework are high performance, high reliability and strict conformity to existing SCSI standards. SCST supports multiple SCSI protocols and local storage interfaces.

SCST is a generic SCSI sub-system for Linux that allows the creation of sophisticated storage devices from any Linux machine. The storage devices created can provide various functionalities like SCSI-3 persistent reservation, replication, thin provisioning and a range of other functions which normal storage devices offer. In this section, we will discuss the iSCSI feature of SCST on Linux machines.

Getting familiar with the terminology used
Before going forward, let’s get familiar with some terms commonly used in the storage domain and in this article.

SCSI (Small Computer System Interface): This is a set of standards for physically connecting and transferring data between computers and peripheral devices. Some examples of SCSI devices are SCSI hard drives, SCSI CD-ROM drives and SCSI tape drives.
iSCSI (Internet Small Computer System Interface): This works on top of TCP (Transport Control Protocol), allowing you to send SCSI commands in a local area network (LANs). iSCSI is the way by which the user can share block level storage over a network, unlike NFS (Network File System), which shares storage at the file system level.

iSCSI target (server): iSCSI infrastructure is a client-server architecture. The server which provides storage resources is called the ‘target’. iSCSI’s target serves storage and other services to clients, and also takes care of SCSI commands received over the network.

iSCSI initiator (client): This is basically a client in the iSCSI infrastructure. Almost all mainstream operating systems, by default, provide an iSCSI initiator package. An initiator sends SCSI commands to the iSCSI target over the network in order to get services and storage served.

Figure 1
Figure 1: Network topology of iSCSI infrastructure

Configuring SCST in Linux

On the target system
SCST can be installed from the source available online at https://svn.code.sf.net/p/scst/svn/trunk/ but before installing it, you need to install kernel development packages for your system.
On Debian systems: To install on Debian systems, give the following command:

# apt-get install gcc libncurses5-dev linux-headers-`uname -r` lsscsi patch subversion

On RHEL/CentOS: Type the following to install on RHEL/CentOS:

# yum install gcc ncurses-devel kernel-devel lsscsi patch subversion

1. Download SCST source code from the SVN repository using the following command:

# svn co https://svn.code.sf.net/p/scst/svn/trunk scst

2. Go to the SCST source directory. By default, the build mode is ‘debug’ which is meant for debugging SCST code. To change this to release mode, issue the following command:

# cd scst
# make 2release

3. Now, build and install SCST kernel modules using the following command:

# BUILD_2X_MODULE=y make all install

4. Verify that the installation is successful. Check if you have the required SCST kernel modules in place by using the following command:

# ls -l /lib/modules/`uname -r`/extra/scst*.ko

5. Insert SCST kernel modules using the modprobe command shown below:

# for j in scst scst_vdisk scst_user ; do modprobe $j ; done

6. Create a virtual device, which will be exported as LUN by SCST using iSCSI, as follows:

# dd if=/dev/zero of=/mnt/disk01 bs=1024k count=512

7. Create a sample configuration file, which will export this newly created device as LUN, using the following command:

# cat << /etc/scst.conf
HANDLER vdisk_fileio {
DEVICE disk1 {
filename /mnt/disk1
}
}
TARGET_DRIVER iscsi{
TARGET iqn.2015-11.com.example:storage1 {
enabled 1
LUN 0 disk1
}
}
EOF

8. Restart SCST using the SCST service, as follows:

# /etc/init.d/scst restart

On initiator systems
Each operating system comes with the iSCSI initiator package. Otherwise, you can install the iSCSI initiator package using the following commands.
On RHEL/CentOS: Give the following command to install the initiator package:

# yum install -y iscsi-initiator-utils

On Debian: To install the initiator package on Debian, type:

# aptitude install open-iscsi

1. Discover the target using the following command. Make sure that the target and initiator have connectivity between them.

# iscsiadm -m discovery -t sendtargets -p <IP_ADDRESS_TARGET>

Notice that you will target iqn.2015-11.com.example:storage1, which is exported by the iSCSI target.
2. Do log in using the following command. Replace targetname with the above iSCSI target name.

# iscsiadm -m node –targetname <targetname> -p <IP_ADDRESS_TARGET> --login

3. Check that LUN is visible in the initiator environment using fdisk:

# fdisk -l

You will notice that the new block device is added to your system configuration.
4. You can create partitions and format the disk using the fdisk and mkfs commands, as follows:

# fdisk -l /dev/sdb4

Disk /dev/sdb4: 536 MB, 536870912 bytes, 1048576 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

You can format to ext4 by using the following commands:

# mkfs.ext4 /dev/sdb4
mke2fs 1.42.9 (28-Dec-2013)
Discarding device blocks: done
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
32768 inodes, 131072 blocks
6553 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=134217728
4 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304

Allocating group tables: done
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

You can perform various file operations on this partition, which are exported by the target and used by the initiator.
SCST provides lots of configuration for the virtual disk created. You can check more details on the documentation page at http://scst.sourceforge.net/target_iscsi.html. You can also contribute to SCST code at http://scst.sourceforge.net/contributing.html, and get the latest details about SCST by subscribing to a mailing list at https://lists.sourceforge.net/lists/listinfo/scst-devel

LEAVE A REPLY

Please enter your comment!
Please enter your name here