How to set up and use iSCSI target on Linux



The business-level Synology NAS servers is able to provide iSCSI service, which means by using the iSCSI Target Service, a Synology NAS seamlessly acts as dedicated storage server to provide iSCSI Target storage, which will be seen virtually as a local hard drive for as many clients as need be; only they are all stored in a centralized Synology server. Advanced management functions such as Thin Provisioning, iSCSI LUN Backup, MC/S (Multiple Connections per Session) and MPIO (Multiple Path I/O) are available on Synology NAS to strengthen the usability and stability of a network storage environment.

This article will guide you through the process of setting up iSCSI target connection from Linux server to your Synology NAS.

What is iSCSI?
iSCSI is an Internet Protocol based storage networking standard for linking data storage facilities. By carrying SCSI commands over IP networks, iSCSI can facilitate data transfers over local area networks (LANs), wide area networks (WANs), or the Internet. Through iSCSI, the space on storage server will be regarded as local disks by client's operation system. But in reality, all data transferred to the disk are actually transferred over network to the storage server.

What is iSCSI Target and LUN?
In SCSI terminology, A LUN (logical unit number) represents an individually addressable (logical) SCSI device that is part of a physical SCSI device (called "Target"). An iSCSI environment emulates the connection to a SCSI hard disk. An iSCSI Target is like a connection interface, and LUNs are essentially numbered disk drives. When an iSCSI Target is connected by an iSCSI initiator (a client), all the LUNs mapped to the iSCSI Target are virtually attached to the client's operation system. Therefore, Initiators can establish and manage file systems on iSCSI LUNs, as they would a raw SCSI or IDE hard drive.


  1. Before You Start
  2. Set up iSCSI target on Linux
  3. Unmount the iSCSI Target and stop iSCSI discovery

1. Before You Start

This article assumes you have performed the following tasks:

  • Set up your Synology NAS and installed Synology DiskStation Manager (DSM) (see the Quick Installation Guide for your device available at Synology's Download Center).
  • Created volumes (see here) and shared folders (see here).
  • Created iSCSI LUNs and Targets on your Synology NAS.

2. Set up iSCSI target on Linux

This section will guide you through the process of setting up an iSCSI target on Linux. Command inputs are shown in bold.

  1. Use the yum command to install the iSCSI Initiator software.
  2. [root@Synology-FedoraVM /]# yum install iscsi-initiator-utils
    Loaded plugins: presto, refresh-packagekit
    Setting up Install Process
    Resolving Dependencies
    --> Running transaction check
    ---> Package iscsi-initiator-utils.i686 0: set to be installed
    --> Finished Dependency Resolution
    iscsi-initiator-utils.i686 0:

    Note: The previous command is for installing the iSCSI Initiator on Fedora. To install the iSCSI Initiator on Ubuntu, please enter apt-get install open-iscsi instead.

  3. Use the vi command to set node.startup to automatic.
  4. [root@Synology-FedoraVM /]# vi /etc/iscsi/iscsid.conf

    node.startup = automatic

  5. Use the iscsiadm command to start the iSCSI discovery.
  6. [root@Synology-FedoraVM /]# iscsiadm -m discovery -t st -p
    Starting iscsid: [ OK ],0 iqn.2010-10.synology-iscsi:newvirtualdisk.1,0 iqn.2010-10.synology-iscsi:newvirtualdisk.1

    [root@Synology-FedoraVM /]# iscsiadm -m node,0 iqn.2010-10.synology-iscsi:newvirtualdisk.1,0 iqn.2010-10.synology-iscsi:newvirtualdisk.1

  7. Use the iscsiadm command to log on to an iSCSI target.
  8. [root@Synology-FedoraVM /]# iscsiadm -m node --targetname "iqn.2010-10.synology-
    iscsi:newvirtualdisk.1" --portal "" --login
    Logging in to [iface: default, target: iqn.2010-10.synology-iscsi:newvirtualdis
    k.1, portal:,3260]
    Login to [iface: default, target: iqn.2010-10.synology-iscsi:newvirtualdisk.1,
    portal:,3260] successful.

  9. Partition, format and mount the iSCSI target by fdisk, mkfs.ext3, and mount command.
  10. [root@Synology-FedoraVM /]# fdisk -l

    Disk /dev/sdb: 161.1 GB, 161061273600 bytes
    255 heads, 63 sectors/track, 19581 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x00000000

    Disk /dev/sdb doesn't contain a valid partition table

    [root@Synology-FedoraVM /]# fdisk /dev/sdb
    Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
    Building a new DOS disklabel with disk identifier 0x6eae1b66.
    Changes will remain in memory only, until you decide to write them.
    After that, of course, the previous content won't be recoverable.

    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

    WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
    switch off the mode (command 'c') and change display units to
    sectors (command 'u').

    Command (m for help): n
    Command action
    e extended
    p primary partition (1-4)
    Partition number (1-4): 1
    First cylinder (1-19581, default 1):
    Using default value 1
    Last cylinder, +cylinders or +size{K,M,G} (1-19581, default 19581):
    Using default value 19581

    Command (m for help): t
    Selected partition 1
    Hex code (type L to list codes): 83

    Command (m for help): w
    The partition table has been altered!

    Calling ioctl() to re-read partition table.
    Syncing disks.

    [root@Synology-FedoraVM /]# mkfs.ext3 /dev/sdb1
    mke2fs 1.41.10 (10-Feb-2009)
    Filesystem label=
    OS type: Linux
    Creating journal (32768 blocks): done
    Writing superblocks and filesystem accounting information: done

    This filesystem will be automatically checked every 30 mounts or
    180 days, whichever comes first. Use tune2fs -c or -i to override.

    [root@Synology-FedoraVM /]# mount /dev/sdb1 /mnt
    [root@Synology-FedoraVM /]# cd /mnt
    [root@Synology-FedoraVM mnt]# ls -l
    total 16
    drwx------. 2 root root 16384 Oct 29 12:16 lost+found

3. Unmount the iSCSI Target and stop iSCSI discovery

The following section will guide you to unmount the iSCSI Target and stop iSCSI discovery.

  1. Unmount the iSCSI Target and stop iSCSI discovery by using umount and iscsiadm command.
  2. [root@Synology-FedoraVM mnt]# cd /
    [root@Synology-FedoraVM /]# umount /mnt

    [root@Synology-FedoraVM /]# iscsiadm -m node --targetname" "iqn.2010-10.synolog y-iscsi:newvirtualdisk.1" --portal" "" --logout
    Logging out of session [sid: 1, target: iqn.2010-10.synology-iscsi:newvirtualdi
    sk.1, portal:,3260]
    Logout of [sid: 1, target: iqn.2010-10.synology-iscsi:newvirtualdisk.1, portal:,3260] successful.

    [root@Synology-FedoraVM /]# iscsiadm -m discovery --portal "" --op=delete