Ubuntu 16.04 / Debian 8: Install iSCSI target and share with Windows 10

This article will describe installing iSCSI target and sharing with Windows 10.

 

1 System environment

A private network address is 192.168.11.0/24.

2 Install iscsitarget

Install iscsitarget with apt.

$ sudo apt install -y iscsitarget

3 /etc/default/iscsitarget

Change ISCSITARGET_ENABLE to be true.

$ diff -uprN /etc/default/iscsitarget{.org,}
--- /etc/default/iscsitarget.org        2016-05-05 14:28:56.574153766 +0900
+++ /etc/default/iscsitarget    2016-05-05 14:29:03.398123667 +0900
@@ -1,4 +1,4 @@
-ISCSITARGET_ENABLE=false
+ISCSITARGET_ENABLE=true
 ISCSITARGET_MAX_SLEEP=3

4 /etc/iet/targets.allow

Add access permission to localhost and private network.

$ cat /etc/iet/targets.allow
ALL 127.0.0.1,192.168.11.0/24

5 Export volume

Export a file as a volume.

$ sudo mkdir /var/lib/iscsi
$ sudo dd if=/dev/zero of=/var/lib/iscsi/fileio.img bs=1 count=0 seek=20G

Export a block device /dev/vdb as a volume.

$  cat /proc/partitions | grep vdb
 253       16   20971520 vdb

6 /etc/iet/ietd.conf

Type to fileio in case of a file, blockio in case of a block device.

$ sudo cat /etc/iet/ietd.conf
Target iqn.2016-05.net.my:fileio.img
  Lun 0 Path=/var/lib/iscsi/fileio.img,Type=fileio
Target iqn.2016-05.net.my:blockio.img
  Lun 0 Path=/dev/vdb,Type=blockio

7 Run iscsitarget

Run iscsitarget with systemd.

$ sudo systemctl enable iscsitarget
$ sudo systemctl restart iscsitarget

8 Access from Windows 10

Windows 10 has a iSCSI initiator.

Control panel -> System and Security -> Administrative Tools  -> iSCSI initiator

0001_Windows-iSCSI-initiator_en.png

After connection with iSCSI initiator, you can initialize volume with Disk Management and use it as a drive.