You can support us by downloading this article as PDF from the Link below. Download the guide as PDF


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 on CentOS 8 / RHEL 8

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 

Step 3: Configure authentication credentials – username & password

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
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.

# iscsiadm -m discovery -t sendtargets -p,1

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.

# iscsiadm -m node -o show
 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 8 / RHEL 8

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

# iscsiadm -m node --login
Logging in to iface: default, target:, portal:,3260

Login to [iface: default, target:, portal:,3260] successful.

Confirm that you are logged into your iSCSI Target Server

# iscsiadm -m session -o show
tcp: [1],1 (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

 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.

# 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.

# lsblk

 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.

# 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

# 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 


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.

How To Sync CentOS 8 repositories on Satellite / Katello / Foreman

How To Setup a TFTP server on CentOS 8 / RHEL 8 Linux

Install Puppet Master and Agent on CentOS 8 / RHEL 8

How To Manage CentOS 8 Linux With Cockpit Web Console

How To Setup Chef Infra Server on CentOS 8 / RHEL 8

How To Install Chef Workstation on CentOS 8 / RHEL 8

Install and Configure Ghost CMS on CentOS 8 / RHEL 8

As an appreciation for the content we put out,
we would be thrilled if you support us!

As we continue to grow, we would wish to reach and impact more people who visit and take advantage of the guides we have on our blog. This is a big task for us and we are so far extremely grateful for the kind people who have shown amazing support for our work over the time we have been online.

Thank You for your support as we work to give you the best of guides and articles. Click below to buy us a coffee.


Please enter your comment!
Please enter your name here