17.5 C
Texas
Melhttp://www.osradar.com
Guru Unix /Linux and GNU supporter

Install and Configure iSCSI Initiator

After installing  the Target  Iscsci disk on the server A, we need to use it from Server B .

Please  note :this installation  was  executed on my own test lap  based on Vmware machines . Now we will explain how to add the target disk to our local server.

 

You can consult this line  to see how we  did the installation of  target iSCSI server

How to Configure Storage Server with iSCSI in Redhat and Centos 7

- Advertisement -

 

Info  :

Target  ISCSI Server   =   centos7a

The Actual Server       =  centos7b

Before  to  start  Please  install   the  iscsi initiator utils

yum -y install iscsi-initiator-utils

Enable  and  start  Iscsid services

systemctl  enable iscsid
systemctl start iscsid

Show My  disks

[root@centos7b ~]# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000bfc92
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 41943039 19921920 8e Linux LVM
Disk /dev/mapper/centos-root: 18.2 GB, 18249416704 bytes, 35643392 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

 

the  Status  on the Target Server  :

We have to use the ACL rule to be able to  login and use the disk on target  server

Please  add the ACL  initiator name  to /etc/iscsi/initiatorname.iscsi  .

[root@centos7b ~]# vi /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2018-04.org.osradar.com.centos7.share
 Check  if the  Port is opened on Target Server
[root@centos7b ~]# telnet centos7a 3260
Trying 192.168.65.131...
Connected to centos7a.
Escape character is '^]'.
 Discover the target
[root@centos7b ~]# iscsiadm --mode discoverydb --type sendtargets --portal centos7a --discover
192.168.65.131:3260,1 iqn.2016-02.osradar.com
[root@centos7b ~]#
Please  remember the iqn name
 Login to the Target.
 We are logged in..  nice!
Show  my disks   Now  
 
 you  can format the disk and use it for mount partition  /data  
fdisk /dev/sdb and create primary partition  /dev/sdb1
[root@centos7b ~]# 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 0x087d615e.

Command (m for help): n
Partition type:
 p primary (0 primary, 0 extended, 4 free)
 e extended
Select (default p): p
Partition number (1-4, default 1): 
First sector (8192-8388607, default 8192): 
Using default value 8192
Last sector, +sectors or +size{K,M,G} (8192-8388607, default 8388607): 
Using default value 8388607
Partition 1 of type Linux and of size 4 GiB is set

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@centos7b ~]#

new device has  been created

Format the Disk and create ext4 disk

[root@centos7b ~]# mkfs.ext4 /dev/sdb1 
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=1024 blocks
262144 inodes, 1047552 blocks
52377 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1073741824
32 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
 32768, 98304, 163840, 229376, 294912, 819200, 884736

Allocating group tables: done 
Writing inode tables: done 
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done

[root@centos7b ~]#

Create directory /data  and mount  the disk to  this folder

[root@centos7b ~]# mkdir /data 
[root@centos7b ~]# mount /dev/sdb1 /data
[root@centos7b ~]# df -h 
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 17G 5.5G 12G 33% /
devtmpfs 477M 0 477M 0% /dev
tmpfs 488M 0 488M 0% /dev/shm
tmpfs 488M 6.8M 481M 2% /run
tmpfs 488M 0 488M 0% /sys/fs/cgroup
/dev/sda1 1014M 153M 862M 16% /boot
192.168.65.131:/nfs 17G 5.9G 12G 35% /nfsshare
tmpfs 98M 0 98M 0% /run/user/0
/dev/sdb1 3.9G 16M 3.7G 1% /data
[root@centos7b ~]#

 

To Mount this disk permanently please add this  line to  /etc/fstab

/dev/sdb1 /data ext4 _netdev,defaults 0 0
 Reboot your System and Check  if the disk is mounted  automatically.
Enjoy
- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article