FreeNAS 11.2 iSCSI with XCP-ng 7.6.0 Lab Setup

In an effort to find a more open alternative to ESXi I’ve been labbing with XCP-ng. Setting it up with an iSCSI connection to FreeNAS is rather simple, here I’ll explain how I’ve done it in hopes it can help others out there.

I’ll be using fresh installs of XCP-ng and FreeNAS with a storage pool already created for this guide. Also I’ll use XCP-ng Center so a Windows system is required.

If you’re still in the planning phase of your FreeNAS system, you can browse NAS Hard Drives on amazon here!

FreeNAS iSCSI Setup

It’s good practice to have your iSCSI network physically separate from other networks. The data going across this network is sensitive and directly effects the performance and stability of the VMs. Because of this I have dedicated ports on my XCP-ng and FreeNAS box for the iSCSI link.

The first step on FreeNAS is to create a zvol for your iSCSI share to use. Under Storage > Pools find the pool you want to use and click the cog on the top right, then Add Zvol.

Name your Zvol and select what size, then click Create. It’s a good idea to not use all your disk space as ZFS really doesn’t like that with iSCSI. Keep it under 80% to be safe.

We need to configure iSCSI now and it’s a little more involved than SMB or NFS shares. Go to Sharing > Block (iSCSI).

There are 5 things we need to configure as a bare minimum to get iSCSI working.

  1. Click Portals > Add and Save without changing anything. This means there will be no authentication method and it’ll listen to any IP from any subnet trying to connect. Not good in production but simple for LAB use.
  2. Next is Initiators > Add and again click Save. The defaults allow all, that’s fine for us.
  3. Targets > Add now we have to fill in some boxes. Name your target, pick a Portal Group ID and Initiator Group ID then save.
  4. Under Extents > Add pick and extent name then under Device pick your zvol you created earlier.
  5. It’s time to link the target and extent. Go to Associated Targets > Add then pick the target and extent you created in the drop down boxes. Give it a LUN ID (1 or any number is fine).

That’s iSCSI configured, now we can enable it! On the left, go to Services and turn on iSCSI. Tick the Start Automatically box too while you’re at it.

Network Setup

Lets setup the network connection between the two systems now. I’ll have a link directly between them, as in an ethernet cable from FreeNAS directly plugged in to XCP-ng. Because there are only 2 hosts we can use a /30 subnet.

On the left panel go Network > Interfaces then Add. Enter a valid address for your network and Save.


XCP-ng iSCSI Setup

Open up XCP-ng Center,Select your VM host, and go to the Network tab.  At the bottom of the page click Configure.

In the new window that pops up on the left hand side click on Add IP address. Make sure it’s using the right network adapter then tick the Use these settings: box and type in an IP Address in the same subnet as the FreeNAS one you intend to use for iSCSI.

Storage

As of writing this there is a bug in 7.6 that prevents you adding iSCSI from within XCP-ng center. It gives the error “the sr could not be connected because the driver gfs2 was not recognised” even when you’re using LVM instead of gfs2. Because of this there are 2 other ways to go about adding iSCSI storage. On the metal using it’s interface directly or through Xen Orchestra. Both ways work and I’ll cover configuring it through XCP-ng directly.

  1. On the XCP-ng screen go down to Disks and Storage Repositories
  2. Then Create New Storage Repository
  3. Enter your username and password.
  4. Choose Software iSCSI
  5. Enter the IP Address of the FreeNAS box in Hostname of iSCSI Target and optionally pick a Name.
  6. Press enter on the next two windows and F8 on the final one. We’re done, the iSCSI SR is added.

At this point you can create a VM on the iSCSI SR. Make sure when you create the Virtual Disk that it’s on the iSCSI SR.


Conclusion

Now you have all the benefits of XFS storage and FreeNAS support/usability. It’s an excellent setup if you have a NAS in use and some budget 10gbit hardware. If you’re interested on doing this with ESXi and FreeNAS I have a write up on that too, check it out here!

Share this post

Share on facebook
Share on google
Share on twitter
Share on linkedin
Share on pinterest
Share on print
Share on email

Join the Conversation

2 Comments

Leave a comment

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