iSCSI ESX Datastore

using iscsi for the esx datastore

9 August 2017   3 min read

Due to close scare in my lab I decided to switch the datastore from a single onboard hdd to iSCSI. I use a WD MyCloud EX2 Ultra but there are a lot of more advanced NAS out there with a whole host of extra features. The WD is rather basic but is sufficient for my needs of partitioning it into a backup drive and an iSCSI drive. Since moving onto this I haven’t noticed any real performance degradation in my lab, its run over 1 Gig port.

The iSCSI adapter and physical NIC connect through a VMK. I created the new VMK on a separate vSphere switch (vSwitch) using a 1:1 mapping between the virtual and physical network adapter. If you needed Jumbo frames this can be set on the vswitch and the VMK.
In this example the vSwitch and VLAN are called ‘iscsi’, VLAN ID is ‘5’ and is on the ‘10.10.5.0/24’ network.

1. Create vswitch called iscsi and map it to a physical NIC

esxcli network vswitch standard add --vswitch-name=iscsi
esxcli network vswitch standard uplink add --uplink-name=vmnic0 --vswitch-name=iscsi

2. Create a port-group, map to the vlan, add the VMK and give it an IP. This VMK that will be used solely for iSCSI.

esxcli network vswitch standard portgroup add -p iscsi -v iscsi
esxcli network vswitch standard portgroup set -p iscsi -v 5
esxcli network ip interface add --interface-name=vmk0 --portgroup-name=iscsi
esxcli network ip interface ipv4 set --interface-name=vmk0 --ipv4=10.10.5.51 --netmask=255.255.255.0 --type=static

3. Test that you have IP and TCP connectivity to the iSCSI drive.

vmkping 10.10.5.61                                                                 The equivalent of normal ping

esxcli iscsi software set -e true                     Need to enable iSCSI to test TCP connectivity
nc -z 10.10.5.61 3260 Test TC connectivity on port 3260
Connection to 10.10.5.61 3260 port tcp/* succeeded!

4. Associate the VMK and add a Dynamic target. If you do in the GUI (under storage) enter the iSCSI IP, it then scans and sets the static targets for you.

esxcli iscsi adapter list                                                          Check the adapter name, usually vmhbaxx

esxcli iscsi networkportal add -A vmhba64 -n vmk0   Bind the vmk to iscsi interface
esxcli iscsi adapter discovery sendtarget add -A vmhba64 -a 10.10.5.61:3260        Connect iSCSI adapter to iSCSI target

esxcli iscsi networkportal list                Check the interface and that VMK is bound

Can now go ahead and create a new datastore. In the GUI it will show up under devices as Normal, Degraded if you only have 1 ethernet link to the iSCSI. If the iSCSI already has a datastore on it can be rediscovered (can take 5 mins).

esxcli iscsi adapter discovery rediscover -A vmhba64
df                  Check the datastore has been added

For the VMs to appear in the inventory you need re-register each of them by referencing the .vmx file.

ls -l /vmfs/volumes/ds1/                                                           List all the vm folders
vim-cmd solo/registervm /vmfs/volumes/ds1/vm_name/vm_name.vmx
vim-cmd vmsvc/getallvms                     List all registered VMs
vim-cmd vmsvc/power.on                     Power on a vmvim-cmd
esxcli vm process list                              List all powered on vms