45Drives Knowledge Base
KB450410 - Adding new Luns to iSCSI Configuration
https://knowledgebase.45drives.com/kb/kb450410-adding-new-luns-to-iscsi-configuration/

KB450410 - Adding new Luns to iSCSI Configuration

Posted on March 6, 2023 by Austin Axworthy


Scope/Description

This guide details the process of creating a new iSCSI lun and adding it to the configuration. Replace variables in the example comamnds defined with curly braces with the correct name, i.e. {pool_name } -> pool1.

Prerequisites

Steps

Create a Block Image for the iSCSI Lun

Do not accidentally specify the name of an existing lun. This command will zero out all data on the block image. Ensure a new name is used.

cd /{pool_name}/images
dd if=/dev/zero of={lun_name} bs=1 count=0 seek=(size of LUN)

# cd /tank_mirror/images
# dd if=/dev/zero of=testlun bs=1 count=0 seek=1T
0+0 records in
0+0 records out
0 bytes copied, 9.8113e-05 s, 0.0 kB/s

Entering Targetcli Config

targetcli

Creating Fileio Storage Object

/> cd backstores/fileio
/backstores/fileio> create {lun_name} /{pool_name}/images/{lun_name}
/backstores/fileio> create testlun /tank_mirror/images/testlun
Created fileio testlun with size 1099511627776
/backstores/fileio> ls
o- fileio ..................................................................................................... 
  o- testlun ...................................................................... 
    o- alua ....................................................................................................... 
      o- default_tg_pt_gp ........................................................................... 

Adding new Lun to Existing iSCSI Target

cd /iscsi/{target_name}/tpg1/luns/
create /backstores/fileio/{lun_name}
/> cd /iscsi/iqn.2023-02.labtest:test.environment/tpg1/luns/
/iscsi/iqn.20...ent/tpg1/luns> create /backstores/fileio/testlun 
Created LUN 2.
Created LUN 2->2 mapping in node ACL iqn.1991-05.com.microsoft:win-9171j57n62e
Created LUN 2->2 mapping in node ACL iqn.1991-05.com.microsoft:win-clvclj26v2c

Exit and Save Configuration

/iscsi/iqn.20...ent/tpg1/luns> exit
Global pref auto_save_on_exit=true
Last 10 configs saved in /etc/target/backup/.
Configuration saved to /etc/target/saveconfig.json

Verification