Creating a virtual iSCSI target server

By | May 1, 2011

How to create a iSCSI target running inside a virtual machine in VMware Workstation.

If running for example VMware ESXi in a lab or home test environment one common problem is the lack of shared storage, i.e. a SAN, which is needed for most of the advanced options. One way to solve this is to run a iSCSI target inside a virtual machine.

Here is a guide how to setup a iSCSI server running the freeware solution Openfiler on VMware Workstation 7.x. The complete way to setup the iSCSI target on Openfiler might seem a bit complicated, but will only take 15-20 minutes if following the steps below.

First of all we need to download the iso from and store on local disk. Select the ISO Image (x86/64) and not the VMware appliance. This guide is based on release 2.3 of Openfiler. When downloaded, begin with creating a new virtual machine, choose Custom and select the file

openfiler-2.3-x86_64-disc1.iso” as Installer Disc Image ISO.

Guest operating system: Linux: Other Linux 2.6.x kernel 64-bit

Select the following during the following screens: 1 CPU, 512 MB RAM and 2 GB disk. After the VM has been created, edit the virtual machine settings and remove the following virtual hardware not needed: Floppy, USB Controller, Sound card, and Printer.

Start the new virtual machine and choose a graphical installation of Openfiler (default). On the first option of testing the CD media, select SKIP. Next, and then select a suitable keyboard for your language.

Leave default “Automatic partitioning” and select NEXT. On the question of erase all data: YES. Select “Remove all partitions on this system”, Next and Confirm with YES. Leave all partition sizes default and select NEXT. On the question of enabling swap, select YES.

Either set a static IP or leave the default DHCP if available (probably through VMware Workstation networking) and select the correct timezone for your location. Enter a strong password for the root account. (Note that this account will not be used with the main web interface later, only for local command line access.)

Select NEXT a final time and the installation will begin. Wait a short while and then let it reboot and make sure it starts correctly. A screen similar to the one below should be visible once started.

Log on directly on the console with account root and the password that was set during the installation. We shall now shut down the system to add more diskspace. Type “halt” on the command line and press enter, then wait until the final row says “System halted” and power off the virtual machine.

In VMware Workstation: Edit Virtual Machine settings on the new VM, Add – Hard Disk, Create a new virtual disk, leave default SCSI and select the size of the disk. This will be used later as an exposed LUN from the iSCSI server and should be of proper size for your needs. Selected in the example below is 50 GB. It is very possible to add more disks later and expose more LUNs from the iSCSI server.

If having a traditional HDD you can select “Allocate all disk space now”, which will give a somewhat better write performance later, but the downside is that is the whole virtual disk file will be expanded from the start which will consume more diskspace on the host computer. It will also zero out the whole file which could take some time depending on the size. If the virtual disk is located on a SSD do not select that option.

Start the virtual machine again and make a note of the IP address shown on the console and then start your favorite web browser from the host computer and connect to:

https://ip:446 (note that you must use both HTTPS and the special port of 446 and not the expected 443!)

Accept the warning about the certificate and log on with these credentials:

Username: openfiler

Password: password

Note that you must use the default username “openfiler” and not the root account with the password selected during the installation.


(Root is not allowed access through the web interface.)

Once logged on, first go to the Accounts tab to the right and on the “Admin Password” section you can set a new and stronger password for the admin account called “Openfiler” (default is “password”).

Now go the tab “System” on the top row and make sure the “Network Setup” is selected on the bar to the right, it should be by default.

Many of the later options will be configured through “System sections” like the one to the right. Depending of which tab is selected on the top different options will be present.




Scroll down to Network Access Configuration, see below.

Here you will add a network that will be given access to the iSCSI LUN that will be created shortly. Set a name of your choice, then enter the subnet (e.g. where your iSCSI client will be (most likely the same as the Openfiler VM is on) and the correct subnet mask. Leave the Type as Share and then select Update.

The network(s) added here does not give access to anything now, and we must later select the appropriate networks for each LUN when they are made available through the iSCSI Target.


Now select the Services tab on the top and find the iSCSI target service and enable it as above.

Go on to the Volumes tab on the top and then Block Devices on the section to the right. Here you shall see two disks, first the smaller one used by the operating system called /dev/sda and a larger second one with the name /dev/sdb. Click on the second link to reach the partition page. Scroll down to the bottom and just click “Create” to create a single partition on the new disk that we added to the Virtual Machine.

Now select “Volume Groups” on the right section, just above Block Devices.

Enter a name for a new so called volume group, perhaps just “Volumegroup1”, select the newly created partition below (should be /dev/sdb1) and click add volume group.


Now select “Add Volume” to the right, just below Block Devices. Scroll down and enter a name for the volume, for example “Volume1”. Enter a description if wished, extend the volume all the way to the right (important or we will have no disk space at all) and change Filesystem/Volume type to iSCSI before clicking Create.

Then choose iSCSI Targets on the right, below the Add Volume part. Here will the final steps for the target be done.

On the first tab (Target Configuration) you can accept the default Target IQN name and just click add, or you can alter the second part of the IQN, for example:

Remember to click add and then move to the next sub tab on the right: LUN Mapping. Here will we attach the volume created earlier to a LUN that will be exposed by the iSCSI target service.

To get better performance there is some important changes that should be done here. On the R/W Mode you should alter the default “write-thru” to “write-back“. This should however not be done in a production environment without proper UPS protection, but in a lab it will greatly increase the write throughput.

Change the Transfer Mode from “blockio” to “fileio” and then finally click Map.

It will automatically be given the first available Logical Unit Number (LUN), here 0. If you later add more virtual disks to the iSCSI VM you can follow the steps again as they are identical, and the new disk will be LUN 1 and so on.

Next moment is to select the Network ACL tab and change the access type for the network created earlier to Allow. Without this no iSCSI initiators will be allowed to see the LUN at all. After selecting Update we are almost done!

The final part that should be done is to make sure the Openfiler is up to date with patches, which could be both security and performance related. Go to the tab SYSTEM on the top and select “System Update” on the right, then click “Launch system update“.

When the available patches are displayed, select “Update All Packages” on the top and then “Install Updates”. Close the window and wait approximately five minutes for the updates to download and install.

Hit F5 to refresh the Update Log window once in a while and when the final row shows “command complete” we are done. Go to Shutdown/Reboot on the right and let the server reboot.

We now have a working iSCSI target available on the network and you can connect for example a ESXi to the new iSCSI target and it should be able to see the new and empty LUN 0 available to create a VMFS partition on!

From the ESXi side it will look like this:

Please post comments or questions for this iSCSI setup guide.

Leave a Reply

Your email address will not be published. Required fields are marked *