Prerequisites
The server will require the open-iscsi package, please follow the procedure to install Open-iSCSI as described in How to install iSCSI initiator in linux.
iSCSI Connection with CHAP Authentication
Configuration
To authenticate and establish a connection to the iSCSI target, you will need to use the iscsiadm
command. You'll need to provide the following parameters:
- iSCSI target
- VPSA IP/hostname
- username
- password (CHAP secret)
Below you can see the commands to be run to create a new iSCSI target, set the auth to CHAP, provide the credentials, and login.
iscsiadm -m node -T <target> -p <ip> --o new
iscsiadm -m node -T <target> -p <ip> --o update -n node.session.auth.authmethod -v CHAP
iscsiadm -m node -T <target> -p <ip> --o update -n node.session.auth.username -v <username>
iscsiadm -m node -T <target> -p <ip> --o update -n node.session.auth.password -v <secret>
iscsiadm -m node -T <target> -p <ip> --login
Example
As an example—given the parameters below—this code block provides a full example of the commands and output for a successfully login.
- iSCSI target=
iqn.2011-04.com.zadarastorage:vsa-000001f2
- VPSA IP/hostname=
170.70.2.126
- username=
user
- password (CHAP secret)=
123456789012
# iscsiadm -m node -T iqn.2011-04.com.zadarastorage:vsa-000001f2:1 -p 170.70.2.126 --o new
New iSCSI node [tcp:[hw=,ip=,net_if=,iscsi_if=default] 170.70.2.126,3260,-1 iqn.2011-04.com.zadarastorage:vsa-000001f2:1] added
# iscsiadm -m node -T iqn.2011-04.com.zadarastorage:vsa-000001f2:1 -p 170.70.2.126 --o update -n node.session.auth.authmethod -v CHAP
# iscsiadm -m node -T iqn.2011-04.com.zadarastorage:vsa-000001f2:1 -p 170.70.2.126 --o update -n node.session.auth.username -v user
# iscsiadm -m node -T iqn.2011-04.com.zadarastorage:vsa-000001f2:1 -p 170.70.2.126 --o update -n node.session.auth.password -v 123456789012
# iscsiadm -m node -T iqn.2011-04.com.zadarastorage:vsa-000001f2:1 -p 170.70.2.126 --login
Logging in to [iface: default, target: iqn.2011-04.com.zadarastorage:vsa-000001f2:1, portal: 170.70.2.126,3260]
Login to [iface: default, target: iqn.2011-04.com.zadarastorage:vsa-000001f2:1, portal: 170.70.2.126,3260]: successful
By default, the CHAP authentication and mounting of the volume will not happen automatically when your server is disconnected or rebooted.
The following command can be used to configure iscsid
to automatically reconnect on process restart and system reboot:
iscsiadm -m node -T <target name> -p <IP> --op update -n node.startup -v automatic
If you wish to have your volume mount after reboot it should be added to /etc/fstab
:
/dev/sda1 /mnt/Zadara ext4 defaults,_netdev 0 0
Adding _netdev
option will prevent the system from attempting to mount these filesystems until the network has been enabled on the system.
Post Connection
Some useful commands to utilize after the connection is established and authentication successfully completed.
- To print out the soft links of the devices in the Linux host:
$ sudo ls -l /dev/disk/by-path/
- If you detach a volume from the server (or delete it), the appropriate iSCSI block device on the server still exists (but returns IO errors). If you want to remove it, then locate the block device (following the link in /dev/disk/by-path) and issue:
$ echo 1 > /sys/block/<name>/device/delete
Be careful not to delete the wrong device!
- If you add a new volume or expand an existing one, you should see the change automatically. If not, issue:
$
iscsiadm -m session -R
This command will rescan all iscsi sessions for changes.