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
- ZFS Storage pool configured
- iSCSI configured
Steps
Create a Block Image for the iSCSI Lun
- Create a sparse image file before using targetcli. This will create the image, specify the lun name and size. By default 45Drives stores lun images at /{pool_name}/images. The seek refers to the size of the lun that is required. It can be defined with the following examples 1T, 1G, 100G, etc.
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)
- See example commands below.
[root@av15-rocky45d images]# cd /tank_mirror/images [root@av15-rocky45d 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
- To make changes to the targetcli configuration, run the following command.
targetcli
Creating Fileio Storage Object
- Create a fileio storage object, using the created lun in the previous steps.
/> cd backstores/fileio /backstores/fileio> create {lun_name} /{pool_name}/images/{lun_name}
- Example below:
/backstores/fileio> create testlun /tank_mirror/images/testlun Created fileio testlun with size 1099511627776
- Verify your block devices have been created in targetcli
/backstores/fileio> ls o- fileio ..................................................................................................... [Storage Objects: 1] o- testlun ...................................................................... [/tank_mirror/images/testlun (1.0TiB) write-back deactivated] o- alua ....................................................................................................... [ALUA Groups: 1] o- default_tg_pt_gp ........................................................................... [ALUA state: Active/optimized]
Adding new Lun to Existing iSCSI Target
- Change the targetcli working directory to the iSCSI target’s lun directory, then add the lun to the existing target.
cd /iscsi/{target_name}/tpg1/luns/ create /backstores/fileio/{lun_name}
- Example below:
/> 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
- The output will show the new lun being mapped to each of the clients iqns that correspond to the iSCSI target.
Exit and Save Configuration
- Exit the configuration, this is required for changes to take affect. A backup file will be written to /etc/target/saveconfig.json on RHEL based distros, and /etc/rtslib-fb-target/saveconfig.json
/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
- Open “iSCSI Initiator”
- Enter Target IP into “Target” field
- Hit quick-connect
Views: 1380