How to Install ISCSI-SERVER(TARGET) on CentOS 6.9

To Install iSCSI-SERVER(TARGET) on CentOS 6.9

ISCSI, expanded as Internet Small Computer System Interface, is an IP-based storage networking standard for linking data storage facilities like SAN (Storage Area Networks) . It’ s a block level Protocol used for sharing RAW Storage Devices over TCP/IP Networks, Sharing and accessing Storage over iSCSI, can be used with existing IP and Ethernet networks such as NICs, Switched, Routers etc. In this tutorial, the installation of iSCSI &ndash server(Target)is covered. 

 

My setup 

Ip addr = 1962.168.7.240
Hostname= linuxhelp.com

 

Installing iSCSI-SERVER(TARGET)

In order to install ISCSI-SERVER, you need to install the ISCSI target utils in prior. So, run the following command for the same purpose. 

[root@linuxhelp ~]# yum install scsi-target-utils -y
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: ftp.iitm.ac.in
 * extras: ftp.iitm.ac.in
 * updates: ftp.iitm.ac.in
Resolving Dependencies
-->  Running transaction check
--->  Package scsi-target-utils.x86_64 0:1.0.24-18.el6 will be installed
-->  Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================================================
 Package                                     Arch                             Version                                   Repository                      Size
=============================================================================================================================================================
Installing:
 scsi-target-utils                           x86_64                           1.0.24-18.el6                             base                           177 k

Transaction Summary
=============================================================================================================================================================
Install       1 Package(s)

Total download size: 177 k
Installed size: 459 k
Downloading Packages:
scsi-target-utils-1.0.24-18.el6.x86_64.rpm                                                                                            | 177 kB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : scsi-target-utils-1.0.24-18.el6.x86_64                                                                                                    1/1 
  Verifying  : scsi-target-utils-1.0.24-18.el6.x86_64                                                                                                    1/1 

Installed:
  scsi-target-utils.x86_64 0:1.0.24-18.el6                                                                                                                   
Complete!

 

Once it is done, you need to start target service with the help of the following command. 

[root@linuxhelp ~]# /etc/init.d/tgtd start

 

Later, check the status of target service by using the following command. 

[root@linuxhelp ~]# /etc/init.d/tgtd status
tgtd (pid 3297 3294) is running...


After that, you need to create new partition using fdisk. So, first list the fdisk as follows.

[root@linuxhelp ~]# fdisk -l 

Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000635e2

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        3188    25600000   83  Linux
/dev/sda2            3188        3443     2048000   82  Linux swap / Solaris
/dev/sda3            3443        3704     2097152   8e  Linux LVM
Partition 3 does not end on cylinder boundary.

Disk /dev/mapper/vg1-lv1: 1610 MB, 1610612736 bytes
255 heads, 63 sectors/track, 195 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x2ce40f21

               Device Boot      Start         End      Blocks   Id  System
/dev/mapper/vg1-lv1p1               1         196     1569792    7  HPFS/NTFS
Partition 1 has different physical/logical endings:
     phys=(194, 254, 63) logical=(195, 111, 44)

 


Now, you need to create a new partition in sda, so enter into it. Give all the below mentioned options. 

[root@linuxhelp ~]# fdisk -cu /dev/sda

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Selected partition 4
First sector (59492352-62914559, default 59492352): 
Using default value 59492352
Last sector, +sectors or +size{K,M,G} (59492352-62914559, default 62914559): +2G

Command (m for help): t 
Partition number (1-4): 4
Hex code (type L to list codes): 8e
Changed system type of partition 4 to 8e (Linux LVM)

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.


After creating the new partition, you need to reboot the machine, so that you can create LVM later.  Now, you need to create physical volume as follows. 

[root@linuxhelp Desktop]# pvcreate /dev/sda3
  Physical volume " /dev/sda3"  successfully created

 

After that, you need to create a volume group as follows. 

[root@linuxhelp Desktop]# vgcreate vg1 /dev/sda3
Volume group " vg1"  successfully created

 

Later, you should create a logical volume. 

[root@linuxhelp Desktop]# lvcreate -L 1.5G -n lv1 vg1
Logical volume " lv1"  created.

We have created Logical Volumes and ready to use with LUN, but we need to define the LUNs in target configuration, only then it will be available for client machines (Initiators).


So, you should open and edit Targer configuration file located at ‘ /etc/tgt/targets.conf’ with any editor of your choice. Here Vim editor is used. Open the file. 

[root@linuxhelp Desktop]#  vim /etc/tgt/targets.conf

 

And add the following lines to it.

< target iqn.20155555-07.com.linuxhelp:tgt1> 
backing-store /dev/vg1/lv1
< /target> 

 

 

Next, you need to reload target daemon as follows.

[root@linuxhelp Desktop]#  /etc/init.d/tgtd reload
Updating SCSI target daemon configuration:                 [  OK  ]


And then, verify the available LUNs using the following command. 

[root@linuxhelp Desktop]# tgtadm --mode target --op show
Target 1: iqn.20155555-07.com.linuxhelp:tgt1
    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
            Backing store type: null
            Backing store path: None
            Backing store flags: 
        LUN: 1
            Type: disk
            SCSI ID: IET     00010001
            SCSI SN: beaf11
            Size: 1611 MB, Block size: 512
            Online: Yes
            Removable media: No
            Prevent removal: No
            Readonly: No
            Backing store type: rdwr
            Backing store path: /dev/vg1/lv1
            Backing store flags: 
    Account information:
    ACL information:
        ALL

Finally, give the ISCSI_client (initiator) file link.  With this, the complete installation of ISCSI-SERVER(TARGET) on CentOS 6.9 is complete. 

FAQ
Q
What is SPC-3 (SCSI-3)? Persistent Reserve?
A
Persistent Reserve refers to a set of Small Computer Systems Interface-3 (SCSI-3) standard commands and command options which provide SCSI initiators with the ability to establish, preempt, q
Q
What do I need to use iSCSI?
A
You will need iSCSI initiators, either software initiators or HBA (Host Bus Adapter). For Windows operating system, you can download Microsoft iSCSI Software initiator from Microsoft’s web si
Q
Where can I find the documentation for the Microsoft iSCSI Software Target 3.2?
A
iSCSI Software Target 3.2 documentation is available through OEMs with the purchase of an appliance running Windows Storage Server 2008 and the iSCSI Software Target 3.2 (an optional add-on).
Q
How do I create iSCSI targets on a failover cluster?
A
1. Step-by-step instructions are provided in the iSCSI Software Target 2.help file, which is available from the Help menu in the iSCSI Software 3.Target snap-in. Begin with the topic titled “Configure
Q
Which initiators work with iSCSI Software Target 3.2?
A
We tested the following initiators:
1.Microsoft iSCSI Initiator 2.07 and 2.08 in Windows Server 2003

2.Microsoft iSCSI Initiator in Windows Server 2008 SP1

3.Microsoft iSCSI Initiator in W