• Books
  • Movies
  • Sports
    • Football
    • Hockey
  • Tech
    • Apps
    • Networking
    • Virtualization
    • Linux
      • CentOS
      • Ubuntu
    • MacOS
    • Microsoft
  • Recipes
  • Family
  • About
  • Home.Lab Project
    • Home.Lab Hardware
      • Storage CentOS Server (Phoenix)
      • Centos Hypervisor (Cyclops)
      • CentOS Hypervisor (Wolverine)
      • Homegrown SuperMicro ESXi Hypervisor (Deadpool)
    • Networking
      • Hypervisor Network
      • Juniper SSG5 Configuration
      • Security Zone Configuration
    • Virtual Machines
      • Black Widow (RHEL 6.4)
    • Hypervisor Technologies
    • Tutorials
      • Creating an iSCSI Target in CentOS 6.4
      • Managing Linux Hypervisors through Windows
Home » Tech » Linux » CentOS » Creating an iSCSI Target in CentOS 6.4

Creating an iSCSI Target in CentOS 6.4

Posted on July 23, 2013 by Vitaly Posted in CentOS, Linux, Networking, Tech, Virtualization

There are two widely used network file systems for virtual machines: iSCSI and NFS. As far as which is better you will find various flame wars throughout the web akin to Ford vs. Chevy. For small environments like ours they server the same purpose. One can make the argument that some network switches are optimized for iSCSI traffic, but in my experience their performance is similar. There some underlying file locking and read/write differences at the block level between the two file systems, but we will dive into those later. This page will walk through how to create an ISCSI target and assign it to an LVM disk image so that a hypervisor can mount it and start using it as a block device. As with all my home lab configs, I keep SELinux disabled (which is scorned by purists, but it is a complication in small environments — mainly because I have not taken the time to learn its intricacies — yet :)).

Install Scsi-Target-Utils
Start by installing the scsi-target-utils package.

# yum install scsi-target-utils

Configuration
Make sure that port 3260 is open for incoming connections. This can be done by manually modifying iptables, or running system-config-firewall. Make sure to restart iptables after the change.
Start the scsi target tools and make sure that they start on boot.

# service tgtd start
# chkconfig tgtd on

Three baby steps to walking
1. Create a new target device

# tgtadm -lld iscsi --mode target --op new --tid=1 --targetname iqn.2013-05.lab.home:storage.punisher

2. Assign to a logical unit (you can assign to a disk partition, a whole disk, an LVM logical volume, or a file). In our case, we will assign to an LVM logical partition, and it will be to LUN (logical unit number) #1.

# tgtadm --lld iscsi --mode logicalunit --op new --tid 1 --lun 1 -b /dev/vg_iscsi_share/punisher

3. Assign password or subnet permissions

# tgtadm --lld iscsi --mode target --op bind --tid 1 -I 10.0.0.0/24 ### permit anyone on the 10.0.0.0/24 subnet to connect freely
# tgtadm --lld iscsi --mode account --op new --user ''iscsipunisher'' --password ''punisher4san'' ### permit specific CHAP requirements
# tgtadm --lld iscsi --mode account --op bind --tid 1 --user ''iscsipunisher'' ### assign iscsipunisher account to target ID #1

Once the above is activated,  the iSCSI initiator should be able to connect to the target. This will create the following table in the /etc/tgt/targets.conf file:

target iqn.2013-05.lab.home:storage.punisher
   backing-store /dev/vg_iscsi_share/punisher
   initiator-address 10.0.0.0/24
/target

The steps to actually connect to the target will be listed in the steps of firing up the Punisher virtual machine.

View the Output
To view what targets are presently active at any time, run the command tgtadm –mode target –op show, which in my case returns:

[root@Phoenix ~]# tgtadm --mode target --op show
Target 1: iqn.2013-05.lab.home:storage.punisher
    System information:
        Driver: iscsi
        State: ready
    I_T nexus information:
        I_T nexus: 3
            Initiator: iqn.1998-01.com.vmware:localhost-62d21772
            Connection: 0
                IP Address: 10.0.0.5
    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: 85899 MB, Block size: 512
            Online: Yes
            Removable media: No
            Prevent removal: No
            Readonly: No
            Backing store type: rdwr
            Backing store path: /dev/vg_iscsi_share/punisher
            Backing store flags:
    Account information:
    ACL information:
        10.0.0.0/24
« Managing Linux Hypervisors through Windows
Home.Lab Hardware »

Leave a comment Cancel reply

Your email address will not be published. Required fields are marked *

Around the Way

July 2013
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
293031  
« Apr   Aug »

Recent Posts

  • Getting spice client console working in Virt-Manager for Mint 19
  • Using RealVNC in Windows to connect to a KVM session
  • Switching the default user when using SSH
  • X-Men Apocalypse Movie Review
  • Getting Virt-Manager working in Ubuntu 16.04 LTS bypassing openssh-askpass

Old School

  • September 2018
  • August 2016
  • July 2016
  • June 2016
  • April 2016
  • February 2016
  • January 2016
  • August 2013
  • July 2013
  • April 2013
  • February 2013
  • December 2012
  • November 2012

Archives

  • September 2018
  • August 2016
  • July 2016
  • June 2016
  • April 2016
  • February 2016
  • January 2016
  • August 2013
  • July 2013
  • April 2013
  • February 2013
  • December 2012
  • November 2012

Recent Posts

  • Getting spice client console working in Virt-Manager for Mint 19
  • Using RealVNC in Windows to connect to a KVM session
  • Switching the default user when using SSH
  • X-Men Apocalypse Movie Review
  • Getting Virt-Manager working in Ubuntu 16.04 LTS bypassing openssh-askpass
© Chubby Apple