FreeNAS 9.3 - iSCSI
Jul 16, 2015

iSCSI allows you to connect network storage to a local machine over TCP and have it show up like a normal disk in the operating system. This hopefully simple guide will walk through the process of setting up iSCSI in FreeNAS and connecting to the storage in Debian 8 and Windows 8.1.

For better performance multiple NICs can be utilized with MPIO (multipath). It does not seem possible to use LACP (link aggregation) to achieve better performance with iSCSI. MPIO must be used. This guide will be updated for multipath if I ever decide to get a quad-port gigabit NIC.

There are several reasons to use iSCSI:

  1. Virtual machine storage Instead of using local storage for VMs you can setup an iSCSI target on the host and give the VM its own LV to use (LVM). This gives the benefits of ZFS and not needing internal storage.

  2. Add more storage without the overhead of SMB, NFS, or AFP

Downsides:

  1. Performance will not be as good as locally connected storage in most cases.

  2. Each iSCSI target is limited to one client. This means the target cannot be accessed by multiple machines at once where an SMB, NFS, or AFP share can be.


Getting Started

You will need FreeNAS and a Debian client or Windows client.


FreeNAS

  1. Log into your FreeNAS server

  2. Select “Storage” from the top menu bar

  3. From there select your local zvol and select “Create zvol” from the bottom

  4. Give your zvol a name and size

  5. Select “Services” from the top menu bar

  6. Turn on “iSCSI”

  7. Once iSCSI is enabled, click on the wrench beside iSCSI

  8. Select the “Portals” tab

  9. Select “Add Portal”

  10. Click “OK”

  11. Go to the next tab “Initiators”

  12. Select “Add Initiator” and click “OK”

  13. Select “Authorized Access” and click “Add Authorized Access” This menu is for CHAP authentication. You should add a user for each iSCSI target. Give it a strong password.

  14. Next, select “Targets” and add a new iSCSI target

  15. Finally, add a LUN by selecting “Associated Targets”


Windows iSCSI Setup

  1. Open the iSCSI Initiator

  2. On the “Targets” tab enter the IP address of your FreeNAS server and select “Quick Connect…”

  3. This will give you a list of all the targets that were discovered.

  4. Click “Done”

  5. Select the target you wish to connect to and click “Connect”

  6. From here you will need to set up CHAP authentication. Select “Advanced…” -> “Enable CHAP log on”

    The password is the CHAP secret you set in FreeNAS.

  7. “OK” -> “OK”

    If you did everything right it will now say “Connected” under “Discovered targets”.

  8. Navigate to the “Volumes and Devices” tab and click “Auto Configure”. You should see a new volume appear in the dialog.

You can now format the new volume by going into “Disk Management”.


Debian iSCSI Setup

  1. Install open-iscsi apt-get install open-iscsi multipath-tools

  2. Enable CHAP and automatic startup /etc/iscsi/iscsid.conf
    node.startup = automatic
    node.session.auth.authmethod = CHAP
    node.session.auth.username = USERNAME
    node.session.auth.password = PASSWORD
    
  3. Restart open-iscsi systemctl restart open-iscsi

  4. Discover iSCSI targets iscsiadm -m discovery -t sendtargets -p IP_ADDRESS

  5. Log into all possible iSCSI targets iscsiadm -m node --login

    You should now be able to see a new block device show up in fdisk -l.

Logging out of all iSCSI targets: iscsiadm -m node -u


Benchmarks

These benchmarks are from inside a KVM virtual machine with an LV on the FreeNAS server. Writeback caching is disabled and it is connected via 1Gb Ethernet.

root@:~# ioping -R .
--- . (ext4 /dev/disk/by-uuid/646d39c1-bc59-40ad-9048-ea79d04de593) ioping statistics ---
9559 requests completed in 3000.1 ms, 4051 iops, 15.8 mb/s
min/avg/max/mdev = 0.2/0.2/2.2/0.0 ms

root@:~# ioping -c 10 .
4096 bytes from . (ext4 /dev/disk/by-uuid/646d39c1-bc59-40ad-9048-ea79d04de593): request=1 time=0.5 ms
4096 bytes from . (ext4 /dev/disk/by-uuid/646d39c1-bc59-40ad-9048-ea79d04de593): request=2 time=0.5 ms
4096 bytes from . (ext4 /dev/disk/by-uuid/646d39c1-bc59-40ad-9048-ea79d04de593): request=3 time=0.7 ms
4096 bytes from . (ext4 /dev/disk/by-uuid/646d39c1-bc59-40ad-9048-ea79d04de593): request=4 time=0.7 ms
4096 bytes from . (ext4 /dev/disk/by-uuid/646d39c1-bc59-40ad-9048-ea79d04de593): request=5 time=0.8 ms
4096 bytes from . (ext4 /dev/disk/by-uuid/646d39c1-bc59-40ad-9048-ea79d04de593): request=6 time=0.9 ms
4096 bytes from . (ext4 /dev/disk/by-uuid/646d39c1-bc59-40ad-9048-ea79d04de593): request=7 time=0.6 ms
4096 bytes from . (ext4 /dev/disk/by-uuid/646d39c1-bc59-40ad-9048-ea79d04de593): request=8 time=0.6 ms
4096 bytes from . (ext4 /dev/disk/by-uuid/646d39c1-bc59-40ad-9048-ea79d04de593): request=9 time=0.5 ms
4096 bytes from . (ext4 /dev/disk/by-uuid/646d39c1-bc59-40ad-9048-ea79d04de593): request=10 time=0.6 ms

--- . (ext4 /dev/disk/by-uuid/646d39c1-bc59-40ad-9048-ea79d04de593) ioping statistics ---
10 requests completed in 9009.1 ms, 1565 iops, 6.1 mb/s
min/avg/max/mdev = 0.5/0.6/0.9/0.1 ms

root@:~# dd if=/dev/zero of=test bs=8k count=128k conv=fdatasync
131072+0 records in
131072+0 records out
1073741824 bytes (1.1 GB) copied, 10.5501 s, 102 MB/s
Comments