Close this search box.

Install and Configure iSCSI Storage Server on Ubuntu 22.04

Table of Contents

This guide aims to walk you through the process of installing and configuring an iSCSI storage server on Ubuntu 22.04. By following this guide, you will learn how to set up the iSCSI target, configure the logical unit (LUN), and establish a secure connection from an iSCSI initiator (client). Whether you’re setting up a home lab, a small business server, or an enterprise storage solution, this guide will provide the foundational steps to get your iSCSI storage server up and running efficiently.



By the end of this tutorial, you will have a fully functional iSCSI storage server, capable of serving storage to multiple clients over your network. This setup is particularly beneficial for environments requiring centralized storage management, such as virtualized environments, clustered databases, and large-scale data centers.



To begin, ensure you’ve established a VPSie Account if you haven’t yet. Then, move forward by deploying the Ubuntu server tailored to meet your exact requirements.


Make sure you have the following:

  1. A system running Ubuntu 22.04 for the iSCSI target, equipped with a 1 GB external HDD.
  2. A separate system running a fresh installation of Ubuntu 22.04 for the iSCSI initiator.

Once the servers are deployed, SSH into the command line interface. Before installing any packages, it’s essential to update your system’s package list to ensure you have access to the latest versions. Open a terminal and run the following command:

sudo apt-get update -y

Install the iSCSI Target

To set up the iSCSI Target on Ubuntu 22.04, you’ll need to install the necessary package available in the default repository.


Execute the following command on your iSCSI Target server:

sudo apt install tgt -y


Once the installation completes, you can verify that the iSCSI Target daemon is active and running by checking its status with this command:

systemctl status tgt


The output should confirm that the iSCSI Target daemon is active and running smoothly.

Configure the iSCSI Target

Begin by creating a new configuration file with the following command:

nano /etc/tgt/conf.d/iscsi.conf



In the configuration file, add these lines:

    backing-store /dev/sdb
    initiator-address {iSCSI initiator IP}
    incominguser iscsi-user password
    outgoinguser iscsi-target secretpass


This configuration includes:

  • The name of the LUN.
  • The location and name of the storage device on the iSCSI target server.
  • The IP address of the iSCSI initiator.
  • Authentication details for both incoming and outgoing connections.


Save and close the file after editing.



To apply the changes, restart the iSCSI service with this command:

systemctl restart tgt



Verify that the iSCSI target server is correctly configured by running:

tgtadm --mode target --op show



This command should display the target information, confirming the successful setup of your iSCSI LUN.

Install and Configure the iSCSI Initiator

Start by installing the iSCSI initiator package with the following command:

sudo apt install open-iscsi -y

After the installation completes, discover the iSCSI target server to find the shared targets:

sudo iscsiadm -m discovery -t st -p {iSCSI target IP}

This command will display the shared targets available on the iSCSI target server.

Define the LUN Device Name, edit the initiatorname.iscsi file to define the LUN device name:

sudo nano /etc/iscsi/initiatorname.iscsi

Add the iSCSI target LUN name in the file as shown below:

Save and close the file to ensure the initiator can identify the target.

To configure CHAP (Challenge-Handshake Authentication Protocol) information, edit the node configuration file:

sudo nano /etc/iscsi/nodes/{tartget_IP},3260,1/default

Modify the following lines to match your CHAP configuration:

node.session.auth.authmethod = CHAP
node.session.auth.username = iscsi-user
node.session.auth.password = password
node.session.auth.username_in = iscsi-target
node.session.auth.password_in = secretpass
node.startup = automatic

Save and close the file.

Restart the iSCSI initiator service to apply the changes:

sudo systemctl restart open-iscsi iscsid

Check the status of the iSCSI service to ensure it is active and running:

sudo systemctl status open-iscsi

You should see output indicating that the service is active.

To verify the iSCSI connection, run:

sudo iscsiadm -m session -o show

This command will display the active iSCSI sessions.

Finally, to verify the storage device shared from the iSCSI target, run:


You should see the shared device listed among the available disks.

Creating a File System on the Shared Device

To make use of the shared device on the iSCSI initiator, you need to create a file system on it. Follow these steps:


Access the Partitioning Tool: Run the following command to open the partitioning tool:

sudo fdisk /dev/sdb


Follow the prompts to create a new partition.


Once the partition is created, format it with the ext4 file system using the command:

sudo mkfs.ext4 /dev/sdb1


Mount the newly created partition to the /mnt directory:

sudo mount /dev/sdb1 /mnt


To ensure the partition is mounted correctly, run:

df -h


This command will display the mounted partition among the list of file systems.


By following these steps, you will have successfully created and mounted a file system on your shared iSCSI device.

Make a Comment
Share on
VPSie Cloud service

Fast and Secure Cloud VPS Service

For a month

The First 1 orders gets free discount today! Try Sign up on VPSie to get a chance to get the discount.