KB450300 – Setup iSCSI Storage Server on Ubuntu 20.04 LTS

Last modified: May 12, 2021
You are here:
  • KB Home
  • KB450300 – Setup iSCSI Storage Server on Ubuntu 20.04 LTS
Estimated reading time: 1 min

Setup iSCSI Storage Server on Ubuntu 20.04 LTS

Scope/Description:

In this tutorial, we will explain how to setup iSCSI targets on Ubuntu 20.04 server

The iSCSI target is LIO and is managed via targetcli

Prerequisites:

  • ZFS Storage pool configured

Steps:

Install needed packages for iSCSI

apt install targetcli-fb

Create ZFS dataset to store images for iSCSI images

  • Create a zfs dataset named “images”

  • Multiple iscsi lun files can be stored in this single dataset or an individual dataset can be created for each iscsi lun.

Configure iSCSI Target

Create Block Backstores for iSCSI LUNS
  • Create a sparse image file before using targetcli, creating large files in targetcli is a slow process
root@ceph-ubuntu1:~# cd /tank/images
root@ceph-ubuntu1:~# dd if=/dev/zero of=lun0 bs=1 count=0 seek=1T
  • Launch “targetcli” and create a fileio backstore with the sparse image created above
root@ceph-ubuntu1:~# targetcli
targetcli shell version 2.1.51
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type 'help'.

/> cd backstores/fileio
/backstores/fileio> create lun0 /tank/images/lun0
  • Verify your block devices have been created in targetcli
/backstores/fileio> ls
o- fileio ..................................................................................................... [Storage Objects: 1]
  o- lun0 ...................................................................... [/tank/images/lun0 (1.0TiB) write-back deactivated]
    o- alua ....................................................................................................... [ALUA Groups: 1]
      o- default_tg_pt_gp ........................................................................... [ALUA state: Active/optimized]
Create an iSCSI Target
  • Create the iSCSI target by selecting its name
    • naming rule : iqn.YYYY-MM.REVERSE.DOMAIN.NAME:unique
    • In this example the target name will be “iqn.2021-04.com.45lab:ubuntu.iscsi0”
/backstores/block> cd /iscsi 
/iscsi> create iqn.2021-04.com.45lab:ubuntu.iscsi0
Created target iqn.2021-04.com.45lab:ubuntu.iscsi0.
Created TPG 1.
Global pref auto_add_default_portal=true
Created default portal listening on all IPs (0.0.0.0), port 3260.
Create iSCSI LUNs
/iscsi> cd iqn.2021-04.com.45lab:ubuntu.iscsi0/tpg1/luns 
/iscsi/iqn.20...si0/tpg1/luns> create /backstores/fileio/lun0 
Created LUN 0.
Configure ACL (Inititator IQN)
  • The ACL to be created is the initiator IQN name of the client that will be connecting to the LUN.
    • In the example the Windows client’s IQN is “iqn.1991-05.com.microsoft:win10”
/iscsi/iqn.20...si0/tpg1/luns> cd /iscsi/iqn.2021-04.com.45lab:ubuntu.iscsi0/tpg1/acls 
/iscsi/iqn.20...si0/tpg1/acls> create iqn.1991-05.com.microsoft:win10
Created Node ACL for iqn.1991-05.com.microsoft:win10
Created mapped LUN 0.
Configure Authentication
  • Configure userid and password when connecting to the LUN from the client. This is optional.
    • Choose any name and password for “userid” and “password”
/iscsi/iqn.20...si0/tpg1/acls> cd iqn.1991-05.com.microsoft:win10/
/iscsi/iqn.20...crosoft:win10> set auth userid=username
Parameter userid is now 'username'.
/iscsi/iqn.20...crosoft:win10> set auth password=password
Parameter password is now 'password'.
Exit and Save Configuration
/iscsi/iqn.20...crosoft:win10> exit
Global pref auto_save_on_exit=true
Configuration saved to /etc/rtslib-fb-target/saveconfig.json
Open Firewall for iSCSI and enable rtslib service
  • In Houston UI add “iscsi” service to firewall in the Networking Module

  • Enable “rtslib-fb-targetctl” service

Configure Windows initiator

  • Open “iSCSI Initiator”
  • Enter Target IP into “Target” field
  • Hit quick-connect

Verification:

Troubleshooting:

Was this article helpful?
Dislike 0
Views: 102
Unboxing Racking Storage Drives Cable Setup Power UPS Sizing Remote Access