We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Learn how to – How To Configure iSCSI Initiator on CentOS 8 / RHEL 8

Learn how to – How To Configure iSCSI Initiator on CentOS 8 / RHEL 8.

Introduction

How to setup iSCSI Initiator on CentOS 8 / RHEL 8?. As promised, this is a continuation of the iSCSI Target guide setup. In our previous tutorial, we covered the installation of iSCSI Target on CentOS 8 / RHEL 8. This guide for focus on how to configure iSCSI Initiator on CentOS 8 / RHEL 8 Linux machine.

Step 1: Install iscsi-initiator-utils

Start by installing iscsi-initiator-utils on CentOS 8 / RHEL 8 machine which will act as initiator. This is done by running the commands below in your terminal.

sudo  dnf -y install iscsi-initiator-utils

Step 2: Configure Initiator Name

We had already covered this in step 14 in the iSCSI Target installation guide. Open “/etc/iscsi/initiatorname.iscsi” file with your favorite editor and edit the name to match what you had used in the target server.

$ sudo vi /etc/iscsi/initiatorname.iscsi
## Change it to match the one you placed in target's ACL
InitiatorName=iqn.2019-11.com.learnhowto:initiator1 

Step 3: Configure authentication credentials

Open “/etc/iscsi/iscsid.conf” file and edit as shown below. Make sure the username and password matche what we had entered in ACLs in the iSCSI Target Server. Use the line numbers to guide you on the position of lines to edit. Approximately on line 57, 61 and 62. Uncomment “node.session.auth.authmethod = CHAP“, uncomment and set “node.session.auth.username = initiator1” and “node.session.auth.password = gai0daeNgu“(Use your credentials in both lines here)

$ sudo vi /etc/iscsi/iscsid.conf
## Uncomment this line
57 node.session.auth.authmethod = CHAP
58 
59 # To set a CHAP username and password for initiator
60 # authentication by the target(s), uncomment the following lines:
61 node.session.auth.username = initiator1
62 node.session.auth.password = gai0daeNgu

Step 4: Test iSCSI Target discovery

After all is set, it is time to confirm if the iSCSI initiator can discover our installed iSCSI Target. Run the command below, replacing the IP with the IP of your iSCSI target server.

$ sudo iscsiadm -m discovery -t sendtargets -p 172.17.52.184
172.17.52.184:3260,1 iqn.2019-11.ownyourlife.com.ng:geekstarget1

We can confirm the discovery was successful – The ip information and access details is displayed.

Step 5: Confirm Target’s status

Just like we were issuing ls command while on the target, issue the command below to check status. There will be a lot of information. We have truncated most of them.

$ sudo iscsiadm -m node -o show
# BEGIN RECORD 6.2.0.874-10
 node.name = iqn.2019-11.ownyourlife.com.ng:geekstarget1
 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

Log into your iSCSI Target by issuing the command below. You should see “successful” at the end.

$ sudo iscsiadm -m node --login
Logging in to iface: default, target: iqn.2019-11.ownyourlife.com.ng:geekstarget1, portal: 172.17.52.184,3260

Login to [iface: default, target: iqn.2019-11.ownyourlife.com.ng:geekstarget1, portal: 172.17.52.184,3260] successful.

Confirm that you are logged into your iSCSI Target Server

$ sudo iscsiadm -m session -o show
tcp: [1] 172.17.52.184:3260,1 iqn.2019-11.ownyourlife.com.ng:geekstarget1 (non-flash)

Check your disks of you have the iSCSI Target’s disk added.

Mine as you can see “b” worth 5G of space. This is the backstore we had created in the previous guide.

$ lsblk

 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 ## See disk added
 sr0              11:0    1 1024M  0 rom

Format the new disk and mount it ready for use.

We will use fdisk in this guide to set up LVM type. You are free to use any tool you are free with here such as parted and the rest.

$ sudo fdisk /dev/sdb
 Welcome to fdisk (util-linux 2.23.2).
 Changes will remain in memory only, until you decide to write them.
 Be careful before using the write command.
 Device does not contain a recognized partition table
 Building a new DOS disklabel with disk identifier 0x88715239.      
 Command (m for help): n
 Partition type:
    p   primary (0 primary, 0 extended, 4 free)
    e   extended
 Select (default p):
 Using default response p
 Partition number (1-4, default 1): 
 First sector (16384-10485759, default 16384): 
 Using default value 16384
 Last sector, +sectors or +size{K,M,G} (16384-10485759, default 10485759): 
 Using default value 10485759
 Partition 1 of type Linux and of size 5 GiB is set
 Command (m for help): t
 Selected partition 1
 Hex code (type L to list all codes): L
 Hex code (type L to list all codes): 8e
 Changed type of partition 'Linux' to 'Linux LVM'
 Command (m for help): w
 The partition table has been altered!
 Calling ioctl() to re-read partition table.
 Syncing disks.

Confirm the new partition number

As you can see, we now have sdb1 added from below. Next, we are going to add a file system on the new partition.

$ sudo lsblk

 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

We are going to use xfs. You can use any here(ext3,ext4, Btrfs etc) to fit your use case.

$ sudo mkfs.xfs /dev/sdb1
 meta-data=/dev/sdb1              isize=512    agcount=4, agsize=327168 blks
          =                       sectsz=512   attr=2, projid32bit=1
          =                       crc=1        finobt=0, sparse=0
 data     =                       bsize=4096   blocks=1308672, imaxpct=25    
          =                       sunit=0      swidth=0 blks
 naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
 log      =internal log           bsize=4096   blocks=2560, version=2        
          =                       sectsz=512   sunit=0 blks, lazy-count=1    
 realtime =none                   extsz=4096   blocks=0, rtextents=0

Mount your partition and confirm

$ sudo mount /dev/sdb1 /mnt
$ df -Th

 Filesystem              Type      Size  Used Avail Use% Mounted on
 devtmpfs                devtmpfs  453M     0  453M   0% /dev
 tmpfs                   tmpfs     464M     0  464M   0% /dev/shm
 tmpfs                   tmpfs     464M  1.1M  463M   1% /run
 tmpfs                   tmpfs     464M     0  464M   0% /sys/fs/cgroup      
 /dev/mapper/centos-root xfs       6.1G  1.4G  4.7G  23% /
 /dev/sda1               xfs       947M  192M  756M  21% /boot
 /dev/mapper/centos-home xfs       7.5G   33M  7.5G   1% /home
 /dev/mapper/centos-var  xfs       4.7G  252M  4.5G   6% /var
 tmpfs                   tmpfs      93M     0   93M   0% /run/user/1000      
 tmpfs                   tmpfs      93M     0   93M   0% /run/user/0
 /dev/sdb1               xfs       5.0G   33M  5.0G   1% /mnt ##Our mounted disk 

Conclusion

All is now set and ready. All that is remaining is to make good use of your resources. Thank you for reading through. Before you leave, check the guides below that might blow your mind.

Cart

Your Cart is Empty

Back To Shop