VMware ESXi 7
Sponsored Link

Use iSCSI Storage2023/03/06

 
Attach iSCSI Storages on the network and use them as Datastore.
On this example, it uses iSCSI storage by Linux Server like here.
Also it allows the IQN below on the iSCSI Target Server for ESXi Host.
⇒ iqn.2023-03.world.srv:ctrl.initiator01
[1] To configure on shell access, set like follows.
# enable iSCSI feature

[root@ctrl:~]
esxcli iscsi software set --enabled true

Software iSCSI Enabled
[root@ctrl:~]
esxcli iscsi software get

true
[root@ctrl:~]
esxcli iscsi adapter list

Adapter  Driver     State   UID            Description
-------  ---------  ------  -------------  -----------
vmhba64  iscsi_vmk  online  iscsi.vmhba64  iSCSI Software Adapter

[root@ctrl:~]
esxcli iscsi adapter get -A vmhba64

vmhba64
   Name: iqn.1998-01.com.vmware:ctrl.srv.world:2061197269:64
   Alias: iscsi_vmk
   Vendor: VMware
   Model: iSCSI Software Adapter
   Description: iSCSI Software Adapter
   Serial Number:
   Hardware Version:
   Asic Version:
   Firmware Version:
   Option Rom Version:
   Driver Name: iscsi_vmk
   Driver Version:
   TCP Protocol Supported: false
   Bidirectional Transfers Supported: false
   Maximum Cdb Length: 64
   Can Be NIC: false
   Is NIC: false
   Is Initiator: true
   Is Target: false
   Using TCP Offload Engine: false
   Using ISCSI Offload Engine: false

# changte IQN to the one that is set in ACL of iSCSI Target
# * if you do not like to change the default IQN, allow the default IQN on the iSCSI Target side

[root@ctrl:~]
esxcli iscsi adapter set -A vmhba64 -n iqn.2023-03.world.srv:ctrl.initiator01

[root@ctrl:~]
esxcli iscsi adapter get -A vmhba64

vmhba64
   Name: iqn.2023-03.world.srv:ctrl.initiator01
   Alias: iscsi_vmk
   Vendor: VMware
.....
.....

# set username and password for CHAP authentication configured on iSCSI Target ACL

[root@ctrl:~]
esxcli iscsi adapter auth chap set --direction=uni --authname=username --secret=password --level=discouraged -A vmhba64
# discover iSCSI Target

[root@ctrl:~]
esxcli iscsi adapter discovery sendtarget add --address=10.0.0.30 -A vmhba64

# login to iSCSI Target

[root@ctrl:~]
esxcli storage core adapter rescan -A vmhba64

[root@ctrl:~]
esxcli iscsi session list

vmhba64,iqn.2023-03.world.srv:dlp.target01,00023d000001
   Adapter: vmhba64
   Target: iqn.2023-03.world.srv:dlp.target01
   ISID: 00023d000001
   TargetPortalGroupTag: 1
   AuthenticationMethod: none
   DataPduInOrder: true
   DataSequenceInOrder: true
   DefaultTime2Retain: 0
   DefaultTime2Wait: 2
   ErrorRecoveryLevel: 0
   FirstBurstLength: 65536
   ImmediateData: true
   InitialR2T: true
   MaxBurstLength: 262144
   MaxConnections: 1
   MaxOutstandingR2T: 1
   TSIH: 1

[root@ctrl:~]
esxcli storage core device capacity list

Device                                                                    Physical Blocksize  Logical Blocksize  Logical Block Count        Size  Format Type
------------------------------------------------------------------------  ------------------  -----------------  -------------------  ----------  -----------
t10.ATA_____QEMU_HARDDISK___________________________QM00001_____________                 512                512            167772160   81920 MiB  512n
t10.ATA_____QEMU_HARDDISK___________________________QM00003_____________                 512                512            335544320  163840 MiB  512n
t10.ATA_____QEMU_HARDDISK___________________________QM00005_____________                 512                512            335544320  163840 MiB  512n
naa.6001405b0481179103a4d64a3b5b744f                                                     512                512             20971520   10240 MiB  512n
# ↑ iSCSI storage
[2] After conneting to iSCSI storage, it's the same way to create Datastore on it with Localdisk.
[root@ctrl:~]
partedUtil get "/vmfs/devices/disks/naa.6001405b0481179103a4d64a3b5b744f"

1305 255 63 20971520
[root@ctrl:~] partedUtil setptbl \
"/vmfs/devices/disks/naa.6001405b0481179103a4d64a3b5b744f" gpt \
"1 2048 $(expr 20971520 - 2048) AA31E02A400F11DB9590000C2911D1B8 0" 
gpt
0 0 0 0
1 2048 20969472 AA31E02A400F11DB9590000C2911D1B8 0

[root@ctrl:~] vmkfstools -C vmfs6 -S iSCSI-Store \
"/vmfs/devices/disks/naa.6001405b0481179103a4d64a3b5b744f:1" 
create fs deviceName:'/vmfs/devices/disks/naa.6001405b0481179103a4d64a3b5b744f:1', fsShortName:'vmfs6', fsName:'iSCSI-Store'
deviceFullPath:/dev/disks/naa.6001405b0481179103a4d64a3b5b744f:1 deviceFile:naa.6001405b0481179103a4d64a3b5b744f:1
Checking if remote hosts are using this device as a valid file system. This may take a few seconds...
Creating vmfs6 file system on "naa.6001405b0481179103a4d64a3b5b744f:1" with blockSize 1048576, unmapGranularity 1048576, unmapPriority default and volume label "iSCSI-Store".
Successfully created new volume: 64018498-cb4a8256-3628-52540094d817

[root@ctrl:~]
esxcli storage vmfs extent list

Volume Name                                 VMFS UUID                            Extent Number  Device Name                                                               Partition
------------------------------------------  -----------------------------------  -------------  ------------------------------------------------------------------------  ---------
iSCSI-Store                                 64018498-cb4a8256-3628-52540094d817              0  naa.6001405b0481179103a4d64a3b5b744f                                              1
OSDATA-63edd31c-7f6b194e-4446-52540094d817  63edd31c-7f6b194e-4446-52540094d817              0  t10.ATA_____QEMU_HARDDISK___________________________QM00001_____________          7

[root@ctrl:~]
esxcli storage filesystem list

Mount Point                                        Volume Name                                 UUID                                 Mounted  Type           Size         Free
-------------------------------------------------  ------------------------------------------  -----------------------------------  -------  ------  -----------  -----------
/vmfs/volumes/64018498-cb4a8256-3628-52540094d817  iSCSI-Store                                 64018498-cb4a8256-3628-52540094d817     true  VMFS-6  10468982784   8960081920
/vmfs/volumes/63edd31c-7f6b194e-4446-52540094d817  OSDATA-63edd31c-7f6b194e-4446-52540094d817  63edd31c-7f6b194e-4446-52540094d817     true  VMFS-L  77040975872  73955016704
/vmfs/volumes/32a32ba4-c7431b3a-62bb-53408cbb2f76  BOOTBANK1                                   32a32ba4-c7431b3a-62bb-53408cbb2f76     true  vfat     4293591040   4079091712
/vmfs/volumes/70d28441-c34632eb-ec8b-af86d58e456a  BOOTBANK2                                   70d28441-c34632eb-ec8b-af86d58e456a     true  vfat     4293591040   4293525504
[3] To detach iSCSI Storages, operate like follows.
# switch to maintenance mode

[root@ctrl:~]
esxcli system maintenanceMode set --enable true

[root@ctrl:~]
esxcli system maintenanceMode get

Enabled
# remove iSCSI session

[root@ctrl:~]
esxcli iscsi session remove -A vmhba64

# remove iSCSI Target setting

[root@ctrl:~]
esxcli iscsi adapter discovery sendtarget remove --address=10.0.0.30 -A vmhba64

# set CHAP setting to the default to clear the current setting

[root@ctrl:~]
esxcli iscsi adapter auth chap set --default -A vmhba64
# restart system

[root@ctrl:~]
esxcli system shutdown reboot -r "2023-03-03 Maintenance"

# after restarting, release maintenance mode

[root@ctrl:~]
esxcli system maintenanceMode set --enable false

# if also disable iSCSI feature, set like follows

[root@ctrl:~]
esxcli iscsi software set --enabled false

Software iSCSI Disabled.
 
To configure on VMware Host Client, set like follows.
[4] Login to VMware Host Client with root user account and click [Storage] icon that is under [Navigator] menu.
[5] Click [Software iSCSI] button.
[6] Input CHAP username and password, Hostname or IP address of iSCSI Target, and Click [Save configuration] button.
[7] After successfully connected to iSCSI storage, it will be listed under the [Devices] pane.
Matched Content