vCLI: Managing iSCSI Storage

As I want to get deeper into VMware CLI (vCLI) I deciced to make a summary of the vSphere Command-Line Interface Installation and Scripting Guide. Every chapter will be a separate blog post.

This summary is meant for my documentation but feel free to make use of it.

In this blog post: Managing iSCSI Storage

Setting up Software iSCSI

  1. Determine the HBA type and retrieve the HBA ID (you will get something back like vmhba32)
    vicfg-iscsi –adapter –list
  2. Enable the Software iSCSI client
    vicfg-iscsi –swiscsi –enable
    You can check the status with
    vicfg-iscsi –swiscsi –list
  3. If you want you can set the iSCSI name (IQN) or alias
    vicfg-iscsi -I -n <iscsi_name> <adapter_name>
    vicfg-iscsi –iscsiname –name <iscsi_name> <adapter_name>
    vicfg-iscsi -I -a <alias_name> <adapter_name>
    vicfg-iscsi –iscsiname –alias <alias_name> <adapter_name>
  4. Add a dynamic discovery address or a static discovery address
    Dynamic: vicfg-iscsi <conn_options> –discovery –add –ip <ip_addr | domain_name> <adapter_name>
    Static: vicfg-iscsi <conn_options> –static –add –ip <ip_addr | domain_name> –name <iscsi_name <adapter_name>
  5. If you want to use CHAP authentication
    vicfg-iscsi –authentication –level <level> –method <auth_method>
    –auth_username <auth_u_name> –auth_password <auth_password>
    [–ip <stor_ip_addr|stor_hostname> [:<portnum>] [-name <iscsi_name]]
    <adapter_name>
  6. If you want to use mutual CHAP run the vicfg-iscsi -A command again with the -b option. Best practice is to use a different username and password.
    For the <level> you can use:

    • chapProhibited to disable host CHAP authentication
    • chapRequired to enable host CHAP authentication
  7. For additional iSCSI paremeters use vicfg-iscsi -W
  8. Rescan the host with vicfg-rescan

Setting up Dependent Hardware iSCSI

  1. Determine the HBA type and retrieve the HBA ID (you will get something back like vmhba32)
    vicfg-iscsi –adapter –list
  2. If you want you can set the iSCSI name (IQN) or alias
    vicfg-iscsi -I -n <iscsi_name> <adapter_name>
    vicfg-iscsi –iscsiname –name <iscsi_name> <adapter_name>
    vicfg-iscsi -I -a <alias_name> <adapter_name>
    vicfg-iscsi –iscsiname –alias <alias_name> <adapter_name>
  3. Set up port binding
    • Identify the VMkernel port of the dependent hardware iSCSI adapter.
      esxcli <conn_options> swiscsi vmknic list -d <vmhba>
    • Connect the dependent hardware iSCSI initiator to the iSCSI VMkernel ports by running the
      following command for each port.
      esxcli <conn_options> swiscsi nic add -n <port_name> -d <vmhba>
    • Verify that the ports were added to the dependent hardware iSCSI initiator.
      esxcli <conn_options> swiscsi nic list -d <vmhba>
    • Rescan the dependent hardware iSCSI initiator.
      vicfg-rescan <conn_options> <vmhba>
  4. The rest of the steps are the same as from step 4 Software iSCSI

Setting up independent Hardware iSCSI

  1. Determine the HBA Type and HBA ID
    vicf-iscsi –adapter –list
  2. Configure the HBA by running vicfg-iscsi -N with one or more of the following options:
    • –list (list network adapters)
    • –ip <ip address> (sets the HBA IPv4 address)
    • –subnetmask <subnetmask> (Sets the HBA subnetmask)
    • –gateway <default gateway> (Set the default gateway)
    • –set ARP=TRUE|FALSE (enable or disable ARP redirect)

    Of course you can use these option in one command line

  3. The rest is the same as from step 3 Software iSCSI

vicfg-iscsi Command syntax

-A –authentication -c <level>
-m <auth_method> -b
-u <ma_username>
-w <ma_password>
[-i <stor_ip_addr|stor_hostname> [:<portnum>] [-n <iscsi_name>]]
<adapter_name>
–level <level>
–method <auth_method> –mutual
–auth_username <ma_username>
–auth_password <ma_password>
[–ip <stor_ip_addr|stor_hostname> [:<portnum>]
[–name <iscsi_name>]] <adapter_name>
Enables mutual authentication.
You must enable authentication
before you can enable mutual
authentication.
-A –authentication -c <level>
-m <auth_method>
-u <auth_u_name>
-w <a_password>
[-i <stor_ip_addr|stor_hostname> [:<portnum>] [-n <iscsi_name>]]
<adapter_name>
–level <level>
–method <auth_method>
–auth_username <auth_u_name>
–auth_password <auth_password>
[–ip <stor_ip_addr|stor_hostname> [:<portnum>]
[–name <iscsi_name>]] <adapter_name>
Enables authentication using the
specified options.
-A –authentication -l <adapter_name>
–list <adapter_name>
Lists supported authentication
methods.
-D –discovery -a -i <stor_ip_addr|stor_hostname[:<portnum>] <adapter_name>
–add –ip <stor_ip_addr|stor_hostname> [:<portnum>]
<adapter_name>
Adds a dynamic discovery
address.
-D –discovery -l <adapter_name>
–list <adapter_name>
Lists dynamic discovery
addresses.
-D –discovery -r -i <stor_ip_addr|stor_hostname>[:<portnum>] <adapter_name>
–remove –ip <stor_ip_addr|stor_hostname> [:<portnum>]
<adapter_name>
Removes a dynamic discovery
address.
-H -l [<adapter_name>]
–list [<adapter_name>]
Lists all iSCSI adapters or a
specified adapter.
-L –lun -l <adapter_name>
–list <adapter_name>
Lists LUN information.
-L –lun -l -t <target_ID> <adapter_name>
–list –target_id <target_id> <adapter_name>
Lists LUN information for a
specific target.
-N –network (Independent hardware iSCSI only) -l <adapter_name>
–list <adapter_name>
Lists network properties.
-N –network (Independent hardware iSCSI only) -i <ip_addr> <adapter_name>
–ip <ip_addr> <vmhba>
Sets the HBA IPv4 address to
ip_addr.
-N –network (Independent hardware iSCSI only) -s <subnet_mask> <adapter_name>
–subnetmask <subnet_mask> <adapter_name>
Sets the HBA network mask to
subnet_mask.
-N –network (Independent hardware iSCSI only) -g <default_gateway> <adapter_name>
–gateway <default_gateway> <adapter_name>
Sets the HBA gateway to
default_gateway.
-N –network (Independent hardware iSCSI only) -i <ip_addr> -s <subnet mask>
-g <default_gateway> <adapter_name>
–ip <ip_addr> –subnetmask <subnet_mask>
–gateway <default_gateway> <adapter_name>
Sets the IP address, subnet mask,
and default gateway in one
command.
-p –pnp (Independent hardware iSCSI only) -l <adapter_name>
–list <adapter_name>
Lists physical network portal
options.
-p –pnp (Independent hardware iSCSI only) -M <mtu_size> <adapter_name>
–mtu <mtu-size> <adapter_name>
Sets physical network portal
options.
-I –iscsiname -a <alias_name> <adapter_name>
–alias <alias_name> <adapter_name>
Sets the iSCSI initiator alias.
-I –iscsiname -n <iscsi_name> <adapter_name>
–name <iscsi_name> <adapter_name>
Sets the iSCSI initiator name.
-I –iscsiname -l <adapter_name>
–list <adapter_name>
Lists iSCSI initiator options.
-M –mtu -p -M <mtu_size> <adapter_name>
–pnp –mtu <mtu-size> <adapter_name>
Sets MTU size. Used with the
–pnp option.
-S –static -l <adapter_name>
–list <adapter_name>
Lists static discovery addresses.
-S –static -r -i <stor_ip_addr|stor_hostname> [:<portnum>] -n <target_name>
<adapter_name>
–remove –ip <stor_ip_addr|stor_hostname> [:<portnum>] -name
<target_name> <adapter_name>
Removes a static discovery
address.
-S –static -a -i <stor_ip_addr|stor_hostname> [:<portnum>]
-n <target_name> <adapter_name>
–add –ip <stor_ip_addr|stor_hostname> [:<portnum>]
-name <target_name> <adapter_name>
Adds a static discovery address.
-P –phba -l <adapter_name>
–list <adapter_name>
Lists external, vendor‐specific
properties of an iSCSI adapter.
-T –target -l <adapter_name>
–list <adapter_name>
Lists target information.
-W ‐‐parameter -l [-i <stor_ip_addr|stor_hostname> [:<portnum>]
[-n <iscsi_name]] <adapter_name>
–list [–ip <stor_ip_addr|stor_hostname> [:<portnum>]
[–name <iscsi_name]] <adapter_name>
Lists iSCSI parameter
information.
-W ‐‐parameter -l -k [-i <stor_ip_addr|stor_hostname> [:<portnum>] [-n
<iscsi_name]] <adapter_name>
–list –detail
[–ip <stor_ip_addr|stor_hostname> [:<portnum>]
[–name <iscsi_name]] <adapter_name>
Lists iSCSI parameter details.
-W ‐‐parameter -W -j <name>=<value>
-i <stor_ip_addr|stor_hostname> [:port_num>] [-n <iscsi_name>]]
<adapter_name>
–parameter –set <name>=<value>
–ip <stor_ip_addr|stor_hostname> [:port_num>]
[–name <iscsi_name>]] <adapter_name>
Sets iSCSI parameters.
-W ‐‐parameter -W -o <param_name>
-i <stor_ip_addr|stor_hostname> [:port_num>] [-n <iscsi_name>]]
<adapter_name>
-parameter –reset <param_name>
-ip <stor_ip_addr|stor_hostname> [:port_num>]
[-name <iscsi_name>]] <adapter_name>
Returns parameters in discovery
target or send target to default
inheritance behavior.
-z –reset_auth -a -z
-m <auth_method> -b
[-i <stor_ip_addr|stor_hostname> [:<portnum>] [-n <iscsi_name>]]
<adapter_name>
–authentication –reset_auth
–method <auth_method>
[–ip <stor_ip_addr|stor_hostname> [:<portnum>]
[–name <iscsi_name>]] <adapter_name>
Resets target level authentication
properties to be inherited from
adapter level. Used with the
–authentication option.

About Michael
Michael Wilmsen is a experienced VMware Architect with more than 20 years in the IT industry. Main focus is VMware vSphere, Horizon View and Hyper Converged with a deep interest into performance and architecture. Michael is VCDX 210 certified, has been rewarded with the vExpert title from 2011, Nutanix Tech Champion and a Nutanix Platform Professional.

RSS feed for comments on this post.

Leave a Reply

You must be logged in to post a comment.