How to create and use the iSCSI target service on a QNAP NAS


Last modified date: 2023-07-20

"A quick, simple method of implementing network storage solutions with high ROI"


  1. An Introduction to iSCSI and its Benefits
    Before you get started
  2. Creating an iSCSI Target
  3. Creating an iSCSI LUN
  4. Managing iSCSI Targets and LUNs
  5. Connecting to an iSCSI target using Microsoft iSCSI initiator in Windows
  6. Connecting to an iSCSI target using globalSAN iSCSI initiator in Mac OS
  7. Connecting to an iSCSI Target using Open-iSCSI Initiator on Linux
    Additional Linux commands.
  8. Reference: A Comparison of Block-based and File-based LUN Features

1. An Introduction to iSCSI and its Benefits

iSCSI (Internet Small Computer System Interface) is an IP-based (Internet Protocol) storage networking standard for linking data storage facilities. By carrying SCSI commands over IP networks, iSCSI is used to facilitate location-independent data storage and retrieval over LANs (Local Area Networks) and WANs (Wide Area Networks).

iSCSI enables clients such as computers, servers, and virtual machines to use storage from your QNAP NAS as virtual disks. Clients can partition, format, and use virtual disks exactly like local disks, and then use them for storage expansion or as backup destinations.

Before you get started

iSCSI Target: An iSCSI storage server. In this tutorial the target is your NAS.

iSCSI initiator: An iSCSI client. Initiators connect to targets and use their storage.

Warning: Connecting more than one initiator to the same target might result in data loss or damage to the NAS disks.

2. Creating an iSCSI Target

  1. Go to Storage & Snapshot > iSCSI Storage.
    If this is the first time you have used iSCSI then QTS will prompt you to enable
    the iSCSI service.
  2. Click New iSCSI Target.

    The iSCSI Target Creation Wizard opens.
  3. Click Next.
  4. Specify a name and alias, and then click Next.
  5. Optional: Configure CHAP authentication, and then click Next.
    Initiators must authenticate with the specified username and password when
    connecting.
  6. Optional: Select Create an iSCSI LUN and map it to this target.
    After you have finished creating the target, QTS opens the Block-Based iSCSI 
    LUN Creation Wizard. Follow this wizard to create a block-based LUN.
  7. Click Apply.
    QTS creates the target. You can view it at Storage & Snapshots > iSCSI Storage > iSCSI Target List.

3. Creating an iSCSI LUN

An iSCSI LUN is a portion of storage space that can be utilized by initiators by connecting it to a target. There are two types of LUNs available in QTS.

Block-based LUNs use space from a storage pool
File-based LUNs use space from a volume.

Generally speaking, block-based LUNs should be used instead of file-based LUNs, as they support more snapshot and virtualization features. For a more detailed comparison, see the table at the end of this tutorial.

  1. Go to Storage & Snapshots > Storage/Snapshots.
  2. Create a LUN by performing one of the following methods.
LUN TypeSteps
Block-based
  1. Select a storage pool.
  2. Select Create > New Block-Based iSCSI LUN.
File-based
  1. Select a volume.
  2. Select Create > New File-Based iSCSI LUN.

In this tutorial we will create a block-based LUN.

The iSCSI creation wizard opens.

  1. Select a storage pool.
  2. Select the allocation type, and then click Next.
    Allocation TypeDescription
    Thick Instant AllocationQES allocates pool space when creating the LUN. This guarantees that the space will be available for connected iSCSI initiators.
    Thin provisioningQTS allocates storage pool space to a LUN only when it is needed. This offers greater flexibility as empty space is not wasted. However, QTS cannot save data to the LUN if the storage pool runs out of space.
  3. Specify the LUN name.
  4. Specify the LUN capacity.
  5. Optional: Configure advanced settings.
    For more information on a setting, click its tip.
  6. Click Next.
  7. Map the LUN to a target.
    Mapping an iSCSI LUN to a target allows iSCSI initiators to connect to it.
  8. Click Next.
  9. Review the summary, and then click Finish.

QTS creates the iSCSI LUN. You can view it at Storage & Snapshots > iSCSI Storage > iSCSI Target List.

4. Managing iSCSI Targets and LUNs

Go to Storage & Snapshots > iSCSI Storage > iSCSI Target List to view and modify iSCSI targets, iSCSI LUNs, and their mappings. Mapped LUNs appear nested under their target.

You can also go to Storage & Snapshots > Storage/Snapshots to view the storage status of block-based iSCSI LUNs.

Note:

  • File-based LUNs do not appear in the list at Storage & Snapshots > Storage/Snapshots.
  • The health status of a file-based LUN is always the same as its parent volume.

5. Connecting to an iSCSI target using Microsoft iSCSI initiator in Windows

Microsoft iSCSI Initiator is built into all versions of Windows, starting from Windows Vista and Windows Server 2008. You can download and install it on Windows 2003, Windows XP and Windows 2000.

  1. In Windows, locate and run iSCSI Initiator.
    Depending on your Windows version, you can search for it in the Windows program search or find it at Control Panel” > Administrative Tools.
  2. Optional: Click Yes if Windows prompts you to start the iSCSI service.
  3. Enter the NAS IP address under Targets > Target, and then click Quick Connect.

    iSCSI Initiator searches for available iSCSI targets and adds them to the Discovered Targets list.

  4. Optional: Add CHAP authentication credentials to the target.
    If you configured CHAP authentication on the NAS, then the target will have the status Inactive. You must specify the CHAP username and password to connect.
    1. Select a target in the Discovered Targets List.
    2. Click Connect.
    3. Click Advanced.
    4. Select Enable CHAP log on.
    5. Under Name, specify the CHAP username.
    6. Under Target Secret, specify the CHAP password.
    7. Click OK and then OK.

    The target now has the status Connected.
  5. Format the connected LUN as a disk in Windows.
    For this guide, we will be using Windows 10. For older Windows versions you must use Disk Management.
    1. Search for and run Storage.

    2. Click Manage Storage Spaces.

    3. Click Create a new pool and storage space.
    4. Select one or more iSCSI LUNs, and then click Create Pool.

    5. Specify the pool formatting options, and then click Create Storage Space.
      The iSCSI LUN space appears as a drive in Windows.



6. Connecting to an iSCSI target using globalSAN iSCSI initiator in Mac OS

Mac OS does not include an iSCSI initiator client by default. You will need to install third-party iSCSI initiator software to connect the iSCSI target on your QNAP NAS. For this tutorial we will use GlobalSAN iSCSI Initiator.

  1. In Mac OS, download and install globalSAN iSCSI Initiator for OS X.
    This software requires Mac OS X 10.4 or later. For details, see http://www.studionetworksolutions.com/globalsan-iscsi-initiator.
  2. Go to System Preferences.
  3. Double-click on globalSAN iSCSI initiator.
  4. Click +, and then select Portal/Group.

  5. Specify a name.
  6. Specify the NAS DNS name or IP address, and then click Add.

  7. Select a target in the left list.

  8. Select the IP address to use to connect to the iSCSI target.
  9. Click Connect.
  10. Optional: Click Initialize.
    If this is the first time you have connected to the target then Mac OS will prompt you to format the disk.

    The target’s status changes to Connected. The new drive is ready to use and appears on the Mac OS desktop.

7. Connecting to an iSCSI Target using Open-iSCSI Initiator on Linux

The Linux Open-iSCSI Initiator is a built-in package in Ubuntu 8.04 LTS and later. For more information on Ubuntu, see http://www.ubuntu.com

  1. Install the open-iscsi package.
    Run the following command.
# sudo apt-get install open-iscsi
  1. Optional: Add CHAP credentials to iscsid.conf.
    1. Edit the file.
      Run the following command.
# vi /etc/iscsi/iscsid.conf
    1. Add the target CHAP username under node.session.auth.username.
    2. Add the CHAP password under node.session.auth.password.
    3. Save and then close the file.
    4. Restart the open-iscsi service.
      Run the following command.
# /etc/init.d/open-iscsi restart
  1. Discover all iSCSI targets on the NAS.
    In this example the NAS IP address is 10.8.12.31 and the default iSCSI port is 3260.
    Run the following command.
# iscsiadm -m discovery -t sendtargets -p 10.8.12.31:3260
  1. Check the available iSCSI nodes.
    Run the following command.
# iscsiadm -m node
  1. Optional: Delete nodes that you do not want to connect to.
    Run the following command.
# iscsiadm -m node --op delete --targetname THE_TARGET_IQN
  1. Restart the open-iscsi service to log into all of the available nodes.
    Run the following command.
# /etc/init.d/open-iscsi restart

Linux displays a login message. Example:
Login session [iface: default, target: iqn.2004-04.com:NAS:iSCSI.ForUbuntu.B9281B, portal: 10.8.12.31,3260] [ OK ]

  1. Check the device status with dmesg.
    Run the following command.
# dmesg | tail
  1. Create a partition.
    In this example, the device name is /dev/sdb. Run the following command.
# fdisk /dev/sdb
  1. Format the partition.
    Run the following command.
# mkfs.ext3 /dev/sdb1
  1. Mount the file system.
    Run the following two commands.
# mkdir /mnt/iscsi

# mount /dev/sdb1 /mnt/iscsi/

The storage is now available to use.

Additional Linux commands.

ActionCommand
Test the I/O speed of the iSCSI LUN.# hdparm -tT /dev/sdb1
Discover targets on the host# iscsiadm -m discovery --type sendtargets --portal HOST_IP
Log into a target# iscsiadm –m node --targetname THE_TARGET_IQN --login
Log out of a target# iscsiadm –m node --targetname THE_TARGET_IQN --logout
Delete a Target# iscsiadm –m node --op delete --targetname THE_TARGET_IQN

8. Reference: A Comparison of Block-based and File-based LUN Features

Feature NameBlock-Based LUNFile-Based LUN
VAAI Full Copy
VAAI Block Zeroing✓  
VAAI Hardware Assisted Locking✓      
VAAI Thin Provisioning and Space Reclamation✓       
Thin provisioning
Space reclamation
Supported in: VMware ESXi with VAAI, Windows Server 2012 or later, Windows 8 or later
 
Microsoft ODX 
LUN Import/Export
LUN snapshotsYou must take a snapshot of the parent volume.

Was this article helpful?

80% of people think it helps.
Thank you for your feedback.

Please tell us how this article can be improved:

If you want to provide additional feedback, please include it below.

Choose specification

      Show more Less

      Choose Your Country or Region

      back to top