Linux — iSCSI Target using open-iscsi

I recently set up an iSCSI SAN for use with VMWare Server. The set up was basically a Linux Ubuntu Server target with 2 network links to a single VNWare Server as the integrator. I also included iSCSI multi-pathing by enabling it on the initiator (VMWare Server).

This is how I set up an Linux SAN Target with iSCSI, interfacing with VMWare 5.1. as the iSCSI Initiator.

Part 1: Setting up our iSCSI Target with Linux

  1. Let’s set up our network interfaces that will be used for the SAN connection.
    Plain text
    Copy to clipboard
    Open code in new window
    EnlighterJS 3 Syntax Highlighter
    vi /etc/network/interfaces
    #closed circuit storage network
    auto eth0
    iface eth0 inet static
    address 192.168.255.101
    netmask 255.255.255.252
    auto eth1
    iface eth1 inet static
    address 192.168.255.201
    netmask 255.255.255.252
    vi /etc/network/interfaces #closed circuit storage network auto eth0 iface eth0 inet static address 192.168.255.101 netmask 255.255.255.252 auto eth1 iface eth1 inet static address 192.168.255.201 netmask 255.255.255.252
    vi /etc/network/interfaces
    #closed circuit storage network
    auto eth0
    iface eth0 inet static
            address 192.168.255.101
            netmask 255.255.255.252
    
    auto eth1
    iface eth1 inet static
            address 192.168.255.201
            netmask 255.255.255.252
    
    

    I chose two separate /30 networks. If you remember a /30 only has 2 usable host IPs. This ensures that our iSCSI Target and Imitator are the only IPs on the network. No use in using a larger network, as it will be wasted with our Point-to-Point Ethernet link.

  2. Creating LUNs. I decided to use a flat file for my LUN images. You can use other storage devices, such as a /dev/sdX devices,etc. I just thought it would be easier to keep track of the LUNs if they were files…not sure if this is best practice…anyway!
    Plain text
    Copy to clipboard
    Open code in new window
    EnlighterJS 3 Syntax Highlighter
    mkdir LUNs
    cd LUNs
    dd if=/dev/zero of=LUN02.img bs=1024k count=10000
    10000+0 records in
    10000+0 records out
    10485760000 bytes (10 GB) copied, 103.744 s, 101 MB/s
    mkdir LUNs cd LUNs dd if=/dev/zero of=LUN02.img bs=1024k count=10000 10000+0 records in 10000+0 records out 10485760000 bytes (10 GB) copied, 103.744 s, 101 MB/s
    mkdir LUNs
    cd LUNs
    dd if=/dev/zero of=LUN02.img bs=1024k count=10000
    
    10000+0 records in
    10000+0 records out
    10485760000 bytes (10 GB) copied, 103.744 s, 101 MB/s
    

    This will create a zero’d LUN01.img file with the size of 10GBs

  3. Prepare the LUN, and partition it.
    Plain text
    Copy to clipboard
    Open code in new window
    EnlighterJS 3 Syntax Highlighter
    fdisk LUN01.img
    fdisk LUN01.img
    fdisk LUN01.img

    Create a new partition 1, type fb (VMFS)

  4. On the iSCSI target, install the following packages:
    Plain text
    Copy to clipboard
    Open code in new window
    EnlighterJS 3 Syntax Highlighter
    apt-get install iscsitarget iscsitarget-dkms
    apt-get install iscsitarget iscsitarget-dkms
    apt-get install iscsitarget iscsitarget-dkms

    This will install the necessary packages to run the iSCSI target service. Also install the following packages for troublshooting purposes. These packages can be used to impersonate an iSCSI initirator connection.

    Plain text
    Copy to clipboard
    Open code in new window
    EnlighterJS 3 Syntax Highlighter
    apt-get install open-iscsi open-iscsi-utils
    apt-get install open-iscsi open-iscsi-utils
    apt-get install open-iscsi open-iscsi-utils
  5. Start the iSCSI Target service and make sure it starts successfully.
    Plain text
    Copy to clipboard
    Open code in new window
    EnlighterJS 3 Syntax Highlighter
    /etc/init.d/iscsitarget start
    /etc/init.d/iscsitarget start
    /etc/init.d/iscsitarget start
  6. Edit the ietd.conf file to identify the LUNs you will advertise.
    Plain text
    Copy to clipboard
    Open code in new window
    EnlighterJS 3 Syntax Highlighter
    vi /etc/ietd/ietd.conf
    Target iqn.2001-04.com.example:storage.lun01
    Lun 0 Path=/{mount_location}/LUNs/LUN01.img,Type=fileio
    Alias LUN01
    vi /etc/ietd/ietd.conf Target iqn.2001-04.com.example:storage.lun01 Lun 0 Path=/{mount_location}/LUNs/LUN01.img,Type=fileio Alias LUN01
    vi /etc/ietd/ietd.conf
    Target  iqn.2001-04.com.example:storage.lun01
            Lun 0 Path=/{mount_location}/LUNs/LUN01.img,Type=fileio
            Alias LUN01
    
  7. Restart the iSCSI Target Service:
    Plain text
    Copy to clipboard
    Open code in new window
    EnlighterJS 3 Syntax Highlighter
    /etc/init.d/iscsitarget restart
    /etc/init.d/iscsitarget restart
    /etc/init.d/iscsitarget restart

Part 2: Setting up VMWare ESXi 5.1

  1. Assuming you have installed VMWare and have two(2) Ethernet interfaces to use to hook into a SAN network. We will start by setting up the Network Adapters.
    IP the two(2) Ethernet Network Adapters

    (Do this for both Network Adapters) 
  2. You should now see a iSCSI Storage Adapter Available.
  3. Right-Click on the iSCSI Adapter and go to Properties. Here we have to set the iSCSI Discovery Address.
  4. Click on the iSCSI Adapter, you should see in the bottom pane the LUN being advertised by our iSCSI Target.

    NOTICE: We have 2 paths going to our LUN?? (This is a good thing! We have to set up multipathing…but later!)
  5. Provision the LUN Storage to be used with VMWare.
    Under Storage, click on the far Right the “Add Storage” Link and follow the following prompts to provision the LUN for use with VMWare.

    Wait for the drive to be provisioned.
  6. You should now have a Storage LUN available for use with VMWare.
  7. Set up Mutlipathing..
    Click on the LUN under Storage. Right Click and go to Properties.

    Next, click on Manage Paths.Click on Manage Paths, in the following prompt, change

Part 3: Limiting iSCSI Access

You can limit the access of the iSCSI connection by editing the initiator.allow and/or targets.allow.

  • Edit the initiators.allow, this file limits the allowed initiators by either their IQN, IP, or IP Subnet.
    Plain text
    Copy to clipboard
    Open code in new window
    EnlighterJS 3 Syntax Highlighter
    vi /etc/ietd/initiators.allow
    ALL ALL
    vi /etc/ietd/initiators.allow ALL ALL
    vi /etc/ietd/initiators.allow
    ALL ALL
    
  • Edit the targets.allow, this file limits the allowed targets. (I’ve limited to the follow IPs so the only IPs used on the Target to those that are part of the Multipathing that we set up from above.)
    Plain text
    Copy to clipboard
    Open code in new window
    EnlighterJS 3 Syntax Highlighter
    vi /etc/ietd/targets.allow
    #storage networks /30s
    ALL 192.168.255.101,192.168.255.201
    vi /etc/ietd/targets.allow #storage networks /30s ALL 192.168.255.101,192.168.255.201
    vi /etc/ietd/targets.allow
    #storage networks /30s
    ALL 192.168.255.101,192.168.255.201
    

Source: