This document supports the version of each product listed and
supports all subsequent versions until the document is
replaced by a new edition. To check for more recent editions of
this document, see http://www.vmware.com/support/pubs.
EN-002352-00
vSphere Command-Line Interface Concepts and Examples
You can find the most up-to-date technical documentation on the VMware Web site at:
hp://www.vmware.com/support/
The VMware Web site also provides the latest product updates.
If you have comments about this documentation, submit your feedback to:
Path Claiming with esxcli storage core claiming 108
Using the Reclaim Troubleshooting Command 109
Unclaiming Paths or Sets of Paths 109
Managing Claim Rules 110
Change the Current Claim Rules in the VMkernel 110
Adding Claim Rules 111
Removing Claim Rules 112
Listing Claim Rules 113
Loading Claim Rules 113
Moving Claim Rules 113
Load and Apply Path Claim Rules 114
Running Path Claim Rules 114
Managing Users117
7
Users in the vSphere Environment 117
vicfg-user Command Syntax 118
Managing Users with vicfg-user 118
Assigning Permissions with ESXCLI 120
Managing Virtual Machines123
8
vmware-cmd Overview 123
Connection Options for vmware-cmd 124
General Options for vmware-cmd 124
Format for Specifying Virtual Machines 124
List and Register Virtual Machines 125
Retrieving Virtual Machine Aributes 125
Managing Virtual Machine Snapshots with vmware-cmd 127
Take a Virtual Machine Snapshot 127
Reverting and Removing Snapshots 128
Powering Virtual Machines On and O 128
Connecting and Disconnecting Virtual Devices 129
Working with the AnswerVM API 130
Forcibly Stop a Virtual Machine with ESXCLI 130
Managing vSphere Networking131
9
Introduction to vSphere Networking 131
Networking Using vSphere Standard Switches 132
Networking Using vSphere Distributed Switches 133
Retrieving Basic Networking Information 134
Troubleshoot a Networking Setup 134
6 VMware, Inc.
Seing Up vSphere Networking with vSphere Standard Switches 136
Seing Up Virtual Switches and Associating a Switch with a Network Interface 136
Retrieving Information About Virtual Switches 137
Adding and Deleting Virtual Switches 138
Checking, Adding, and Removing Port Groups 139
Managing Uplinks and Port Groups 140
Seing the Port Group VLAN ID 141
Managing Uplink Adapters 142
Adding and Modifying VMkernel Network Interfaces 145
Seing Up vSphere Networking with vSphere Distributed Switch 148
Managing Standard Networking Services in the vSphere Environment 149
Seing the DNS Conguration 149
Seing the DNS Conguration with ESXCLI 149
Seing the DNS Conguration with vicfg-dns 151
Manage an NTP Server 152
Manage the IP Gateway 152
Seing Up IPsec 153
Using IPsec with ESXi 154
Managing Security Associations 155
Managing Security Policies 156
Manage the ESXi Firewall 157
Monitor VXLAN 158
Contents
Monitoring ESXi Hosts161
10
Using resxtop for Performance Monitoring 161
Managing Diagnostic Partitions 161
Managing Core Dumps 162
Manage Local Core Dumps with ESXCLI 162
Manage Core Dumps with ESXi Dump Collector 163
Manage Core Dumps with vicfg-dumppart 164
Conguring ESXi Syslog Services 164
Managing ESXi SNMP Agents 166
Conguring SNMP Communities 166
Conguring the SNMP Agent to Send Traps 166
Conguring the SNMP Agent for Polling 168
Retrieving Hardware Information 169
Index171
VMware, Inc. 7
vSphere Command-Line Interface Concepts and Examples
8 VMware, Inc.
About This Book
vSphere Command-Line Interface Concepts and Examples explains how to use the commands in the VMware
vSphere® Command-Line Interface (vCLI) and includes command overviews and examples.
Intended Audience
This book is for experienced Windows or Linux system administrators who are familiar with vSphere
administration tasks and data center operations and know how to use commands in scripts.
VMware Technical Publications Glossary
VMware Technical Publications provides a glossary of terms that might be unfamiliar to you. For denitions
of terms as they are used in VMware technical documentation, go to
hp://www.vmware.com/support/pubs.
Related Documentation
The documentation for vCLI is available in the vSphere Documentation Center and on the vCLI
documentation page. Go to hp://www.vmware.com/support/developer/vcli.
Geing Started with vSphere Command-Line Interfaces includes information about available CLIs, enabling
n
the ESXi Shell, as well as installing and running vCLI and DCLI commands.
VMware, Inc.
vSphere Command-Line Interface Reference is a reference to both ESXCLI commands and vicfg-
n
commands. The vicfg- command help is generated from the POD available for each command, run
pod2html for any vicfg- command to generate individual HTML les interactively. The ESXCLI
reference information is generated from the ESXCLI help.
DCLI Reference is a reference to DCLI commands for managing vCenter services.
n
The documentation for PowerCLI is available in the vSphere Documentation Center and on the PowerCLI
documentation page.
The vSphere SDK for Perl documentation explains how you can use the vSphere SDK for Perl and related
utility applications to manage your vSphere environment.
The vSphere Management Assistant Guide explains how to install and use the vSphere Management Assistant
(vMA). vMA is a virtual machine that includes vCLI and other prepackaged software.
Background information for the tasks discussed in this book is available in the vSphere documentation set.
The vSphere documentation consists of the combined VMware vCenter Server and ESXi documentation.
9
vSphere Command-Line Interface Concepts and Examples
10 VMware, Inc.
vSphere CLI Command Overviews1
This chapter introduces the command set, presents supported commands for dierent versions of vSphere,
lists connection options, and discusses vCLI and lockdown mode.
This chapter includes the following topics:
“Introduction,” on page 11
n
“List of Available Host Management Commands,” on page 13
n
“Targets and Protocols for vCLI Host Management Commands,” on page 15
n
“Supported Platforms for vCLI Commands,” on page 15
n
“Commands with an esxcfg Prex,” on page 16
n
“ESXCLI Commands Available on Dierent ESXi Hosts,” on page 17
n
“Trust Relationship Requirement for ESXCLI Commands,” on page 17
n
“Using ESXCLI Output,” on page 19
n
“Connection Options for vCLI Host Management Commands,” on page 19
n
“Connection Options for DCLI Commands,” on page 19
n
“vCLI Host Management Commands and Lockdown Mode,” on page 19
n
Introduction
The commands in the vSphere CLI package allow you to perform vSphere conguration tasks using
commands from vCLI package installed on supported platforms, or using commands from vMA. The
package consists of several command sets.
The following table lists the components of the vSphere CLI command set.
vCLI CommandsDescription
ESXCLI commandsManage many aspects of an ESXi host. You can run ESXCLI commands remotely or in the
ESXi Shell.
You can also run ESXCLI commands from the PowerCLI prompt by using the Get-EsxCli
cmdlet.
vicfg- commands
VMware, Inc. 11
Set of commands for many aspects of host management Eventually, these commands will be
replaced by ESXCLI commands.
A set of esxcfg- commands that precisely mirrors the vicfg- commands is also included in
the vCLI package.
vSphere Command-Line Interface Concepts and Examples
vCLI CommandsDescription
Other commands
(vmware-cmd, vifs,
vmkfstools)
DCLI commandsManage VMware SDDC services.
Commands implemented in Perl that do not have a vicfg-prex. These commands are
scheduled to be deprecated or replaced by ESXCLI commands.
DCLI is a CLI client to the vSphere Automation SDK interface for managing VMware SDDC
services. A DCLI command talks to a vSphere Automation API endpoint to locate relevant
information, and then executes the command and displays result to the user.
You can install the vSphere CLI command set on a supported Linux or Windows system. See Geing Startedwith vSphere Command-Line Interfaces. You can also deploy the vSphere Management Assistant (vMA) to an
ESXi system of your choice.
After installation, run vCLI commands from the Linux or Windows system or from vMA.
Manage ESXi hosts with other vCLI commands by specifying connection options such as the target
n
host, user, and password or a congurationle. See “Connection Options for vCLI Host Management
Commands,” on page 19.
Manage vCenter services with DCLI commands by specifying a target vCenter Server system and
n
authentication options. See Geing Started with vSphere Command-Line Interfaces for a list of connection
options.
Documentation
You can nd information about dierent aspects of vCLI in separate publications.
Geing Started with vSphere Command-Line Interfaces includes information about available CLIs, enabling the
ESXi Shell, and installing and running vCLI commands.
Reference information for vCLI and DCLI commands is available on the vCLI documentation page
hp://www.vmware.com/support/developer/vcli/ and in the vSphere Documentation Center for the product
version that you are using.
vSphere Command-Line Interface Reference is a reference to vicfg- and related vCLI commands and
n
includes reference information for ESXCLI commands. All reference information is generated from the
help.
A reference to esxtop and resxtop is included in the Resource Management documentation.
n
The DCLI Reference is included separately from the vSphere Command-Line Interface Reference. All
n
reference information is generated from the help.
Command-Line Help
Available command-line help diers for the dierent command sets.
Command SetAvailable Command-Line Help
vicfg-
commands
ESXCLI
commands
DCLI commands
Run <vicfg-cmd> --help for an overview of each options.
Run Pod2Html with a vicfg- command as input and pipe the output to a le for more detailed help
information.
This output corresponds to the information available in the vSphere Command-Line Interface Reference.
Run --help at any level of the hierarchy for information about both commands and namespaces
available from that level.
Run --help for any command or namespace to display the input options, whether the option is
required, and the input option type. For namespaces, --help displays all available child namespaces
and commands.
Run dcli --help to display usage information for DCLI.
12 VMware, Inc.
List of Available Host Management Commands
vCLI host management commands from earlier versions have been replaced with commands that have
equivalent functionality.
The following table lists vCLI host management commands in alphabetical order and the corresponding
ESXCLI command if available. For ESXCLI, new commands and namespaces are added with each release.
See the Release Notes for the corresponding release for information.
Functionality of the DCLI command set that is being added in vSphere 6.0 and later is dierent from these
commands. They are not included in the table.
Chapter 1 vSphere CLI Command Overviews
vCLI 4.1
Command
esxcliesxcli (new syntax)
resxtopresxtop (No ESXCLI
svmotionsvmotion (No ESXCLI
vicfg-advcfgesxcli system settings
vicfg-authconfigvicfg-authconfig (No
vicfg-cfgbackupvicfg-cfgbackup (No
vicfg-dnsesxcli network ip dns
vicfg-dumppartesxcli system coredumpSets both the partition (esxcli system coredump partition)
vicfg-hostopsesxcli system
vicfg-ipsecesxcli network ip ipsec
vicfg-iscsiesxcli iscsi
vCLI 5.1 and later
CommandComment
All vCLI 4.1 commands have been renamed. Signicant additions
have been made to ESXCLI. Many tasks previously performed
with a vicfg- command is now performed with ESXCLI.
Monitors in real time how ESXi hosts use resources. Runs in
equivalent)
Supported only on Linux.
equivalent)
Must run against a
vCenter Server system.
advanced
ESXCLI equivalent)
ESXCLI equivalent)
Cannot run against a
vCenter Server system.
maintenancemode
esxcli system shutdown
interactive or batch mode.
See “Using resxtop for Performance Monitoring,” on page 161.
See the vSphere Resource Management documentation for a detailed
reference.
Moves a virtual machine’s congurationle, and, optionally, its
disks, while the virtual machine is running.
See “Migrating Virtual Machines with svmotion,” on page 63.
Performs advanced conguration.
The advanced seings are a set of VMkernel options. These
options are typically in place for specic workarounds or
debugging.
Use this command as instructed by VMware.
Remotely congures Active Directory seings for an ESXi host.
See “Using vicfg-authcong for Active Directory Conguration,”
on page 26.
Backs up the conguration data of an ESXi system and restores
previously saved conguration data.
See “Backing Up Conguration Information with vicfg-
cfgbackup,” on page 24.
Species an ESXi host’s DNS (Domain Name Server)
conguration.
See “Seing the DNS Conguration,” on page 149.
and the network (esxcli system coredump network) to use for
core dumps. Use this command to set up ESXi Dump Collector.
See “Managing Diagnostic Partitions,” on page 161.
Manages hosts.
“Stopping, Rebooting, and Examining Hosts,” on page 21.
“Entering and Exiting Maintenance Mode,” on page 22.
Sets up IPsec (Internet Protocol Security), which secures IP
communications coming from and arriving at ESXi hosts. ESXi
hosts support IPsec using IPv6.
See “Seing Up IPsec,” on page 153.
Manages hardware and software iSCSI storage.
See Chapter 5, “Managing iSCSI Storage,” on page 69.
VMware, Inc. 13
vSphere Command-Line Interface Concepts and Examples
vCLI 4.1
Command
vCLI 5.1 and later
CommandComment
vicfg-moduleesxcli system module
vicfg-mpath
vicfg-mpath35
esxcli storage core
path
vicfg-nasesxcli storage nfs
vicfg-nicsesxcli network nic
vicfg-ntpvicfg-ntp (No ESXCLI
equivalent)
vicfg-rescanesxcli storage core
adapter rescan
vicfg-routeesxcli network ip route
vicfg-scsidevsesxcli storage core
device
vicfg-snmpesxcli system snmp
vicfg-syslogesxcli system syslog
vicfg-uservicfg-user (No ESXCLI
equivalent)
vicfg-vmknicesxcli network ip
interface
vicfg-volumeesxcli storage
filesystem
vicfg-vswitchesxcli network vswitch
vifsvifs (No ESXCLI equivalent)
vihostupdateesxcli software vib
Enables VMkernel options. Use this command with the options
listed in this document, or as instructed by VMware.
See “Managing VMkernel Modules,” on page 25.
Congures storage arrays.
See “Managing Paths,” on page 50.
Manages NAS/NFS lesystems.
See “Managing NFS/NAS Datastores,” on page 57.
Manages the ESXi host's uplink adapters.
See “Managing Uplink Adapters,” on page 142.
Denes the NTP (Network Time Protocol) server.
See “Manage an NTP Server,” on page 152.
Rescans the storage conguration.
See “Scanning Storage Adapters,” on page 66.
Manages the ESXi host's route entry.
See “Manage the IP Gateway,” on page 152.
Finds and examines available LUNs.
See “Examining LUNs,” on page 45.
Manages the SNMP agent. See “Managing ESXi SNMP Agents,”
on page 166. Using SNMP in a vSphere environment is discussed
in detail in the vSphere Monitoring and Performance documentation.
New options added in vCLI 5.0.
Expanded SNMP support added in vCLI 5.1.
Species log seings for ESXi hosts including local storage
policies and server and port information for network logging. See
“Conguring ESXi Syslog Services,” on page 164.
The vCenter Server and Host Management documentation explains
how to set up system logs using the vSphere Web Client.
Creates, modies, deletes, and lists local direct access users and
groups of users. See Chapter 7, “Managing Users,” on page 117.
The vSphere Security documentation discusses security
implications of user management and custom roles.
Adds, deletes, and modies VMkernel network interfaces.
See “Adding and Modifying VMkernel Network Interfaces,” on
page 145.
Supports resignaturing the copy of a VMFS volume, and
mounting and unmounting the copy.
See “Managing Duplicate VMFS Datastores,” on page 32.
Adds or removes virtual switches or modies virtual switch
seings.
See “Seing Up Virtual Switches and Associating a Switch with a
Network Interface,” on page 136.
Performs le system operations such as retrieving and uploading
les on the ESXi system.
See “Managing the Virtual Machine File System with vmkfstools,”
on page 30.
Updates legacy ESXi hosts to a dierent version of the same major
release.
You cannot run vihostupdate against ESXi 5.0 and later hosts.
See “Managing VMkernel Modules,” on page 25.
14 VMware, Inc.
Chapter 1 vSphere CLI Command Overviews
vCLI 4.1
Command
vmkfstoolsvmkfstools (No ESXCLI
vmware-cmdvmware-cmd (No ESXCLI
vCLI 5.1 and later
CommandComment
Creates and manipulates virtual disks, le systems, logical
equivalent)
equivalent)
volumes, and physical storage devices on an ESXi host.
See “Managing the Virtual Machine File System with vmkfstools,”
on page 30.
Performs virtual machine operations remotely. This includes, for
example, creating a snapshot, powering the virtual machine on or
o, and geing information about the virtual machine.
See Chapter 8, “Managing Virtual Machines,” on page 123.
Targets and Protocols for vCLI Host Management Commands
Most vCLI commands are used to manage or retrieve information about one or more ESXi hosts. They can
target an ESXi host or a vCenter Server system.
When you target a vCenter Server system, you can use --vihost to specify the ESXi host to run the
command against. The only exception is svmotion, which you can run against vCenter Server systems, but
not against ESXi systems.
The following commands must have an ESXi system, not a vCenter Server system as a target.
vifs
n
vicfg-user
n
vicfg-cfgbackup
n
vihostupdate
n
vmkfstools
n
The resxtop command requires an HTTPS connection. All other commands support HTTP and HTTPS.
Supported Platforms for vCLI Commands
Platform support for vCLI commands diers depending on the vCenter Server and ESXi version.
You cannot run the vihostupdate command against an ESXi 5.0 or later system.
You cannot run vicfg-syslog --setserver or vicfg-syslog --setport with an ESXi 5.0 or later target.
The following table lists platform support for the dierent vCLI commands.
vCenter Server 5.x
CommandESXi 5.x and 6.x
DCLI
esxcli
resxtop
svmotion
vicfg-advcfg
vicfg-authconfig
vicfg-cfgbackup
vicfg-dns
vicfg-dumppart
vicfg-hostops
NoNoNoNoNo
YesYesYesYesNo
Yes (from Linux)Yes (from Linux)Yes (from
NoYesNoNoYes
YesYesYesYesYes
YesYesYesYesYes
YesNoYesNoNo
YesYesYesYesYes
YesYesYesYesYes
YesYesYesYesYes
and 6.xESXi 4.xESX 4.x
Linux)
Yes (from
Linux)
vCenter Server
4.x
Yes (from Linux)
VMware, Inc. 15
vSphere Command-Line Interface Concepts and Examples
CommandESXi 5.x and 6.x
vicfg-ipsec
vicfg-iscsi
vicfg-module
vicfg-mpath
vicfg-nas
vicfg-nics
vicfg-ntp
vicfg-rescan
vicfg-route
vicfg-scsidevs
vicfg-snmp
vicfg-syslog
vicfg-user
vicfg-vmknic
vicfg-volume
vicfg-vswitch
vifs
vihostupdateUse esxcli
vmkfstools
vmware-cmd
vicfg-mpath35
vihostupdate35
YesNoYesYesNo
YesYesYesYesYes
YesYesYesYesYes
YesYesYesYesYes
YesYesYesYesYes
YesYesYesYesYes
YesYesYesYesYes
YesYesYesYesYes
YesYesYesYesYes
YesYesYesYesYes
YesNoYesYesNo
NoNo for 5.0 targetYesNoYes
YesNoYesYesNo
YesYesYesYesYes
YesYesYesYesYes
YesYesYesYesYes
YesNoYesYesNo
software vib
instead.
YesNoYesYesNo
YesYesYesYesYes
NoNoNoNoNo
NoNoNoNoNo
vCenter Server 5.x
and 6.xESXi 4.xESX 4.x
Use esxcli
software vib
instead.
YesYesNo
vCenter Server
4.x
Commands with an esxcfg Prefix
To facilitate easy migration if shell scripts that use esxcfg- commands, the vCLI package includes a copy of
each vicfg- command that uses an esxcfgprex.
I You should use ESXCLI or the vCLI commands with the vicfgprex. Commands with the
esxcfg prex are available mainly for compatibility reasons and are now obsolete. vCLI esxcfg- commands
are equivalent to vicfg- commands, but not completely equivalent to the deprecated esxcfg- service console
commands.
The Following table lists all vCLI vicfg- commands for which a vCLI command with an esxcfgprex is
available.
Command with vicfg PrefixCommand with esxcfg Prefix
vicfg-advcfgesxcfg-advcfg
vicfg-cfgbackupesxcfg-cfgbackup
vicfg-dnsesxcfg-dns
vicfg-dumppartesxcfg-dumppart
vicfg-moduleesxcfg-module
16 VMware, Inc.
Chapter 1 vSphere CLI Command Overviews
Command with vicfg PrefixCommand with esxcfg Prefix
vicfg-mpathesxcfg-mpath
vicfg-nasesxcfg-nas
vicfg-nicsesxcfg-nics
vicfg-ntpesxcfg-ntp
vicfg-rescanesxcfg-rescan
vicfg-routeesxcfg-route
vicfg-scsidevsesxcfg-scsidevs
vicfg-snmpesxcfg-snmp
vicfg-syslogesxcfg-syslog
vicfg-vmknicesxcfg-vmknic
vicfg-volumeesxcfg-volume
vicfg-vswitchesxcfg-vswitch
ESXCLI Commands Available on Different ESXi Hosts
The available ESXCLI commands depend on the ESXi host version.
When you run an ESXCLI vCLI command, you must know the commands supported on the target host. For
example, if you run commands against ESXi 5.x hosts, ESXCLI 5.x commands are supported. If you run
commands against ESXi 6.x hosts, ESXCLI 6.x commands are supported.
Some commands or command outputs are determined by the host type. In addition, VMware partners
might develop custom ESXCLI commands that you can run on hosts where the partner VIB has been
installed.
Run esxcli --server <target> --help for a list of namespaces supported on the target. You can drill down
into the namespaces for additional help.
Trust Relationship Requirement for ESXCLI Commands
Starting with vSphere 6.0, ESXCLI checks whether a trust relationship exists between the machine where
you run the ESXCLI command and the ESXi host. An error results if the trust relationship does not exist.
Download and Install the vCenter Server Certificate
You can download the vCenter Server root certicate by using a Web browser and add it to the trusted
certicates on the machine where you plan to run ESXCLI commands.
Procedure
1Enter the URL of the vCenter Server system or vCenter Server Appliance into a Web browser.
2Click the Download trusted root link.
3Change the extension of the downloaded le to .zip. (The le is a ZIP le of all certicates in the
TRUSTED_ROOTS store).
4Extract the ZIP le.
A certicates folder is extracted. The folder includes les with the extension .0. .1, and so on, which are
certicates, and les with the extension .r0, r1, and so on which are CRL les associated with the
certicates.
VMware, Inc. 17
vSphere Command-Line Interface Concepts and Examples
5Add the trusted root certicates to the list of trusted roots.
The process diers depending on the platform that you are on.
What to do next
You can now run ESXCLI commands against any host that is managed by the trusted vCenter Server system
without supplying additional information if you specify the vCenter Server system in the --server option
and the ESXi host in the --vihost option.
Using the --cacertsfile Option
Using a certicate to establish the trust relationship is the most secure option.
You can specify the certicate with the --cacertsfile parameter or the VI_CACERTFILE variable.
Using the --thumbprint Option
You can supply the thumbprint for the target ESXi host or vCenter Server system in the --thumbprint
parameter or the VI_THUMBPRINT variable.
When you run a command, ESXCLI rst checks whether a certicatele is available. If not, ESXCLI checks
whether a thumbprint of the target server is available. If not, you receive an error of the following type.
Connect to sof-40583-srv failed. Server SHA-1 thumbprint: 5D:01:06:63:55:9D:DF:FE:38:81:6E:2C:FA:
71:BC:Usin63:82:C5:16:51 (not trusted).
You can run the command with the thumbprint to establish the trust relationship, or add the thumbprint to
the VI_THUMBPRINT variable. For example, using the thumbprint of the ESXi host above, you can run the
following command.
01:06:63:55:9D:DF:FE:38:81:6E:2C:FA:71:BC:63:82:C5:16:51 storage nfs list
Use the Credential Store
Your vCLI installation includes a credential store. You can establish trust for a user with the credential store.
You can manage the credential store with the credstore-admin utility application, which is located in
the /Perl/apps/general directory inside the VMware vSphere CLI directory.
I Updating the credential store is a two-step process. First you add the user and password for
the server, and then you add the thumbprint for the server.
Procedure
1Add the user and password for the target ESXi host to the local credential store.
If you are using a non-default credential store le, you must pass it in with the --credstore option.
If you do not use the --credstore option, the host becomes accessible without authentication.
18 VMware, Inc.
Chapter 1 vSphere CLI Command Overviews
Using ESXCLI Output
Many ESXCLI commands generate output you might want to use in your application. You can run esxcli
with the --formatter dispatcher option and send the resulting output as input to a parser.
The --formatter options supports three values - csv, xml, and keyvalue and is used before any namespace.
The following example lists all le system information in CSV format.
esxcli --formatter=csv storage filesystem list
You can pipe the output to a le.
esxcli --formatter=keyvalue storage filesystem list > myfilesystemlist.txt
I You should always use a formaer for consistent output.
Connection Options for vCLI Host Management Commands
You can run host management commands such as ESXCLI commands, vicfg- commands, and other
commands with several dierent connection options.
You can target hosts directly or target a vCenter Server system and specify the host you want to manage. If
you are targeting a vCenter Server system, specify the Platform Services Controller, which includes the
vCenter Single Sign-On service, for best security.
I For connections to ESXi hosts version 6.0 or later, vCLI supports both the IPv4 protocol and the
IPv6 protocol. For earlier versions, vCLI supports only IPv4. In all cases, you can congure IPv6 on the
target host with several of the networking commands.
See the Geing Started with vSphere Command-Line Interfaces documentation for a complete list and examples.
Connection Options for DCLI Commands
DCLI is a CLI client to the vSphere Automation SDK interface for managing VMware SDDC services. A
DCLI command talks to a vSphere Automation SDK endpoint to get the vSphere Automation SDK
command information, executes the command, and displays result to the user.
You can run DCLI commands locally or from an administration server.
Run DCLI on the Linux shell of a vCenter Server Appliance.
n
Install vCLI on a supported Windows or Linux system and target a vCenter Server Windows
n
installation or a vCenter Server Appliance. You have to provide endpoint information to successfully
run commands.
DCLI commands support other connection options than other commands in the command set.
See the Geing Started with vSphere Command-Line Interfaces documentation for a complete list and examples.
vCLI Host Management Commands and Lockdown Mode
For additional security, an administrator can place one or more hosts managed by a vCenter Server system
in lockdown mode. Lockdown mode aects login privileges for the ESXi host.
See the vSphere Security document in the vSphere Documentation Center for a detailed discussion of normal
lockdown mode and strict lockdown mode, and of how to enable and disable them.
VMware, Inc. 19
vSphere Command-Line Interface Concepts and Examples
To make changes to ESXi systems in lockdown mode, you must go through a vCenter Server system that
manages the ESXi system as the user vpxuser and include both the --server and --vihost parameters.
esxcli --server MyVC --vihost MyESXi storage filesystem list
The command prompts for the vCenter Server system user name and password.
The following commands cannot run against vCenter Server systems and are therefore not available in
lockdown mode.
vifs
n
vicfg-user
n
vicfg-cfgbackup
n
vihostupdate
n
vmkfstools
n
If you have problems running a command on an ESXi host directly, without specifying a vCenter Server
target, check whether lockdown mode is enabled on that host.
20 VMware, Inc.
Managing Hosts2
Host management commands can stop and reboot ESXi hosts, back up conguration information, and
manage host updates. You can also use a host management command to make your host join an Active
Directory domain or exit from a domain.
For information on updating ESXi 5.0 hosts with the esxcli software command and on changing the host
acceptance level to match the level of a VIB that you might want to use for an update, see the vSphereUpgrade documentation in the vSphere 5.0 Documentation Center.
This chapter includes the following topics:
“Stopping, Rebooting, and Examining Hosts,” on page 21
n
“Entering and Exiting Maintenance Mode,” on page 22
n
“Backing Up Conguration Information with vicfg-cfgbackup,” on page 24
n
“Managing VMkernel Modules,” on page 25
n
“Using vicfg-authcong for Active Directory Conguration,” on page 26
n
“Updating Hosts,” on page 27
n
Stopping, Rebooting, and Examining Hosts
You can stop, reboot, and examine hosts with ESXCLI or with vicfg-hostops.
Stopping and Rebooting Hosts with ESXCLI
You can shut down or reboot an ESXi host by using the vSphere Web Client or vCLI commands, such as
ESXCLI or vicfg-hostops.
Shuing down a managed host disconnects it from the vCenter Server system, but does not remove the host
from the inventory. You can shut down a single host or all hosts in a data center or cluster. Specify one of the
options listed in “Connection Options for vCLI Host Management Commands,” on page 19 in place of
<conn_options>.
To shut down a host, run esxcli system shutdown poweroff. You must specify the --reason option and
supply a reason for the shutdown. A --delay option allows you to specify a delay interval, in seconds.
To reboot a host, run system shutdown reboot. You must specify the --reason option and supply a reason
for the reboot. A --delay option allows you to specify a delay interval, in seconds.
VMware, Inc.
21
vSphere Command-Line Interface Concepts and Examples
Stopping, Rebooting, and Examining Hosts with vicfg-hostops
You can shut down or reboot an ESXi host by using the vSphere Web Client, or ESXCLI or the vicfg-hostops
vCLI command.
Shuing down a managed host disconnects it from the vCenter Server system, but does not remove the host
from the inventory. You can shut down a single host or all hosts in a data center or cluster. Specify one of the
options listed in “Connection Options for vCLI Host Management Commands,” on page 19 in place of
<conn_options>.
Single host - Run vicfg-hostops with --operation shutdown.
n
If the host is in maintenance mode, run the command without the --force option.
n
vicfg-hostops <conn_options> --operation shutdown
If the host is not in maintenance mode, use --force to shut down the host and all running virtual
You can display information about a host by running vicfg-hostops with --operation info.
vicfg-hostops <conn_options> --operation info
The command returns the host name, manufacturer, model, processor type, CPU cores, memory capacity,
and boot time. The command also returns whether vMotion is enabled and whether the host is in
maintenance mode.
Entering and Exiting Maintenance Mode
You can instruct your host to enter or exit maintenance mode with ESXCLI or with vicfg-hostops.
Enter and Exit Maintenance Mode with ESXCLI
You place a host in maintenance mode to service it, for example, to install more memory. A host enters or
leaves maintenance mode only as the result of a user request.
esxcli system maintenanceMode set allows you to enable or disable maintenance mode.
22 VMware, Inc.
Chapter 2 Managing Hosts
When you run the vicfg-hostops vCLI command, you can specify one of the options listed in “Connection
Options for vCLI Host Management Commands,” on page 19 in place of <conn_options>.
Procedure
1To enter maintenance mode, run the following command.
esxcli <conn_options> system maintenanceMode set --enable true
After all virtual machines on the host have been suspended or migrated, the host enters maintenance
mode.
N You cannot deploy or power on a virtual machine on hosts in maintenance mode.
2To exit maintenance mode, run the following command.
esxcli <conn_options> system maintenanceMode set --enable false
N If you aempt to exit maintenance mode when the host is no longer in maintenance mode, an
error informs you that maintenance mode is already disabled.
Enter and Exit Maintenance Mode with vicfg-hostops
You place a host in maintenance mode to service it, for example, to install more memory. A host enters or
leaves maintenance mode only as the result of a user request.
vicfg-hostops suspends virtual machines by default, or powers o the virtual machine if you run vicfghostops --action poweroff.
Nvicfg-hostops does not work with VMware DRS. Virtual machines are always suspended.
The host is in a state of Entering Maintenance Mode until all running virtual machines are suspended or
migrated. When a host is entering maintenance mode, you cannot power on virtual machines on it or
migrate virtual machines to it.
When you run the vicfg-hostops vCLI command, you can specify one of the options listed in “Connection
Options for vCLI Host Management Commands,” on page 19 in place of <conn_options>.
Procedure
1To enter maintenance mode, run the following command.
vicfg-hostops <conn_options> --operation enter
2To check whether the host is in maintenance mode or in the Entering Maintenance Mode state, run the
following command.
vicfg-hostops <conn_options> --operation info
After all virtual machines on the host have been suspended or migrated, the host enters maintenance mode.
You cannot deploy or power on a virtual machine on hosts in maintenance mode.
What to do next
You can put all hosts in a cluster or data center in maintenance mode by using the --cluster or --
datacenter option. You must not use those options unless suspending all virtual machines in that cluster or
data center is no problem.
You can later run vicfg-hostops <conn_options> --operation exit to exit maintenance mode.
VMware, Inc. 23
vSphere Command-Line Interface Concepts and Examples
Backing Up Configuration Information with vicfg-cfgbackup
After you congure an ESXi host, you can back up the host conguration data. You should always back up
your host conguration after you change the conguration or upgrade the ESXi image.
I The vicfg-cfgbackup command is available only for ESXi hosts. The command is not available
through a vCenter Server system connection. No equivalent ESXCLI command is supported.
Backup Tasks
During a conguration backup, the serial number is backed up with the conguration.
The number is restored when you restore the conguration. The number is not preserved when you run the
Recovery CD (ESXi Embedded) or perform a repair operation (ESXi Installable).
You can back up and restore conguration information as follows.
1Back up the conguration by using the vicfg-cfgbackup command.
2Run the Recovery CD or repair operation.
3Restore the conguration by using the vicfg-cfgbackup command.
When you restore a conguration, you must make sure that all virtual machines on the host are stopped.
Backing Up Configuration Data
You can back up conguration data by running vicfg-cfgbackup with the -s option.
The following example backs up conguration data in a temporary location.
For the backup lename, include the number of the build that is running on the host that you are backing
up. If you are running vCLI on vMA, the backup le is saved locally on vMA. Backup les can safely be
stored locally because virtual appliances are stored in the /vmfs/volumes/<datastore> directory on the host,
which is separate from the ESXi image and congurationles.
Restore Configuration Data
If you have created a backup, you can later restore ESXi conguration data.
When you restore conguration data, the number of the build running on the host must be the same as the
number of the build that was running when you created the backup le. To override this requirement,
include the -f (force) option.
When you run the vicfg-cfgbackup vCLI command, you can specify one of the options listed in
“Connection Options for vCLI Host Management Commands,” on page 19 in place of <conn_options>.
Procedure
1Power o all virtual machines that are running on the host that you want to restore.
2Log in to a host on which vCLI is installed, or log in to vMA.
3Run vicfg-cfgbackup with the -lag to load the host conguration from the specied backup le.
If you run the following command, you are prompted for conrmation.
4(Optional) To restore the host to factory seings, run vicfg-cfgbackup with the -r option.
vicfg-cfgbackup <conn_options> -r
Using vicfg-cfgbackup from vMA
To back up a host conguration, you can run vicfg-cfgbackup from a vMA instance. The vMA instance can
run on the host that you are backing up or restoring, also referred to as the target host, or on a remote host.
To restore a host conguration, you must run vicfg-cfgbackup from a vMA instance running on a remote
host. The host must be in maintenance mode, which means all virtual machines, including vMA, must be
suspended on the target host.
For example, a backup operation for two ESXi hosts, host1 and host2, with vMA deployed on both hosts
works as follows.
To back up one of the host’s conguration, run vicfg-cfgbackup from the vMA appliance running on
n
either host1 or host2. Use the --server option to specify the host for which you want backup
information. The information is stored on vMA.
To restore the host1 conguration, run vicfg-cfgbackup from the vMA appliance running on host2. Use
n
the --server option to point to host1 to restore the conguration to that host.
To restore the host2 conguration, run vicfg-cfgbackup from the vMA appliance running on host1. Use
n
the --server option to point to host2 to restore the conguration to that host.
Managing VMkernel Modules
The esxcli system module and vicfg-module commands support seing and retrieving VMkernel module
options.
The vicfg-module and esxcli system module commands are implementations of the deprecated esxcfg-
module service console command. The two commands support most of the options esxcfg-module supports.
vicfg-module and esxcli system module are commonly used when VMware Technical Support, a
Knowledge Base article, or VMware documentation instruct you to do so.
Manage Modules with esxcli system module
Not all VMkernel modules have seable module options.
The following example illustrates how to examine and enable a VMkernel module. Specify one of the
connection options listed in “Connection Options for vCLI Host Management Commands,” on page 19 in
place of <conn_options>.
Procedure
1List information about the module.
esxcli <conn_options> system module list --module=module_name
The system returns the name, type, value, and description of the module.
2(Optional) List all enabled or loaded modules.
esxcli <conn_options> system module list --enabled=true
esxcli <conn_options> system module list --loaded=true
3Enable the model.
esxcli <conn_options> system module set --module=module_name --enabled=true
VMware, Inc. 25
vSphere Command-Line Interface Concepts and Examples
4Set the parameter.
esxcli system module parameters set --module=module_name --parameter-
string="parameter_string"
5Verify that the module is congured.
esxcli <conn_options> system module parameters list --module=module_name
Manage Modules with vicfg-module
Not all VMkernel modules have seable module options.
The following example illustrates how the examine and enable a VMkernel modules. Specify one of the
connection options listed in “Connection Options for vCLI Host Management Commands,” on page 19 in
place of <conn_options>.
Procedure
1Run vicfg-module --list to list the modules on the host.
vicfg-module <conn_options> --list
2Run vicfg-module --set-options with connection options, the option string to be passed to a module,
Using vicfg-authconfig for Active Directory Configuration
ESXi can be integrated with Active Directory. Active Directory provides authentication for all local services
and for remote access through the vSphere Web Services SDK, vSphere Web Client, PowerCLI, and vSphere
CLI.
You can congure Active Directory seings with the vSphere Web Client, as discussed in the vCenter Serverand Host Management documentation, or use vicfg-autconfig.
vicfg-authconfig allows you to remotely congure Active Directory seings on ESXi hosts. You can list
supported and active authentication mechanisms, list the current domain, and join or part from an Active
Directory domain.
Prepare ESXi Hosts for Active Directory Integration
Before you run the vicfg-authconfig command on an ESXi host, you must prepare the host.
Procedure
1Congure ESXi and Active Directory to use same NTP server.
I All hosts that join Active Directory must also be managed by an NTP server to avoid
issues with clock skews and Kerberos tickets. You must make sure the ESXi system and the Active
Directory server are using the same time zone.
The ESXi system’s time zone is always set to UTC.
26 VMware, Inc.
Chapter 2 Managing Hosts
2Congure the ESXi system’s DNS to be in the Active Directory domain.
Set Up Active Directory to Work with ESXi
You can run vicfg-authconfig to add the ESXi host to the Active Directory domain. You can run the
command directly against the host or against a vCenter Server system, specifying the host with --vihost.
Prerequisites
Verify that you have installed the ESXi host, as explained in the vSphere Installation and Setup
n
documentation.
Verify that you have installed Windows Active Directory on a Windows Server that runs Windows 2000
n
Server, Windows Server 2003, or Windows Server 2008. See the Microsoft Web site for instructions and
best practices.
Verify that you have the appropriate Active Directory permissions and administrative privileges on the
n
ESXi host.
Verify that time between the ESXi system and Windows Active Directory is synchronized.
n
Procedure
1Test that the Windows Active Directory Server can ping the ESXi host by using the host name.
ping <ESX_hostname>
2Run vicfg-authconfig to add the host to the Active Directory domain.
vicfg-authconfig --server=<ESXi Server IP Address>
--username=<ESXi Server Admin Username>
--password=<ESXi Server Admin User's Password>
--authscheme AD --joindomain <AD Domain Name>
--adusername=<Active Directory Administrator User Name>
The system prompts for user names and passwords if you do not specify them on the command line.
Passwords are not echoed to the screen.
3Check that a Successfully Joined <Domain Name> message appears.
4Verify the ESXi host is in the intended Windows Active Directory domain.
vicfg-authconfig --server XXX.XXX.XXX.XXX --authscheme AD -c
You are prompted for a user name and password for the ESXi system.
Updating Hosts
When you add custom drivers or patches to a host, the process is called an update.
Update ESXi 4.0 and ESXi 4.1 hosts with the vihostupdate command, as discussed in the vSphere
n
Command-Line Interface Installation and Reference Guide included in the vSphere 4.1 documentation set.
Update ESXi 5.0 hosts with esxcli software vib commands discussed in the vSphere Upgrade
n
documentation included in the vSphere 5.0 documentation set. You cannot run the vihostupdate
command against ESXi 5.0 or later.
Update ESXi 5.0 hosts with esxcli software vib commands discussed in the vSphere Upgrade
n
documentation included in the vSphere 5.0 documentation set. You cannot run the vihostupdate
command against ESXi 5.0 or later.
Update ESXi 5.1 hosts with esxcli software vib commands discussed in the vSphere Upgrade
n
documentation included in the vSphere 5.1 documentation set.
VMware, Inc. 27
vSphere Command-Line Interface Concepts and Examples
Update ESXi 5.5 hosts with esxcli software vib commands discussed in the vSphere Upgrade
n
documentation included in the vSphere 5.5 documentation set.
Update ESXi 6.0 hosts with esxcli software vib commands discussed in the vSphere Upgrade
n
documentation included in the vSphere 6.0 documentation set.
Update ESXi 6.5 hosts with esxcli software vib commands discussed in the vSphere Upgrade
n
documentation included in the vSphere 6.5 documentation set.
28 VMware, Inc.
Managing Files3
The vSphere CLI includes two commands for le manipulation. vmkfstools allows you to manipulate VMFS
(Virtual Machine File System) and virtual disks. vifs supports remote interaction with les on your ESXi
host.
N See Chapter 4, “Managing Storage,” on page 41 for information about storage manipulation
commands.
This chapter includes the following topics:
“Introduction to Virtual Machine File Management,” on page 29
n
“Managing the Virtual Machine File System with vmkfstools,” on page 30
n
“Upgrading VMFS3 Volumes to VMFS5,” on page 31
n
“Managing VMFS Volumes,” on page 31
n
“Reclaiming Unused Storage Space,” on page 34
n
“Using vifs to View and Manipulate Files on Remote ESXi Hosts,” on page 35
n
Introduction to Virtual Machine File Management
VMware, Inc.
You can use the vSphere Web Client or vCLI commands to access dierent types of storage devices that your
ESXi host discovers and to deploy datastores on those devices.
N Datastores are logical containers, analogous to le systems, that hide specics of each storage device
and provide a uniform model for storing virtual machine les. Datastores can be used for storing ISO
images, virtual machine templates, and oppy images. The vSphere Web Client uses the term datastore
exclusively. In vCLI, the term datastore, as well as VMFS or NFS volume, refer to the same logical container
on the physical device.
Depending on the type of storage you use, datastores can be backed by the VMFS and NFS le system
formats.
Virtual Machine File System (VMFS) - High-performance le system that is optimized for storing
n
virtual machines. Your host can deploy a VMFS datastore on any SCSI-based local or networked storage
device, including Fibre Channel and iSCSI SAN equipment. As an alternative to using the VMFS
datastore, your virtual machine can have direct access to raw devices and use a mapping le (RDM) as
a proxy.
You manage VMFS and RDMs with the vSphere Web Client, or the vmkfstools command.
29
iSCSI array
VMFSVMFS
LANLAN
iSCSI
hardware
initiator
ethernet
NIC
Host
requires TCP/IP connectivity
software
initiator
NAS
appliance
NFS
LAN
ethernet
NIC
fibre
array
VMFS
VMFS
LAN
fibre
channel
HBA
local
ethernet
SCSI
vSphere Command-Line Interface Concepts and Examples
Network File System (NFS) - The NFS client built into ESXi uses the NFS protocol over TCP/IP to access
n
a designated NFS volume that is located on a NAS server. The ESXi host can mount the volume and use
it for its storage needs. vSphere supports versions 3 and 4.1 of the NFS protocol. Typically, the NFS
volume or directory is created by a storage administrator and is exported form the NFS server. The NFS
volumes do not need to be formaed with a local le system, such as VMFS. You can mount the
volumes directly and use them to store and boot virtual machines in the same way that you use VMFS
datastores. The host can access a designated NFS volume located on an NFS server, mount the volume,
and use it for any storage needs.
You manage NAS storage devices from the vSphere Web Client or with the esxcli storage nfs
command. The diagram below illustrates dierent types of storage, but it is for conceptual purposes
only. It is not a recommended conguration.
Figure 3‑1. Virtual Machines Accessing Different Types of Storage
Managing the Virtual Machine File System with vmkfstools
VMFS datastores primarily serve as repositories for virtual machines.
You can store multiple virtual machines on the same VMFS volume. Each virtual machine, encapsulated in a
set of les, occupies a separate single directory. For the operating system inside the virtual machine, VMFS
preserves the internal le system semantics.
In addition, you can use the VMFS datastores to store other les, such as virtual machine templates and ISO
images. VMFS supports le and block sizes that enable virtual machines to run data-intensive applications,
including databases, ERP, and CRM, in virtual machines. See the vSphere Storage documentation.
30 VMware, Inc.
Loading...
+ 144 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.