Did you know  45Drives offers free  public and private  webinars ? Click here to learn more  & register! Build & Price

KB450299- Setup iSCSI Storage Server on Ubuntu 20.04 LTS

You are here:

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

(We don’t recommend using bonds with iSCSI, we recommend using Multi-path instead)

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=(size of LUN)
  • 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

Verification

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

Troubleshooting

  • When trying to delete an iSCSI filesystem there will be errors preventing the removal, in order to destroy it you will have to remove the iqn file and the lun0 file.
  • in the targetcli cd into the iscsi directory
cd iscsi
  • Then use the delete command to remove the iqn file
/iscsi> delete iqn.2021-04.com.45lab:ubuntu.iscsi0 
Deleted Target iqn.2021-04.com.45lab:ubuntu.iscsi0.
  • The cd into /backstores/fileio/
cd /backstores/fileio/

  • Use the delete command again to remove lun0
/backstores/fileio> delete lun0 
Deleted storage object lun0.

 

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