How to Configure Iscsi Client (Initiator) on Centos 7
In this tutorial we will show you how to configura iscsi client or initiator on Centos 7. For you don’t know iSCSI ,iSCSI is an acronym for Internet Small Computer Systems Interface, it provides block-level access to storage devices by carrying SCSI commands over a TCP/IP network.
Prerequisites
This article assumes you have at least basic knowledge of linux, know how to use the shell, root user or non-root user account with sudo privileges set up on your server.
Installation
To configure iSCSI initiator we need to install package using yum
1 |
yum install -y iscsi-initiator-utils |
After installation we need to start the iscsid service
1 |
systemctl enable iscsi iscsid |
Note:
- The iscsid service is the main service that accesses all configuration files involved
- The iscsi service is the service that establishes the iSCSI connections
Configuration
For the example iscsi server (target) ip address is 192.168.70.70
Step 1 – Discovery targets
1 |
iscsiadm -m discovery -t sendtargets -p 192.168.70.70:3260 |
Example output
1 2 |
# iscsiadm -m discovery -t sendtargets -p 192.168.70.70:3260 192.168.70.70:3260,1 iqn.2017-06.local.rhce.ipa:data1 |
Step 2 – Log in into discovered target
From the step 1 we found the discovered target has target name iqn.2017-06.local.rhce.ipa:data1
login into discovered target using ip and target name
1 |
iscsiadm -m node -T iqn.2017-06.local.rhce.ipa:data1 -p 192.168.70.70:3260 --login |
Step 3 – Check session
Check your iscsi client session using this command below
1 |
iscsiadm -m session -P3 | less |
Step 4 – File system format
Let’s assume that you was never format your iscsi target before.
Check your iscsi disk using command below
1 |
lsblk --scsi | grep iscsi |
Example output
1 2 |
[root@img]# lsblk --scsi | grep iscsi sdb 3:0:0:0 disk WD FILEIO 4.0 iscsi |
From the command above we see the iscsi disk was exist in path /dev/sdb
We need format the iscsi using this command below
1 |
mkfs.ext4 -m0 /dev/sdb |
Create a mount point and get UUID
1 |
mkdir /data1 |
1 2 |
[root@img]# blkid | grep sdb /dev/sdb: UUID="6a2d55d0-8e27-41f1-81b1-c543b11bb5c7" TYPE="ext4" |
Add the following to /etc/fstab
1 |
UUID=6a2d55d0-8e27-41f1-81b1-c543b11bb5c7 /mnt/block1 ext4 _netdev 0 0 |
Finally , mount the iscsi drive
1 |
mount /data1 |
Optional
You can log out your iscsi session using this command below
1 2 |
# iscsiadm -m node -T iqn.2017-06.local.rhce.ipa:data1 -p 192.168.70.70:3260 --logout # iscsiadm -m node -T iqn.2017-06.local.rhce.ipa:data1 -p 192.168.70.70:3260 -o delete |
If something go wrong , you can stop the iscsi and iscsid service and clean up this folder below
1 |
rm -f /var/lib/iscsi/nodes/* |
It will wipe all iscsi session configuration
Congratulations, you have successfully configure iscsi client (initiator) on Centos 7. Thanks for using this tutorial for configuring iscsi client (initiator) on Centos 7
Recent Comments