Creating a Ubuntu iSCSI SAN Storage Server for VMware vSphere ESXi

This guide shows you how to configure Ubuntu as an iSCSI SAN that you can use with VMware and its advanced features like VMotion and Storage VMotion.

Introduction

I’ve been testing VMware vSphere 6.7 and the vCenter appliance on my MacBook using VMware Fusion to test VMotion and Storage VMotion.

Since I’ve only got 16 GB of RAM, running FreeNAS wasn’t really an option so I created a Ubuntu 18.04 VM with 1 GB of RAM and turned it into an iSCSI SAN.

In this guide I’ll show you how to configure Ubuntu to serve a 1 TB thin provisioned disk via iSCSI and how to connect it to vSphere ESXi 6.7.

The steps below have been tested on a Ubuntu 18.04 virtual machine running on VMware Fusion 11.5*.

Ubuntu iSCSI Target Software

In order to turn Ubuntu into a storage server that can be accessed by multiple ESXi hosts via iSCSI, we need to choose an iSCSI target software package.

There are multiple iSCSI target options (here is a link to a comparison) we can use with Linux but the one we’re going to use in this guide is SCST.

SCST is well tested, high performance, and has useful features like thin provisioning which work well with VMware. SCST has also been used in some enterprise storage solutions that have passed the VMware certification.

Installing SCST on Ubuntu 18.04

SCST is not in the official Ubuntu repositories so we’ll need to compile it from source and install it.

Run the following commands to install SCST.

mkdir ~/scst-build  
cd ~/scst-build  
sudo apt install git devscripts equivs dkms 
git clone -b ubuntu-3.4.x https://github.com/ubuntu-pkg/scst.git  
cd scst  
sudo mk-build-deps -i -r
dpkg-buildpackage -b -uc
sudo mkdir -p /var/lib/scst/pr  
sudo mkdir -p /var/lib/scst/vdev_mode_pages  
sudo dpkg -i ../scst-dkms_*deb  
sudo dpkg -i ../iscsi-scst_*.deb  
sudo dpkg -i ../scstadmin_*deb
sudo /etc/init.d/scst start

Create a folder to store the disk images

Let’s create a folder to store disk images.

sudo mkdir /srv/vmware

Create a 1 TB thin provisioned image

Run the following command to create a 1TB thin provisioned disk inside the vmware folder called disk1.

sudo dd if=/dev/zero of=/srv/vmware/disk1 bs=1 count=0 seek=1T

Note: the max size of this image is 1TB but after running the command above it will only be using 0 bytes on disk. You can check this by running:

ls -lh /srv/vmware
total 0
-rw-r--r-- 1 root root 1.0T Oct 23 12:15 disk1

Export the disk image as a iSCSI LUN

Now we need to export the disk image as a thin provisioned iSCSI target using SCST.

Create scst.conf file.

sudo vim /etc/scst.conf

Add the following contents to the file.

HANDLER vdisk_fileio {
    DEVICE disk1 {
        filename /srv/vmware/disk1  
        nv_cache 0 
        thin_provisioned 1  
    }  
}  
TARGET_DRIVER iscsi {
    enabled 1
    TARGET iqn.2019-10.graspingtech.com:disk1 {
        enabled 1  
        rel_tgt_id 1
        LUN 0 disk1 
    }         
}  

Apply the changes.

sudo scstadmin -config /etc/scst.conf

We’re now ready to connect to the iSCSI target with VMware ESXi.

Adding the iSCSI LUN to VMware vSphere ESXi 6.7

Login to the HTML client of vCenter 6.7 and then perform the following steps to add the iSCSI server to the ESXi hosts.

  1. Click on Hosts and Clusters
  2. Click on the host we want add the iSCSI LUN to.
  3. Click on Configure.
  4. Click on Storage Adapters.
  5. Click on Add Software Adapter.

Screenshot of vCenter Storage Adapters

Select Add software iSCSI adapter then click OK.

Screenshot of vCenter Add Software Adapter

The software iSCSI adapter should now be in the list of storage adapters.

  1. Click on the software iSCSI adapter.
  2. Click on the Dynamic Discovery tab.
  3. Click Add.

Screenshot of vCenter Add iSCSI Server

Enter the IP address of the Ubuntu iSCSI server and then click OK.

Screenshot of vCenter Add Target Server

Once the server is added you will need to click Rescan Adapter for the software adapter to detect any devices on the target.

Screenshot of vCenter rescan adapters

Now click on the Devices tab and you should see the thin provisioned disk we created when configuring the iSCSI target.

Screenshot of vCenter iSCSI Devices

Repeat these steps for any more ESXi hosts you have in your cluster and then we’ll create a new VMFS volume in the next step.

Create new VMFS volume on the iSCSI LUN

Click Actions, Storage and then New Datastore.

Screenshot of vCenter New Datastore

Select VMFS then click NEXT.

Screenshot of vCenter New Datastore Wizard - Step 1

Give the new datastore a name, select the 1 TB iSCSI LUN we created on the Ubuntu storage server and then click NEXT.

Screenshot of vCenter New Datastore Wizard - Step 2

Select VMFS 6 then click NEXT.

Screenshot of vCenter New Datastore Wizard - Step 3

Select the size of the partition you want to create, the block size and reclamation granularity and then click NEXT.

Screenshot of vCenter New Datastore Wizard - Step 4

Click FINISH to create the datastore.

Screenshot of vCenter New Datastore Wizard - Step 5

You should now see the datastore in the Datastores tab of each host in your cluster.

Screenshot of vCenter Datastores

Final thoughts

The steps in this post showed you how to turn a Ubuntu 18.04 machine into an iSCSI storage server that’s good enough to test VMotion and Storage VMotion.

Since we aren’t using FreeNAS, it’s possible to host the Ubuntu SAN, two ESXi hosts, the vCenter appliance and a nested VM on a MacBook Pro with 16 GB of RAM.

The iSCSI target LUN was configured to use thin provisioning, which means even though the Ubuntu VM only has a 20 GB hard drive, we were able to make ESXi think there is 1 TB.

And since we used a VMFS 6 volume, the size of the image can grow/shrink when VMs are migrated to and from the datastore.