We’ve cover the installation of iSCSI Target on CentOS 8 / RHEL 8 in our previous tutorial. In this tutorial we’ll cover the configuration of iSCSI Initiator on CentOS / RHEL 8. So follow these steps to get started.
Step 1: Install iscsi-initiator-utils on CentOS / RHEL 8.
sudo dnf -y install iscsi-initiator-utils
Step 2: Configure Initiator Name
Edit the file /etc/iscsi/initiatorname.iscsi/ and name it to match the target server name you’ve used.
sudo vi /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2019-11.com.osradar:initiator01
Step 3: Configure Credentials
Open the following file to set up credential details.
sudo vi /etc/iscsi/iscsid.conf
Note: Use the credentials as you’ve done in setting up target so they match.
Uncomment "node.session.auth.authmethod=CHAP"
Uncomment "node.session.auth.username" and set username as "Initiator01"
Uncomment "node.session.auth.password" and set it as you've setup in previous setup.
Step 4: Testing iSCSI Target discovery
Run the following command to confirm that iSCSI can discover our installed iSCSI Target.
iscsiadm -m discovery -t sendtargets -p 172.17.52.184
Note: Use your iSCSI target server IP.
If the IP info and access details is displayed we can say the discovery is successful.
Step 5: Confirm Target’s status
Run the given command to check the status.
iscsiadm -m node -o show
# BEGIN RECORD 6.2.0.874-10 node.name = iqn.2019-11.osradar.com:target01 node.tpgt = 1 node.startup = automatic node.leading_login = No iface.hwaddress = iface.ipaddress = iface.iscsi_ifacename = default iface.net_ifacename = iface.gateway = iface.subnet_mask = iface.transport_name = tcp iface.initiatorname = iface.state = iface.vlan_id = 0 iface.vlan_priority = 0 iface.vlan_state = iface.iface_num = 0 iface.mtu = 0
Step 6: Access iSCSI Target on CentOS / RHEL 8
Login to your account by typing this command , you will see a success message at the end.
iscsiadm -m node --login
Logging in to iface: default, target: iqn.2019-11.osradar.com:target01, portal: 172.17.255.109,3260 Login to [iface: default, target: , portal: 172.17.255.109,3260]
iqn.2019-11.osradar.com:target01 successful.
Make sure you’re logged into your iSCSI Target Server.
iscsiadm -m session -o show
tcp: [1] 172.17.255.109:3260,1 iqn.2019-11.osradar.com:target01 (non-flash)
Check disks if you’ve added Target’s disk
We’ve created backstore of 5GB space in our previous tutorial.
lsb1k
Format & mount the new disk to make it ready for use.
In this tutorial we’ll use fdisk to set up LVM type. You are free to use your desired one.
fdisk /dev/sdb
Confirm the new partition number.
lsb1k
Look at the new partition , we have sdb1 as seen below. Now, add a file system on the new partition.
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT fd0 2:0 1 4K 0 disk sda 8:0 0 20G 0 disk ├─sda1 8:1 0 953M 0 part /boot └─sda2 8:2 0 19.1G 0 part ├─centos-root 253:0 0 6G 0 lvm / ├─centos-swap 253:1 0 956M 0 lvm [SWAP] ├─centos-home 253:2 0 7.5G 0 lvm /home └─centos-var 253:3 0 4.7G 0 lvm /var sdb 8:16 0 5G 0 disk └─sdb1 8:17 0 5G 0 part ##sdb1 Added sr0 11:0 1 1024M 0 rom
Set file system on the partition
Here, we’ll use xfs. You can use any (ext3,ext4,Btrfs etc) to fit your case.
mkfs.xfs /dev/sdb1
Mount your partition and confirm
mount /dev/sdb1/mnt
df -TH
Congratulations! You’ve all done. If have any queries regarding this tutorial, you can ask in comments.