---
title: ISCSI server and creating targets on Debian or Ubuntu
description: "This guide will show you how to configure a drive to be reachable via iSCSI. ### Configure Target (server) ### Step 1 Please run apt-get update and install **tgt** and **lvm2** packages: $ apt-get update $ apt-get install tgt lvm2 ### Step 2 Please…"
url: "https://www.clouvider.com/knowledge_base/iscsi-server-and-creating-targets-on-debian-or-ubuntu/"
updated: "2021-12-22"
category: Guides / Linux
tags:
  - Debian
  - ISCSI
  - Linux
  - Ubuntu
---

# ISCSI server and creating targets on Debian or Ubuntu

This guide will show you how to configure a drive to be reachable via iSCSI.

### Configure Target (server)

### Step 1

Please run apt-get update and install **tgt** and **lvm2** packages:

$ apt-get update
 $ apt-get install tgt lvm2

### Step 2

Please run **lsblk** and check which drive (assuming sdb) you would like to use on iSCSI:

$ lsblk

### **Step 3**

Now create LVM and create LVM group named **iscsi**:

$ pvcreate /dev/sdb
 $ vgcreate iscsi /dev/sdb

### **Step 4**

Please create logical volume inside LVM group:

$ lvcreate -l 100%FREE iscsi

![iscsi-lvm.png](https://console.clouvider.co.uk/kb/iscsi-lvm.png)

### **Step 5**

Now create config file: **/etc/tgt/conf.d/iscsi.conf** and put there following content:

backing-store /dev/mapper/iscsi-lvol0 # LVM volume
 initiator-address client-ip-address
 incominguser client-scsi client-password
 outgoinguser server-scsi server-password

Please remember to change **client-ip-address, client-scsi client-password and server-scsi server-password** with your own data.

 

**Step 6**

Please restart **tgt** service:

$ systemctl restart tgt

 

**Step 7**

Now you can check iSCSI targets:

$ tgtadm --mode target --op show

![iscsi-targets.png](https://console.clouvider.co.uk/kb/iscsi-targets.png)
