Use Windows Server as iSCSI target with ESXi

The task: to move a virtual machine from one ESXi to another. The ESXis are on two completely separate networks. VM size is 5.5 TB, with one file being 5TB.

The problem: VM cannot be started due to maxed out resources. There’s no NAS or any other means of storage where the files could be transferred to. From previous experience, I knew that transfer over SSH or USB would be well too slow, as the task was time critical. There wasn’t also a big enough single hard disk which could be used to copy the files onto it.

My proposed solution: Use any spare desktop/server and load it with hard drives, so that all of them can create spanned virtual disk big enough to accommodate files from ESXi, install at least server 2012r2 on it and configure as an ISCSI target.

As you can see above, it was quite an unusual task with quite unusual conditions.

Requirements:

  • Windows box:
    • Spare computer
    • 1HDD for OS
    • Number of HDDs, which summarised capacity would be enough to accommodate files from ESXi. HDDs might be a different size
    • One network adapter
  • Source and destination ESXi:
    • at least one spare network port which can be configured as uplink
    • Possibility to enable iSCSI (I was working on ESXi 6.5)

Let’s start preparation!

Prepare Windows server

I take it you’ve prepared a fresh installation of Windows server, if not go ahead and do it. I’ve used 2012 R2 for the purpose of the task. Don’t forget to activate it.

Another important step is to configure network card you’re going to use with static IP – as we will tell ESXi to connect to the server over that IP. All you need is an IP address and subnet mask.

Unless you’re willing to connect over the network then obviously gateway would be needed. However, it is strongly recommended to use iSCSI on the isolated network – due to security, performance and stability reasons.

Create spanned volume

Once you’ve got your server ready for a spin – the first step is to create a spanned volume – we will simply use all spare hard drives and create one massive disk out of them. I’ve used 1TB, 3TB and 4TB disks, which gave me some 8TB of space altogether.

You’d like to press CTRL + X and bring disk manager. Then right-click on each of the disks and initialize it, then bring them online. In my example, the disks are numbered 1,2 and 3.

Next step is the actual creation of the Spanned Volume, you click on any of the spare disks, and choose “New Spanned Volume”, click next and on “Select Disks” page Add all disks, so that total volume size shows summed storage space from all of them. You assign any letter drive you want, give any name (I called mine BIG) and make sure to tick Perform a quick format.

Spanned volume creation

That’s it, once you click finish you will see the colour of disks changing to purple-ish, and all three disks will have the same partition name with the same letter assigned – in my case “BIG (F:). You can go to my computer and check yourself that this “disk” in fact exists.

Install iSCSI Target Server role

Now it’s time to add iSCSI role so that we can create the iSCSI disk and attach it to ESXi.  iSCSI is a technology which allows you to attach a network drive to the PC and use it as it was a local disk.

Bring up Add roles and features wizard, and on “Server roles” tab check: File and Storage Service > File and iSCSI Services > iSCSI Target Server, accept the default and go ahead with the installation.

iSCSI target role installation

You can achieve the same result using Windows Powershell by using the command:

Create iSCSI disk and target

Final step of our configuration is the actual creation of iSCSI virtual disk.

Head on to the server manager, go to the Files and storage pane > choose iSCSI tab. Click on TASKS and choose “New iSCSI Virtual Disk”

On the new windows that shows up, choose the location on your newly created spanned disk (F: in my case), provide any meaningful name. On the disk size, choose max available space (7.81TB in my case) and choose the disk to grow dynamically.

Since there are no iSCSI targets configured yet, choose to create a new one, give it any name and choose to identify by the IP address (in my case 10.4.1.5) .

There’s no need for authentication here, so just move on next and finish the wizard, which will end up in creating the iSCSI disk with the associated target.

iSCSI virtual disk creation

Powershell way:

At this point, you’re ready to plug your Windows Server directly to the spare ESXi network port. We’re going to do some configuration on ESXi now.

Configure ESXi

Create VMKernel NIC

To start with I wanted to thanks Andy who helped me with VMkernel NIC configuration – it would take me much longer to figure out this myself! Drop me the line if you’re reading thi!

In order to connect the iSCSI disk to ESXi we need network port configured, so if you haven’t yet plugged in your just prepared Windows server to the hypervisor – go and do it now.

We need to configure Virtual switch, port group and finally VMKernal NIC

Click on Networking pane and choose Virtual Switches tab. Down there choose an option to add a new switch. In the new Window that pops out give it a meaningful name and choose the right uplink (port on NIC)

Next click on Port groups tab and choose ato add port group, give it meaningful name, choosing the switch you’ve just created.

The final step is to click on VMkernel NICs tab and add the new VMkernel NIC. Choose port group you’ve created in the previous step, then choose that IP should be static and give it IP address in the same subnet as your Windows machine.

I configured my Windows machine to be 10.4.1.5/24 and VMkernel NIC to be 10.4.1.4/24

Create VMKernel NIC

Add iSCSI disk and configure it as datastore

We’re coming to the very end of the configuration – everything has been configured and the last step is to create a datastore on the iSCSI disk.

Click on storage pane and choose Adapters and click on Configure iSCSI, on the new windows choose to enable iSCSI, and type in the dynamic address field type in the IP of Windows machine, confirm.

After that head on to Datastores tab and choose Add Datastore to create new VMFS datastore, point it to the Windows datastore and create your datastore.

That’s it, you can use newly created datastore as it was the locally attached disk.

ESXi adding iSCSI disk and creating datastore

You can obviously use this configuration in any different scenarios

Since having the possibility of using Windows as iSCSI target is not that very popular, I think using ESXi with attached iSCSI datastores can be an easy and cheap way of making more space for your VMs.

Yet this non-typical topic allowed me to complete this very strange situation within a relatively short and easy way.

Have you found yourself? Do you know any other means of achieving the same goals? Please let me know!

How’s my story ended?

After connecting Windows Server to vSphere with the iSCSI disk, I was able to create the datastore. I then copied the massive VM to it and replugged Win server to the other ESXi server. Once connected and mounted the iSCSI disk – I was able to register the VM.

Hit the start button, choose the VM was copied and boom – I had a working VM directly from the external disks. From that point on I was able to install the backup agent on it and back it up directly to the tape.

Problem solved! Yay!

0 comments on “Use Windows Server as iSCSI target with ESXi

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.