Skip to main content

How to configure ISCSI target and initiator?



What is ISCSI?
ISCSI is a shared storage service, by using ISCSI service we can share storage space which we can use as internal storage in different machines.

Requirements-

2 CentOS machines
Free storage space (as per your requirements)

Let’s start with configuration-

Configuration (Server-Side)-

First, we need to install the targetcli package,
# yum install targetcli -y

Now start and enable the service.
# systemctl start/enable target.service

Create partition of free space that you want to share as ISCSI storage.
# fdisk /dev/sdb
Follow the instructions and create a partition according to your requirements.
I’ve created a partition of 6GB size.

No need to format this partition but you can create LVM partition if you want.
Now run following command-
# targetcli

> cd /backstores/block
> create data_block /dev/sdb1
> cd /iscsi
> create iqn.2020-03.com.example:server1
> cd iqn.2020-03.com.example:server1/tpg1/acls
> create iqn.2020-03.com.example:desktop1
> cd ../luns
> create /backstores/block/data_block
> cd ../portals
> create 172.16.0.187 3260
> cd /
> saveconfig
> exit
Restart the service in Server(Target) machine
# systemctl restart target.service

Add the port in firewall-
# firewall-cmd --permanent --add-port=3260/tcp
# firewall-cmd --reload

Configuration (Client-side)-
First install initiator-utils package.
# yum install iscsi-initiator-utils -y

Now add iqn name in initiatorname file.
# vim /etc/iscsi/initiatorname.iscsi
Iqn.2020-02.com.example:desktop1
Save and exit from that file.

Now discover for target’s iqn name by using the following command-
# iscsiadm --mode discoverydb --type sendtargets --portal 172.16.0.187

Now you got the iqn name of the target machine after that run the following command to login that iscsi device in your initiator machine.
# iscsiadm --mode node --targetname iqn.2020-02.com.example:server1 --portal 172.16.0.187:3260 --login

Now you will get a device listed in your drive list like “/dev/sdb” or “/dev/sdc” according to your drive lists.
After getting that drive run fdisk command to create a partition in it and then format that partition and mount it.

# fdisk /dev/sdb

# mkfs.ext4 /deb/sdb1

To mount I’m gonna edit fstab file-
# vim /etc/fstab
/dev/sdb1    /media        ext4        _netdev,defaults    0    0

Save and exit.

To logout from iscsi drive, we need to first remove that fstab line and then run following line-
# iscsiadm --mode node --targetname iqn.2020-02.com.example:server1 --portal 172.16.0.187:3260 --logout

=> If you have any doubts please comment below or you can mail me-
 JohnTheH4cker

Comments

Popular posts from this blog

How to install BlackArch Linux in VirtualBox

In this blog, I'm going to show you how to install BlackArch Linux in VirtualBox/VMWare. Open your VirtualBox application and click on create a new virtual machine from the main menu. Assign a minimum 2GB ram minimum. Add hard-disk of at least 50GB. Now boot the newly created VM and start the installation process. First, select Boot Black arch Linux, and if you have Nvidia graphics then select Boot BlackArch Linux (nonfree). First thing first you need to login in your new BlackArch live session. The default username and password is root & blackarch. Now after this open terminal and type first command #blackarch-install- #blackarch-install After that, you need to follow the instructions. - Select the second option Install from black arch Live-ISO and hit enter.   - Now you need to select the output method quiet or verbose, here I'm selecting the second option verbose mode.  - Now select your locale settings, according to your locality, here I

How to install and setup Manjaro-i3 for the first time.

Hey, guys today I'm going to show you how to install and setup Manjaro-i3. In this case, first of all, we need to know what is Manjaro and the difference between Manjaro & Manjaro-i3. What is Manjaro? Manjaro is an opensource Linux distribution based on ArchLinux. Its basically used for personal work or we can say that this distribution is the workstation edition of ArchLinux. What is i3? i3 is a desktop environment used in many distributions. It looks good and clean. If you are good at remembering shortcuts and commands then this is for you. It's a lightweight desktop environment. If you are switching to i3 from a gnome desktop environment then you will find some dificulties to use it, but you will learn very quickly. In my opinion, this is the most beautiful desktop environment I have ever used. Now let's take a look at how to install it in VirtualBox . First of all, create a virtual machine with at least 2 GB ram and 40 GB HDD space. Now a

Object storage configuration through MinIO

Object storage configuration through MinIO   Hi guys, in this blog I'm going to explain to you how to set up an object storage server in your local system through MinIO object storage. What is Object Storage - Object storage is a computer data storage architecture that manages data as objects. It can directly store files, unlike block storage. What is MinIO - Minio is a popular open-source object storage server. The service stores unstructured data such as photos, videos, log files, backups, and container/VM images, and can even provide a single object storage server that pools multiple drives spread across many servers. Prerequisites - Ram - 2GB (testing), 4GB recommended. HDD - As per your requirements. Static IP address. If you want to host it on the web then get a domain name. Configuration - First thing you need to update your server. # sudo apt update -y Now you need to download “minio” package by using the following command - # wget https://dl.min.io