KB450011 – Single Server Linux iSCSI Setup (ZFS)

Last modified: February 3, 2020
You are here:
Estimated reading time: 2 min

Configuring the ISCSI Target

First thing we need to do is install the targetcli package

yum install -y targetcli

Activate the target service at boot:

systemctl enable target

Execute the targetcli command

# targetcli

Warning: Could not load preferences file /root/ .targetcli/prefs.bin.
targetcli shell version 2.1 .fb34
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type ‘help’ .
/>

We’re going to create a block backstore using our ZVOL (feel free to use tab to finish here):

/>backstores/block/ create block1/dev/zd0

Created block storage object called block1 using /dev/zd0

Now we need to create an IQN (ISCSI Qualified Name). For this example we’ll call it iqn.2017-11.com.example with a target t1 and it will generate an associated TPG (Target
Portal Group)

/> iscsi/ create iqn .2017 – 11. com.example:t1
Created target iqn .2017 – 11. com.example:t1.
Created TPG 1 .
Global pref auto_add_default_portal=true
Created default portal listening on all IPs ( 0.0 .0.0 ), port 3260 .

Now we can go to the new directory:

/> cd iscsi/iqn .2017 – 11. com.example:t1/tpg1
/iscsi/iqn .20 …ample:t1/tpg1> ls
o- tpg1 …………………………………………. [no-gen-acls, no-auth]
o- acls …………………………………………………… [ACLs: 0 ]
o- luns …………………………………………………… [LUNs: 0 ]
o- portals ……………………………………………… [Portals: 1 ]
o- 0.0 .0.0 : 3260 ………………………………………………. [OK]

Next we’ll create a LUN:

/iscsi/i qn. 20 …ample:t1/tpg1> luns/ create /backstores/block/block1
Created LUN 0.

Create an acl with the previously created IQN (here iqn.2017-11.com.example) and an identifier you choose (here client), together creating the future initiator name:

/iscsi/i qn. 20 …ample:t1 /tpg1> acls/ create iqn. 2017 – 11 .com.example:client
Created Node ACL for iqn. 2017 – 11 .com.example:client
Created mapped LUN 0

/iscsi/iqn .20 …ample:t1/tpg1> set attribute authentication= 0

We can now exit the targetcli command:

/iscsi/i qn. 20 …ple:tgt1 /tpg1> exit
Global pref auto_save_on_exit=true
Last 10 configs saved in / etc /target/ backup.
Configuration saved to /etc/ target /saveconfig.json

NOTE – If you’re setting up multiple ISCSI target volumes, you would now follow the procedure again, but creating block2, block3, and so on.

Finally we need to open port 3260 tcp in the firewall configuration:

# firewall-cmd –permanent –add-port=3260/tcp; firewall-cmd –reload

Connecting to your ISCSI target on a Windows Client

Go to the Control Panel , and in the top right corner change view by: to “Small icons”.
Click on Administrative Tools followed by ISCSI Initiator .

Head to the “Configuration” tab, and change the initiator name to match the ACL you created.

Go back to the “Target” tab, and type in the IP address of the server in the “Target:” box under the Quick Connect section.

Then you should see the iSCSI target and be able to connect.

Next go to the “Disk management” and you should see a new disk which is Offline, Right-click to Online the disk.

Right click on it once it’s online and select the New Simple Volume Wizard, and follow the steps to set up format the disk.

Once this is done, the ISCSI volume should show up as a local Hard Disk in your system.

Deleting an ISCSI volume and ZVOL to resize appropriately

First step is to disconnect from the ISCSI target if you’ve already connected on the Windows
client.

Next, on the server side you’ll want to get back into the targetcli:

# targetcli
Warning: Could not load preferences file /root/.targetcli/prefs.bin.
targetcli shell version 2.1 .fb34
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type ‘help’ .
/>

Delete the ISCSI target

/> iscsi/ delete iqn .2017-11. com.example:t1

Delete the block storage we created

/> backstores/ block delete block1

Then exit the targetcli command:

/> exit
Global pref auto_save_on_exit= true
Last 10 configs saved in /etc/target/backup.
Configuration saved to /etc/target/saveconfig.json

Now you’ll need to delete your ZVOL so that you can size multiple ZVOL’s accordingly if creating multiple ISCSI volumes.

zfs list

To verify the name of your ZVOL, then delete it:

zfs destroy zpool/disk1

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