iSCSI (Internet Small Computer System Interface) is a low level network protocol which allows a client machine (known as the Initiator) to control storage on a server (known as the Target). High level network file systems like CIFS (Common Internet File System), which is used by Windows to map network drives, let the server (and its underlying operating system) handle all the low level access to the network accessible storage. The Windows client doesn’t know anything about the sectors, tracks and heads of the remote storage. It simply asks for data from a file which is then sent by the server.
With iSCSI the control is low level. So low level in fact, that the disk needs to be partitioned and formatted by the Initiator. When the Initiator wants some data from the network storage it sends the low level commands to read and write data from the different sectors of the disk. The results of those operations are returned by the Target over the network to the Initiator. If you are thinking that iSCSI sounds a lot like SCSI, the disk interface often used on server, then you are right. SCSI sends low level commands down a cable to control a hard disk. iSCSI sends SCSI like commands over the network to control a hard disk connected to the iSCSI server.
FreeNAS 8 can act as an iSCSI Target and can allow a remote Initiator to control a whole hard disk or present a file (created on the existing storage) as if it was a hard disk. For this tutorial I will assume you have a FreeNAS system installed with at least one volume configured. For more information on installing FreeNAS and setting up volumes see my previous tutorial here: Build a Simple NAS Setup with FreeNAS 8.
Configure iSCSI Target
To configure the iSCSI service, click Services on the toolbar below the FreeNAS logo and then click the small wrench icon next to iSCSI. Click Portals on the menu bar at the top of the iSCSI tab. Click Add Portal. Accept the default 0.0.0.0:3260 and click OK.
Click Authorized Initiator and then “Add Authorized Initiator”. Accept the defaults of ALL and ALL by clicking on OK.
The next step is to create an extent. This will be the hard disk presented to the Initiator. In fact, it is a file on the FreeNAS server which will act as a virtual hard disk. The size of the file created will determine the size of the iSCSI hard disk.
Click Extents and Add Extent. Add an Extent Name (eg. extent1). Then add a full pathname for the file extent in the Path to the extent field. Click Browse to find your storage (eg. /mnt/store) and then add a filename to the end (eg. /mnt/store/extent1).
Now enter a size for the extent which is in bytes. 10GB is 10,737,418,240 bytes, 100GB is 107,374,182,400 bytes and so on. (Note: You mustn’t enter the commas). Click OK.
When an iSCSI Initiator connects to an iSCSI server it connects to a Target. To create a Target click Targets and Add Target. Enter a Target Name (eg. target1), select Disk from the Type drop down menu. Select 1 for the Portal Group ID and the Initiator Group ID and click OK.
Finally the Target needs to be associated with the Extent so that when the iSCSI Initiator connects to the target it uses the corresponding extent. Click Associated Targets and Add Extent to Target. Select target1 from the Target drop down list and extent1 from the Extent drop down list. Click OK.
To enable the iSCSI service, click Services and click the iSCSI Off switch to make it go from “Off” to “On.”
Connecting from Windows 7
The iSCSI Target is now all configured. iSCSI Initiator software is available for most platforms including Mac OS X and Linux. Windows Vista and Windows 7 has it built-in to the OS. Windows XP and Windows 2003 server users can download the Microsoft iSCSI Software Initiator from
Microsoft Downloads.
In Windows 7, click the Start Menu icon and type iSCSI in the search box. Click iSCSI Initiator. In the Quick Connect section enter the IP address of the FreeNAS server in the “Target:” field and click Quick Connect…
The “Quick Connect” dialog will appear listing a discovered target. The name of the target will be the same as the name set in the “Target Global Configuration” section of the iSCSI tab on the FreeNAS server (eg. iqn.2011-03.example.org.istgt). Click
Done.
On the iSCSI Initator Properies window click the discovered target (eg. iqn.2011-03.example.org.istgt:target1) and click Connect. Wait for the “Connect To Target” dialog and click OK.
Windows is now connected to the iSCSI drive (which is really a file based extent on the FreeNAS server). To use the drive start the Disk Management program by typing diskmgmt.msc in the search box of the Start Menu and click diskmgmt.msc.
The first time the Disk Management program starts it will detect the uninitialized iSCSI drive and prepare to initialize it. Click OK.
The disk will then become available for formatting etc. To format it, right click on the Unallocated partition and click New Simple Volume… Go through the “New Simple Volume Wizard” accepting the defaults. Note you may want to assign a different drive letter other than the one suggested by Windows.
Once the format is complete the drive will appear just like any other hard drive in Windows Explorer.
Conclusion
FreeNAS 8 can act as an iSCSI Target for several iSCSI devices with the only limit being storage space available. Assuming your FreeNAS server has the memory and CPU resources available and that your network can support the throughput, FreeNAS offers an easy way to deploy iSCSI on your home or business network.