You are on page 1of 152

vSphere Command-Line Interface Installation and Scripting Guide

ESX 4.1 ESXi 4.1 vCenter Server 4.1

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-000274-00

vSphere Command-Line Interface Installation and Scripting Guide

You can find the most up-to-date technical documentation on the VMware Web site at: http://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: docfeedback@vmware.com

Copyright 20082010 VMware, Inc. All rights reserved. This product is protected by U.S. and international copyright and intellectual property laws. VMware products are covered by one or more patents listed at http://www.vmware.com/go/patents. VMware is a registered trademark or trademark of VMware, Inc. in the United States and/or other jurisdictions. All other marks and names mentioned herein may be trademarks of their respective companies.

VMware, Inc. 3401 Hillview Ave. Palo Alto, CA 94304 www.vmware.com

VMware, Inc.

Contents

AboutThisBook

1 InstallingvCLI 11
InstallationOverview 11 InstallingandUninstallingvCLIonLinux 11 InstallationProcess 12 InstallingPrerequisiteSoftwareforRedHatEnterpriseLinux5.2 13 RequiredSoftware 13 RecommendedPerlModules 13 InstallingPrerequisiteSoftwareforSLES10andSLES11 13 RequiredSoftware 13 RecommendedPerlModules 13 InstallingPrerequisiteSoftwareforUbuntuDesktop9.04 13 RequiredSoftware 14 RecommendedPerlModules 14 InstallingthevCLIPackage 14 UninstallingthevCLIPackageonLinux 15 InstallingandUninstallingvCLIonWindows 15 DeployingvMA 17

2 RunningvCLICommands 19
OverviewofRunningCommands 19 SpecifyingAuthenticationInformation 20 OrderofPrecedenceforvCLIAuthentication 20 UsingaSessionFile 20 UsingEnvironmentVariables 21 UsingaConfigurationFile 21 UsingCommandLineOptions 22 UsingMicrosoftWindowsSecuritySupportProviderInterface 22 vCLIandLockdownMode 23 CommonOptionsforvCLIExecution 23 UsingvSphereCLICommandsinScripts 25

3 ManagingHosts 27
Stopping,RebootingandExaminingHostswithvicfghostops 27 EnteringandExitingMaintenanceModewithvicfghostops 28 BackingUpConfigurationInformationwithvicfgcfgbackup 28 BackupTasks 28 BackingUpConfigurationData 29 RestoringConfigurationData 29 UsingvicfgcfgbackupfromvMA 29 ManagingHostUpdateswithvihostupdate 29 DeployingThirdPartyBundles 31 RemovingBulletinsfromaHost 31 ManagingVMkernelModuleswithvicfgmodule 32 UsingvicfgauthconfigforActiveDirectoryConfiguration 32

VMware, Inc.

vSphere Command-Line Interface Installation and Scripting Guide

4 ManagingFiles 35
IntroductiontoVirtualMachineFileManagement 35 ManagingtheVirtualMachineFileSystemwithvmkfstools 36 vmkfstoolsCommandSyntax 36 SupportedCommandSpecificOptions 37 SupportedvmkfstoolTargets 38 vmkfstoolsFileSystemOptions 38 CreatingaVMFSFileSystem 38 ListingVMFSVolumeAttributes 39 ExtendingVMFSPartitionsbySpanning 39 vmkfstoolsVirtualDiskOptions 40 SupportedDiskFormats 40 CreatingVirtualDisks 41 InitializingVirtualDisks 41 InflatingThinVirtualDisks 41 DeletingVirtualDisks 42 RenamingVirtualDisk 42 CloningVirtualorRawDisks 42 MigratingVMwareWorkstationandVMwareGSXServerVirtualMachines 43 ExtendingVirtualDisks 43 DisplayingVirtualDiskGeometry 43 ManagingRawDeviceMappingFiles 44 RDMVirtualandPhysicalCompatibilityModes 44 CreatingVirtualCompatibilityModeRawDeviceMappings 45 CreatingPhysicalCompatibilityModeRawDeviceMappings 45 UsingvifstoManipulateFilesonRemoteESX/ESXiHosts 46

5 ManagingStorage 49
IntroductiontoStorage 49 HowVirtualMachinesAccessStorage 50 Datastores 51 StorageDeviceNaming 51 ExaminingLUNswithvicfgscsidevs 52 TargetandDeviceRepresentation 52 ExaminingLUNs 52 ManagingPathswithvicfgmpath 53 MultipathingwithLocalStorageandFCSANs 53 ListingPathInformation 54 ChangingtheStateofaPath 55 ManagingPathPolicieswithesxcli 55 SettingPolicyDetailsforDevicesthatUseRoundRobin 56 MaskingPathswithesxclicorestorageclaimrule 57 ManagingNFS/NASDatastoreswithvicfgnas 58 CapabilitiesSupportedbyNFS/NAS 58 AddingandDeletingNASFileSystems 59 MigratingVirtualMachineswithsvmotion 59 StorageVMotionUses 59 StorageVMotionRequirementsandLimitations 60 RunningsvmotioninInteractiveMode 60 RunningsvmotioninNoninteractiveMode 60 ManagingDuplicateVMFSDatastoreswithvicfgvolume 61 MountingDatastoreswithExistingSignatures 61 ResignaturingVMFSCopies 62 RescanningStorageAdapterswithvicfgrescan 63
4 VMware, Inc.

Contents

6 ManagingiSCSIStorage 65
iSCSIStorageOverview 65 DiscoverySessions 66 DiscoveryTargetNames 67 ProtectinganiSCSISAN 67 ProtectingTransmittedData 67 SecuringiSCSIPorts 68 SettingiSCSICHAP 68 iSCSIStorageSetup 69 SettingUpSoftwareiSCSI 69 SettingUpDependentHardwareiSCSI 70 SettingUpIndependentHardwareiSCSI 72 vicfgiscsiCommandSyntax 73 ListingandSettingiSCSIOptions 77 ListingandSettingiSCSIParameters 77 ReturningParameterstoDefaultInheritance EnablingiSCSIAuthentication 79 SettingUpPortsforiSCSIMultipathing 80 ManagingiSCSISessions 80 ListingiSCSISessions 80 LoggingintoiSCSISessions 81 RemovingiSCSISessions 81

79

7 ManagingUsers 83
UsersandGroupsinthevSphereEnvironment 83 vicfguserCommandSyntax 83 ManagingUserswithvicfguser 84 ManagingGroupswithvicfguser 86

8 ManagingVirtualMachines 89
vmwarecmdOverview 89 ConnectionOptionsforvmwarecmd 89 GeneralOptionsforvmwarecmd 90 FormatforSpecifyingVirtualMachines 90 ListingandRegisteringVirtualMachines 90 RetrievingVirtualMachineAttributes 91 ManagingSnapshotswithvmwarecmd 92 TakingSnapshots 92 RevertingandRemovingSnapshots 93 PoweringVirtualMachinesOnandOff 93 ConnectingandDisconnectingVirtualDevices 94 RetrievingUserInput 95 ForciblyStoppingVirtualMachines 95

9 ManagingThirdPartyStorageArrayswithesxcli 97
esxcliCommandSyntax 98 ManagingNMPwithesxclinmp 99 DeviceManagementwithesxclinmpdevice esxclinmpdevicelist 99 esxclinmpdevicesetpolicy 99 ListingPathswithesxclinmppath 99 99

VMware, Inc.

Contents

ManagingPathSelectionPolicyPluginswithesxclinmppsp 100 RetrievingPSPInformation 100 SettingConfigurationParametersforThirdPartyExtensions 100 FixedPathSelectionPolicyOperationswithesxclinmpfixed 100 esxclinmpfixedgetpreferred 100 esxclinmpfixedsetpreferred 101 CustomizingRoundRobinSetupwithesxclinmproundrobin 101 esxclinmproundrobingetconfig 101 esxclinmproundrobinsetconfig 101 ManagingSATPswithesxclinmpsatp 102 RetrievingInformationAboutSATPs 102 AddingSATPRules 102 DeletingSATPRules 103 RetrievingandSettingSATPConfigurationParameters 103 SettingtheDefaultPSP 104 PathClaimingwithesxclicorestorageclaiming 104 esxclicorestorageclaimingreclaim 104 esxclicorestorageclaimingunclaim 105 ManagingClaimRuleswithesxclicorestorageclaimrule 106 AddingClaimRuleswithesxclicorestorageclaimruleadd 106 ConvertingESX3.5LUNMaskstoClaimRuleFormat 107 DeletingClaimRuleswithesxclicorestorageclaimruledelete 108 ListingClaimRuleswithesxclicorestorageclaimrulelist 108 LoadingClaimRuleswithesxclicorestorageclaimruleload 108 MovingClaimRuleswithesxclicorestorageclaimrulemove 109 esxclicorestorageclaimrulerun 109

10 ManagingvSphereNetworking 111
IntroductiontovSphereNetworking 111 NetworkingUsingvNetworkStandardSwitches 112 NetworkingUsingvNetworkDistributedSwitches 113 SettingUpvSphereNetworkingwithvNetworkStandardSwitches 113 SettingUpVirtualSwitchesandAssociatingaSwitchwithaNetworkInterface 114 RetrievingInformationaboutVirtualSwitches 114 AddingandDeletingVirtualSwitches 115 SettingSwitchAttributes 115 Checking,Adding,andRemovingPortGroups 115 ConnectingandDisconnectingUplinkAdaptersandPortGroups 115 SettingthePortGroupVLANID 116 LinkingandUnlinkingUplinkAdapters 116 ManagingUplinkAdapterswithvicfgnics 116 AddingandModifyingVMkernelNetworkInterfaceswithvicfgvmknic 117 SettingUpvSphereNetworkingwithvNetworkDistributedSwitch 118 ManagingvNetworkDistributedSwitches 119 ManagingStandardNetworkingServicesinthevSphereEnvironment 119 SettingtheDNSConfiguration 119 AddingandStartinganNTPServer 120 ManagingtheIPGateway 120 UsingvicfgipsecforSecureNetworking 121 UsingIPsecwithESX/ESXi 122 ManagingSecurityAssociationswithvicfgipsec 122 ManagingSecurityPolicieswithvicfgipsec 123

VMware, Inc.

Contents

11 MonitoringESX/ESXiHosts 125
UsingresxtopforPerformanceMonitoring 125 ManagingDiagnosticPartitionswithvicfgdumppart 125 ConfiguringSyslogonESXiHosts 126 ManagingESX/ESXiSNMPAgentswithvicfgsnmp 127 ConfiguringSNMPCommunities 127 ConfiguringtheSNMPAgenttoSendTraps 128 ConfiguringtheSNMPAgentforPolling 128 ESX,ESXi,andVirtualMachineLogs 129 EnablingandDisablingCIMProviders 129

12 vSphereCLICommandOverviews 131
ListofAvailableCommands 131 SupportedPlatformsforCommands 133 CommandswithanesxcfgPrefix 135 esxcliCommandOverview 136 Helpforesxcli 137 esxclicorestorageNamespace 137 claimingCommands 137 claimruleCommands 138 deviceCommands 138 plugincommands 139 esxclinetworkNamespace 139 connectionslistCommand 139 neighborsshowCommand 139 esxclinmpNamespace 139 bootrestoreCommand 139 deviceCommands 140 fixedCommands 140 pathCommands 140 pspCommands 140 roundrobinCommands 141 satpCommands 141 esxcliswiscsiNamespace 141 nicCommands 141 sessionCommands 142 vmknicCommands 142 vmnicCommands 142 esxclivaaiNamespace 143 devicelistCommand 143 esxclivmsNamespace 143 vmCommands 143

VMware, Inc.

vSphere Command-Line Interface Installation and Scripting Guide

VMware, Inc.

About This Book

ThevSphereCommandLineInterfaceInstallationandScriptingGuide,explainshowtoinstallandusethe VMwarevSphereCommandLineInterface(vCLI)andincludesexamplescenariosandcommand overviews. ThevSphereCommandLineInterfaceInstallationandScriptingGuidediscussesESX,ESXi,andvCenterServer.

Intended Audience
ThisbookisforexperiencedWindowsorLinuxsystemadministratorswhoarefamiliarwithvSphere administrationtasksanddatacenteroperationsandknowhowtousecommandsinscripts.

VMware Technical Publications Glossary


VMwareTechnicalPublicationsprovidesaglossaryoftermsthatmightbeunfamiliartoyou.Fordefinitions oftermsastheyareusedinVMwaretechnicaldocumentation,gotohttp://www.vmware.com/support/pubs.

Document Feedback
VMwarewelcomesyoursuggestionsforimprovingourdocumentation.Ifyouhavecomments,sendyour feedbacktodocfeedback@vmware.com.

Related Documentation
ThevSphereCommandLineInterfaceReference,whichisthecompaniondocumenttothisguide,isavailableon thevSphereCLIdocumentationpage. ThevSphereSDKforPerldocumentationexplainshowyoucanusethevSphereSDKforPerlandrelated utilityapplicationstomanageyourvSphereenvironment.Thedocumentationincludesinformationaboutthe vSphereSDKforPerlUtilityApplications. ThevSphereManagementAssistantGuideexplainshowtoinstallandusethevSphereManagementAssistant (vMA).vMAisavirtualmachinethatincludesthevCLIandotherprepackagedsoftware.SeeDeploying vMAonpage 17. BackgroundinformationforthetasksdiscussedinthismanualisavailableinthevSpheredocumentationset. ThevSpheredocumentationconsistsofthecombinedVMwarevCenterServerandESX/ESXidocumentation andincludesconfigurationguides,administratorsguides,guidesforstoragesetup,andmore.

Technical Support and Education Resources


Thefollowingsectionsdescribethetechnicalsupportresourcesavailabletoyou.Toaccessthecurrentversion ofthisbookandotherbooks,gotohttp://www.vmware.com/support/pubs.

VMware, Inc.

vSphere Command-Line Interface Installation and Scripting Guide

Online and Telephone Support


Touseonlinesupporttosubmittechnicalsupportrequests,viewyourproductandcontractinformation,and registeryourproducts,gotohttp://www.vmware.com/support. Customerswithappropriatesupportcontractsshouldusetelephonesupportforthefastestresponseon priority1issues.Gotohttp://www.vmware.com/support/phone_support.

Support Offerings
TofindouthowVMwaresupportofferingscanhelpmeetyourbusinessneeds,goto http://www.vmware.com/support/services.

VMware Professional Services


VMwareEducationServicescoursesofferextensivehandsonlabs,casestudyexamples,andcoursematerials designedtobeusedasonthejobreferencetools.Coursesareavailableonsite,intheclassroom,andlive online.Foronsitepilotprograms andimplementationbestpractices,VMwareConsultingServicesprovides offeringsto helpyouassess,plan,build,andmanageyourvirtualenvironment.Toaccessinformationabout educationclasses,certificationprograms,andconsultingservices,gotohttp://www.vmware.com/services.

10

VMware, Inc.

Installing vCLI

YoucaninstallavCLIpackageonaLinuxoraMicrosoftWindowssystem,ordeploythevSphere ManagementAssistant(vMA)onanESX/ESXihost. Thischapterincludesthefollowingtopics:


InstallationOverviewonpage 11 InstallingandUninstallingvCLIonLinuxonpage 11 InstallingandUninstallingvCLIonWindowsonpage 15 DeployingvMAonpage 17

Installation Overview
ThevCLIinstalleralsoinstallsvSphereSDKforPerlbecausevCLIcommandsrunontopofthevSphereSDK forPerl.OnWindows,theinstallationpackageincludesvCLI,vSphereSDKforPerl,andprerequisite software.OnLinux,theinstallationpackageincludesvCLIandvSphereSDKforPerl.Youareresponsiblefor installingrequiredprerequisitesoftware.

vCLIpackages.YoucaninstallavCLIpackageonaphysicalorvirtualmachine.SeeInstallingand UninstallingvCLIonLinuxonpage 11andInstallingandUninstallingvCLIonWindowsonpage 15. Afteryouhaveinstalledthepackage,whichincludesthevSphereSDKforPerl,youcanrunvCLI commandsfromtheoperatingsystemcommandline.Eachtimeyourunacommand,youspecifythe targetserverconnectionoptionsdirectlyorindirectly.SeeSpecifyingAuthenticationInformationon page 20.YoucanalsowritescriptsandmanageyourvSphereenvironmentusingthosescripts.

vMA.YoucandeployvMA,avirtualmachinethatadministratorscanusetorunscriptsthatmanage vSphere,onanESX/ESXihost.vMAincludesvCLIandotherprepackagedsoftwareinaLinux environment. vMAsupportsnoninteractivelogin.IfyouestablishanESX/ESXihostasatargetserver,youcanrunvCLI commandsagainstthatserverwithoutadditionalauthentication.IfyouestablishavCenterServersystem asatargetserver,youcanrunmostvCLIcommandsagainstallESX/ESXisystemsthatservermanages withoutadditionalauthentication.SeeDeployingvMAonpage 17.

Installing and Uninstalling vCLI on Linux


TheinstallationscriptforthevCLIissupportedondefaultinstallationsofthefollowingLinuxdistributions:

RedHatEnterpriseLinux5.2(32bitand64bit) SLES10(32bitand64bit) SLES11(32bitand64bit) Ubuntu9.04(32bitand64bit)

VMware, Inc.

11

vSphere Command-Line Interface Installation and Scripting Guide

IfaversionofvCLIorvSphereSDKforPerlisinstalledonyoursystem,youmustuninstallthatversionbefore youstarttheinstallationprocess. IMPORTANTInstallvCLIonLinuxonlyifyouareanexperiencedLinuxadministratorwhoknowshowtouse thesystemspackagemanager.Otherwise,usevMA.SeeDeployingvMAonpage 17.

Installation Process
ThevCLIpackageinstallerinstallsthevCLIscriptsandthevSphereSDKforPerl.Duringinstallation,the installercheckswhetherprerequisitesareinstalled.Dependingonthetypeofprerequisitethatismissing,the installereitherstopstheinstallationprocessorcontinues,asfollows. 1 Theinstallercheckswhetherthefollowingrequiredprerequisitepackagesareinstalledonthesystem:
OpenSSL ThevCLIrequiresSSLbecausemostconnectionsbetweenthesystemonwhichyourunthecommand andthetargetvSpheresystemareencryptedwithSSL. TheOpenSSLlibrary(libssl-devpackage)isnotincludedinthedefaultLinuxdistribution. Installationinstructionsforeachplatformareincludedbelow. LibXML2 UsedforXMLparsing. Thelibxml2packageisnotincludedinthedefaultLinuxdistribution.Installationinstructionsfor eachplatformareincludedbelow. e2fsprogs Utilitiesformaintainingtheext2,ext3andext4filesystems.RequiredbytheUUIDPerlmodule.

2 3

Ifthesoftwareisfound,theinstallerproceeds.Otherwise,theinstallerstopsandinformsyouthatyou mustinstallthesoftware. TheinstallercheckswhetherthefollowingrecommendedPerlmodulesarefound,andwhetherthe correctversionisinstalled.


CryptSSLeay0.55(0.550.9.7or0.550.9.8) IOCompressBase2.005 CompressZlib2.005 IOCompressZlib2.005 CompressRawZlib2.017 ArchiveZip1.26 DataDumper2.121 XMLLibXML1.63 libwwwperl5.805 XMLLibXMLCommon0.13 XMLNamespaceSupport1.09 XMLSAX0.16 DataDump1.15 URI1.37 UUID0.03 SOAPLite0.710.08 HTMLParser3.60 version0.78

IfarecommendedPerlmoduleisnotfoundatall,theinstallerinstallsit.Ifadifferentversionofthe moduleisfound,theinstallerdoesnotinstallitandproceedswiththeinstallationprocess.Attheendof theinstallationprocess,theinstallerinformsyouiftheversiononthesystemdoesnotmatchthe recommendedversion,andrecommendsthatyouinstalltheversionvCLIwastestedwith.Youcaninstall themodulesusingthepackageinstallerforyourplatform,theinstallationCD,orCPAN.

IMPORTANTTheinstallerdoesnotoverwriteexistingversionsofrecommendedPerlmodules.Youmust explicitlyupdatethosemodulesyourself.

12

VMware, Inc.

Chapter 1 Installing vCLI

IfyouhaveuninstalledapreviousversionofthevCLIorRemoteCLI,andinstallvCLIinadifferentdirectory, youmustresetthePATHenvironmentvariable.Youcandosobeforeoraftertheinstallation,usingthe commandappropriateforyourdistributionandshell(setenv,export,andsoon).Ifyoudonotresetthe PATH,thesystemmightstillgototheoldlocationtofindvCLIcommands.

Installing Prerequisite Software for Red Hat Enterprise Linux 5.2


vCLIissupportedonRedHatEnterpriseLinux5.2,32bitand64bit. PrerequisitesoftwareonRHELincludesrequiredsoftwareandrecommendedPerlmodules.

Required Software
Ifrequiredsoftwareisnotinstalled,thevCLIinstallerstops.Youcaninstallprerequisitesusingyum,theRHEL packageinstaller(recommended),orfromtheinstallationDVD. Forexample,ifbothOpenSSLdevelopmentlibrariesandLibXML2aremissing,typethefollowingata commandprompt:
yum install openssl-devel libxml2-dev

Recommended Perl Modules


Whentheinstallerfinishes,itmightissueawarningthattheversionofamoduleinstalledonyoursystemdoes notmatchtheversionwithwhichvCLIwastested.InstallthatversionusingyumorCPANtoresolvetheissue. SeeInstallationProcessonpage 12foracompletelistofmodules. Afterinstallingprerequisitesoftware,youcaninstallthevCLIitself.SeeInstallingthevCLIPackageon page 14.

Installing Prerequisite Software for SLES 10 and SLES 11


vCLIissupportedonSLES10,32bitand64bitandonSLES11,32bitand64bit. PrerequisitesoftwareonSLESincludesrequiredsoftwareandrecommendedPerlmodules.

Required Software
Ifrequiredsoftwareisnotinstalled,thevCLIinstallerstops.Youcaninstalltheprerequisitepackagesfromthe SLES10orSLES11SDKDVD.WhenyouinserttheDVD,itofferstoautorun.Canceltheautorundialogbox anduserpmortheyastpackageinstallertoinstallOpenSSLorothermissingrequiredpackages. Forexample,ifOpenSSLdevelopmentlibrariesaremissing,typethefollowingatacommandprompt:
yast -i openssl-devel

SomeusersmightbeauthorizedtousetheNovellCustomerCenteranduseyasttoretrievemissingpackages fromthere.

Recommended Perl Modules


Whentheinstallerfinishes,itmightissueawarningthattheversionofamoduleinstalledonyoursystemdoes notmatchtheversionwithwhichvCLIwastested.InstallthatversionusingyastorCPANtoresolvethe issue.SeeInstallationProcessonpage 12foracompletelistofmodules. Afterinstallingprerequisitesoftware,youcaninstallthevCLIitself.SeeInstallingthevCLIPackageon page 14.

Installing Prerequisite Software for Ubuntu Desktop 9.04


vCLIissupportedonUbuntu9.0432bitand64bit. PrerequisitesoftwareincludesrequiredsoftwareandrecommendedPerlmodules.

VMware, Inc.

13

vSphere Command-Line Interface Installation and Scripting Guide

Required Software
Ifrequiredsoftwareisnotinstalled,thevCLIinstallerstops.OnUbuntuyoucanuseapt(advancedpackaging tool)tokeepalocalrepositoryoflibrariesuptodate.Youcanuseapttoinstalltherequiredsoftware. To install required software on Ubuntu Desktop 9.04 1 2 ConnecttotheInternet. Updatethelocalrepositoryoflibrariesfromaterminalwindow.
sudo apt-get update

Installtherequiredlibrariesfromaterminalwindow.ForUbuntuDesktop9.0464bit,youmustinstall the32bitcompatibilitylibrariesortheresxtopandesxclicommandsdonotwork. 32bit 64bit sudo apt-get install libssl-dev perl-doc liburi-perl libxml-libxml-perl libcrypt-ssleay-perl sudo apt-get install libssl-dev perl-doc liburi-perl libxml-libxml-perl libcrypt-ssleay-perl ia32-libs

Recommended Perl Modules


Whentheinstallerfinishes,itmightissueawarningthattheversionofamoduleinstalledonyoursystemdoes notmatchtheversionwithwhichvCLIwastested.Installthatversionusingapt-getorCPANtoresolvethe issue.SeeInstallationProcessonpage 12foracompletelistofmodules. Afterinstallingprerequisitesoftware,youcaninstallthevCLIitself.SeeInstallingthevCLIPackageon page 14.

Installing the vCLI Package


Beforeyouinstallversion4.1ofthevCLI,youmustremoveallpreviousversionsofthatsoftware.Theprocess differsfromsimplyuninstallingvCLI. To remove previous versions of vCLI 1 Runtheuninstallscript,forexample,ifyouinstalledvCLIinthedefaultlocation,runthefollowing command:
/usr/bin/vmware-uninstall-vSphere-CLI.pl

DeleteexistingversionsofvSphere-CLI.xxxx.tar.gzanddeletethevmware-vsphere-cli-distrib directory.

To install vCLI on Linux 1 UntarthevCLIbinarythatyoudownloaded.


tar zxvf VMware-vSphere-CLI-4.X.X-XXXXX.i386.tar.gz

Avmware-vsphere-vcli-distribdirectoryiscreated. 2 Loginassuperuserandruntheinstaller:
/<location>/sudo vmware-vsphere-cli-distrib/vmware-install.pl

3 4

Toacceptthelicenseterms,typeyesandpressEnter. Specifyaninstallationdirectory,orpressEntertoacceptthedefault,whichis/usr/bin. Acompleteinstallationprocesshasthefollowingresult:


Asuccessmessageappears. Theinstallerlistsdifferentversionnumbersforrequiredmodules(ifany). Thepromptreturnstotheshellprompt.

14

VMware, Inc.

Chapter 1 Installing vCLI

Ifyouacceptedthedefaultsduringinstallation,youcanfindtheinstalledsoftwareinthefollowinglocations:

vCLIscripts/usr/bin vSphereSDKforPerlutilityapplications/usr/lib/vmware-vcli/apps vSphereSDKforPerlsamplescripts/usr/share/doc/vmware-vcli/samples

SeethevSphereSDKforPerldocumentationforareferencetoallutilityapplications. AfteryouinstallthevCLI,youcantesttheinstallationbyrunningacommandfromtheWindowscommand prompt. To run a vCLI command on Linux 1 2 3 Openacommandprompt. ChangetothedirectorywhereyouinstalledthevCLI(defaultis/usr/bin). Runthecommand,includingtheconnectionoptions.
<command> <conn_options> <params>

Specifyconnectionoptionsinaconfigurationfileorpassthemonthecommandline.Theextension.pl isnotrequiredonLinux. Forexample:


vicfg-nas --server my_esxserver --list

Thesystempromptsyouforausernameandpassword. SeeTable 22,vCLIConnectionOptions,onpage 23foracompletelistofconnectionoptions.

Uninstalling the vCLI Package on Linux


YoucanuseascriptincludedintheinstallationtouninstallthevCLIpackage. To uninstall the vCLI on Linux 1 2 ChangetothedirectorywhereyouinstalledthevCLI(defaultis/usr/bin). Runthevmware-uninstall-vSphere-CLI.pl script. ThecommanduninstallsthevCLIandthevSphereSDKforPerl.

Installing and Uninstalling vCLI on Windows


BeforeyoucanrunvCLIcommandsonyourWindowsystem,youhavetoinstallthevCLIpackageandtest theinstallationbyrunningacommand. ThevCLIinstallationpackageforWindowsincludestheActivePerlruntimefromActiveStateSoftwareand requiredPerlmodulesandlibraries.ThevCLIissupportedonthefollowingWindowsplatforms:

Windows200332bit WindowsXPSP332bit WindowsVistaEnterpriseSP132bit Windows200864bit

VMware, Inc.

15

vSphere Command-Line Interface Installation and Scripting Guide

To install the vCLI Package on Windows 1 DownloadthevCLIWindowsinstallerpackage. YoucanfindtheinstallerontheVMwareCommunitiespage. 2 3 Starttheinstaller. (Optional)IfpromptedtoremoveolderversionsofvSphereSDKforPerlorvCLI,youcaneitheraccept orinstallthevCLIpackageonadifferentsystem. IMPORTANTTheinstallerreplacesboththevSphereSDKforPerlandthevCLI.Tokeepanolderversion, installthispackageonadifferentsystem. 4 5 ClickNextintheWelcomepage. ToinstallthevCLIinanondefaultdirectory,clickChangeandselectthedirectory. ThedefaultlocationisC:\Program Files\VMware\VMware vCLI. 6 7 ClickNext. ClickInstalltoproceedwiththeinstallation. Theinstallationmighttakeseveralminutestocomplete. 8 Rebootyoursystem. Withoutreboot,pathsettingsmightnotbecorrectonyourWindowsplatform. AfteryouinstallthevCLIandrebootyoursystem,youcantesttheinstallationbyrunningacommandfrom theWindowscommandprompt. To run a vCLI command on Windows 1 2 Openacommandprompt. NavigatetothedirectoryinwhichthevCLIisinstalled.
cd C:\Program Files\VMware\VMware vSphere CLI\bin

Runthecommand,passinginconnectionoptionsandotheroptions. OnWindows,theextension.plisrequiredformostcommands,butnotforesxcli.
<command>.pl <conn_options> <params>

Forexample:
vicfg-nas.pl --server my_esxhost --list

Thesystempromptsyouforausernameandpassword. SeeTable 22,vCLIConnectionOptions,onpage 23foracompletelistofconnectionoptions. YoucanuninstallthevCLIpackageasyouwouldotherprograms. To uninstall the vCLI on Windows 1 2 3 FindtheoptionforaddingandremovingprogramsontheWindowsoperatingsystemyouareusing. Inthepanelthatappears,selectvSphereCLI,andclickRemove. ClickYeswhenprompted.

ThesystemuninstallsthevSphereSDKforPerl,thevCLI,andallprerequisitesoftware.

16

VMware, Inc.

Chapter 1 Installing vCLI

Deploying vMA
Asanalternativetoapackageinstallation,youcandeployvMAonanESX/ESXihostandrunvCLIcommands fromthere.vMAisavirtualmachineyoucanusetorunscriptstomanageESX/ESXisystems.vMAincludes aLinuxenvironment,vCLI,andotherprepackagedsoftware. SettingupvMAconsistsofafewtasks.ThevSphereManagementAssistantGuidediscusseseachtaskindetail. 1 DeployvMAtoanESX/ESXisystemthatmeetsthehardwareprerequisites. SeethevSphereManagementAssistantGuideforprerequisitesanddeploymentdetails. 2 ConfigurevMA. WhenyoubootvMA,youmustspecifythefollowingrequiredconfigurationinformationwhen prompted:

Networkinformation(thedefaultisoftenacceptable) HostnameforvMA. Passwordfortheviadminuser.TheviadminuserhassuperuserprivilegesonvMA.Youcannotlog intovMAastherootuser.

(Optional)AddavCenterServersystemoroneormoreESX/ESXisystemsastargets.Youcanusethe VMwarevifastpassmechanismorActiveDirectoryauthentication,asexplainedinthevSphere ManagementAssistantGuide.

AfteryouhavespecifiedahostasavMAtarget,youcanrunvCLIcommandsagainstanyESX/ESXitarget systemwithoutspecifyingconnectionoptionsforthatsystemexplicitly.IfyousetupavCenterServersystem asatargetserver,youcanconnectanyESX/ESXihoststhatvCenterServersystemmanagesusingthe --vihostoption.

VMware, Inc.

17

vSphere Command-Line Interface Installation and Scripting Guide

18

VMware, Inc.

Running vCLI Commands

YoucanrunvCLIcommandsfromthecommandlineandfromscripts.Eachcommandrequiresataminimum thetargetservertorunthecommandon.Usersauthorizedtoruncommandsonthetargetserverdonothave tospecifyauthenticationinformation.Otherusersmustspecifyauthenticationinformation. Thischapterincludesthefollowingtopics:


OverviewofRunningCommandsonpage 19 SpecifyingAuthenticationInformationonpage 20 CommonOptionsforvCLIExecutiononpage 23 UsingvSphereCLICommandsinScriptsonpage 25

IMPORTANTIfanESXisystemyoutargetisinlockdownmode,youcannotrunvCLIcommandsagainstthat systemdirectly.YoumusttargetavCenterServersystemthatmanagestheESXisystemandusethe--vihost optiontospecifytheESXitarget.SeevCLIandLockdownModeonpage 23.

Overview of Running Commands


YoucanrunvCLIcommandsinteractivelyorinscriptsinseveralways.

OpenacommandpromptonaLinuxorWindowssystemonwhichyouinstalledthevCLI.Enter commandsintothatcommandprompt. AccessthevMALinuxconsole.SetuptargetserversandrunvCLIcommandsagainstthetargetswithout additionalauthentication. PreparescriptsthatcontainvCLIcommands.Thenrunthescriptsfromaremoteadministrationserver thathasthevCLIpackageinstalledorfromthevMALinuxconsole.SeeUsingvSphereCLICommands inScriptsonpage 25.

WhenyouruncommandsagainstanESX/ESXihost,youmustbeauthenticatedforthathost.Whenyourun commandsagainstavCenterServersystem,andyouareauthenticatedforthatsystem,youcantargetall ESX/ESXihoststhatvCenterServermanageswithoutadditionalauthentication.SeeSpecifying AuthenticationInformationonpage 20. CAUTIONIfyouspecifypasswordsinplaintext,youriskexposingthepasswordtootherusers.Thepassword mightalsobecomeexposedinbackupfiles.Donotprovideplaintextpasswordsonproductionsystems.

VMware, Inc.

19

vSphere Command-Line Interface Installation and Scripting Guide

Followoneofthefollowingapproachesforprotectingpasswords.

IfyouuseavCLIcommandinteractivelyanddonotspecifyausernameandpassword,youareprompted forthem.Thescreendoesnotechothepasswordyoutype. Fornoninteractiveuse,youcancreateasessionfileusingthesave_sessionscriptincludedinthe apps/sessiondirectory.SeeUsingaSessionFileonpage 20. IfyouarerunningonaWindowssystem,youcanusethe--passthroughauthoption.Iftheuserwho runsthecommandwiththatoptionisknown,nopasswordisrequired.

IfyouarerunningvMA,youcansetuptargetserversandrunmostvCLIcommandsagainsttargetservers withoutadditionalauthentication.SeethevSphereManagementAssistantGuide.

Specifying Authentication Information


vCLIallowsyoutorunagainstmultipletargetserversfromthesameadministrationserver.Youmusthave thecorrectprivilegestoperformtheactionsoneachtarget. IMPORTANTvCLI4.1andlaterallowsadministratorstoplaceESXihostsinlockdownmodeforenhanced security.OnlyavCLIoravSphereClientconnectedtoavCenterServersystemcanmakechangestoESXihosts inlockdownmode.Nousers,noteventherootuser,canrunvCLIcommandsagainstESXihostsinlockdown mode.SeevCLIandLockdownModeonpage 23andtheDatacenterAdministrationGuide.

Order of Precedence for vCLI Authentication


WhenyourunavCLIcommand,authenticationhappensintheorderofprecedenceshowninTable 21.This orderofprecedencealwaysapplies.Thatmeans,forexample,thatyoucannotoverrideanenvironment variablesettinginaconfigurationfile. Table 2-1. vCLI Authentication Precedence
Authentication Commandline Description Password(--password),sessionfile (--sessionfile),orconfigurationfile (--config)specifiedonthecommandline. Passwordspecifiedinanenvironmentvariable. Passwordspecifiedinaconfigurationfile. Currentaccountinformationusedtoestablish anSSPIconnection.AvailableonlyonWindows. Passwordretrievedfromthecredentialstore. Passwordisnotechoedtoscreen. See UsingaSessionFileonpage 20

Environment variable Configurationfile Currentaccount (ActiveDirectory) Credentialstore Prompttheuserfor apassword.

UsingEnvironmentVariablesonpage 21 UsingaConfigurationFileonpage 21 UsingMicrosoftWindowsSecuritySupport ProviderInterfaceonpage 22 vSphereWebServicesSDKProgrammingGuide andvSphereSDKforPerlProgrammingGuide.

Using a Session File


Youcancreateasessionfilewiththesave_sessionscript.Thescriptisinthe/apps/sessiondirectoryof thevSphereSDKforPerl,whichisincludedinthevCLIpackage.Youcanusethesessionfile,whichdoesnot revealpasswordinformation,whenyourunvCLIcommands.Ifthesessionfileisnotusedfor30 minutes,it expires. Ifyouuseasessionfile,otherconnectionoptionsareignored.

20

VMware, Inc.

Chapter 2 Running vCLI Commands

To create and use a session file 1 Connecttothedirectorywherethescriptislocated. Forexample: Windows: Linux: 2


cd C:\Program Files\VMware\VMware vSphere CLI\Perl\apps\session cd /usr/share/doc/vmware-vcli/apps/session

Runsave_session. Youmustspecifytheservertoconnecttoandthenameofasessionfileinwhichthescriptsavesan authenticationcookie.


save_session --savesessionfile <location> --server <server>

Forexample: Windows: Linux:


save_session.pl --savesessionfile C:\Temp\my_session --server my_server --username <username> --password <password> save_session --savesessionfile /tmp/vimsession --server <servername_or_address> --username <username> --password <password>

Ifyouspecifyaserver,butnousernameorpassword,thescriptpromptsyou. 3 WhenyourunvCLIcommands,passinthesessionfileusingthe--sessionfileoption.
<command> --sessionfile <sessionfile_location> <command_options>

Forexample: Windows: Linux:


vicfg-mpath.pl --sessionfile C:\Temp\my_session --list vicfg-mpath --sessionfile /tmp/vimsession --list

Using Environment Variables


OnLinux,youcansetenvironmentvariablesinaLinuxbashprofileoronthecommandlinebyusinga commandlikethefollowing:
export VI_SERVER=<your_server_name_or_address>

OnWindows,youcansetenvironmentvariablesintheEnvironmentpropertiesdialogboxoftheSystem controlpanel.Forthecurrentsession,youcansetenvironmentvariablesatthecommandlinebyusinga commandlikethefollowing:


set VI_SERVER=<your_server_name_or_address>

IMPORTANTDonotuseescapecharactersinenvironmentvariables. SeeUsingvSphereCLICommandsinScriptsonpage 25foranenvironmentvariableexample.

Using a Configuration File


Youcanuseatextfilethatcontainsvariablenamesandsettingsasaconfigurationfile.Variablescorresponding totheoptionsareshowninTable 22,vCLIConnectionOptions,onpage 23. CAUTIONLimitreadaccesstoaconfigurationfilethatcontainsusercredentials.

PassintheconfigurationfilewhenyourunvCLIcommands,asfollows:
<command> --config <my_saved_config> <option>

VMware, Inc.

21

vSphere Command-Line Interface Installation and Scripting Guide

Forexample:
vicfg-mpath --config <my_saved_config> --list

IfyouhavemultiplevCenterServerorESX/ESXisystemsandyouadministereachsystemindividually,you cancreatemultipleconfigurationfileswithdifferentnames.Torunacommandorasetofcommandsona server,youpassinthe--configoptionwiththeappropriatefilenameatthecommandline. Thefollowingexampleillustratesthecontentsofaconfigurationfile:


VI_SERVER = XX.XXX.XXX.XX VI_USERNAME = root VI_PASSWORD = my_password VI_PROTOCOL = https VI_PORTNUMBER = 443

Ifyouhavesetupyoursystemtorunthisfile,youcanrunscriptsonthespecifiedserverafterwards.

Using Command-Line Options


Youcanpassincommandlineoptionsusingoptionnameandoptionvaluepairsinmostcases.Thefollowing syntaxresults:
<command> --server <vc_server> --username <privileged_user> --password <pw> --vihost <esx_host> --<option_name option_value>

Someoptions,suchas--help,havenovalue. IMPORTANTEnclosepasswordsandothertextwithspecialcharactersinquotationmarks. OnLinux,usesinglequotes( ),onWindows,usedoublequotes( ).OnLinux,youcanalsouseabackslash (\)asanescapecharacter. Thefollowingexamplesconnecttotheserverasusersnow-whitewithpassworddwarf$.Thesystem displayshelpinformationforthecommandbecausethecommandiscalledwithnooptions. Thefirstexample(Linux)usesthebackslash(\)escapecharacter,theothertwousesinglequotes(Linux)and doublequotes(Windows). Linux
vicfg-mpath --server <server> --username snow\-white --password dwarf\$ vicfg-mpath --server <server> --username snow-white --password dwarf$

Windows
vicfg-mpath.pl --server <server> --username snow-white --password dwarf$

Using Microsoft Windows Security Support Provider Interface


The--passthroughauthoption,whichisavailableifyourunvCLIcommandsfromaMicrosoftWindows system,allowsyoutousetheMicrosoftWindowsSecuritySupportProviderInterface(SSPI).SeetheMicrosoft WebsiteforadetaileddiscussionofSSPI. Youcanuse--passthroughauthtoestablishaconnectionwithavCenterServersystem(vCenterServer systemorVirtualCenterServer3.5Update2orlater).Aftertheconnectionhasbeenestablished,authentication forthevCenterServersystemoranyESX/ESXisystemitmanagesisnolongerrequired.Using --passthroughauthpassesthecredentialsoftheuserwhorunsthecommandtothetargetvCenterServer system.Noadditionalauthenticationisrequirediftheuserwhorunsthecommandisknownbythecomputer fromwhichyouaccessthevCenterServersystemandbythecomputerrunningthevCenterServersoftware. IfvCLIcommandsandthevCenterServersoftwarerunonthesamecomputer,theuserneedsonlyalocal accounttorunthecommand.IfthevCLIcommandandthevCenterServersoftwarerunondifferent machines,theuserwhorunsthecommandmusthaveanaccountinadomaintrustedbybothmachines.

22

VMware, Inc.

Chapter 2 Running vCLI Commands

SSPIsupportsseveralprotocols.Bydefault,itselectstheNegotiateprotocol,whereclientandservertryto findaprotocolthatbothsupport.Youcanuse--passthroughauthpackagetoexplicitlyspecifyaprotocol supportedbySSPI.Kerberos,theWindowsstandardfordomainlevelauthentication,isusedfrequently.Ifthe vCenterServersystemisconfiguredtoacceptonlyaspecificprotocol,specifyingtheprotocolwith --passthroughauthpackagemightberequiredforsuccessfulauthentication.Ifyouuse --passthroughauth,youdonothavetospecifyauthenticationinformationbyusingotheroptions. Example


vicfg-mpath.pl --server <vc_server> --passthroughauth --passthroughauthpackage Kerberos --vihost my_esx --list

ConnectstoaserverthathasbeensetuptouseSSPI.Whenatrusteduserrunsthecommand,thesystemcalls vicfg-mpathwiththe--listoption.Thesystemdoesnotpromptforausernameandpassword.

vCLI and Lockdown Mode


LockdownmodedisablesalldirectrootaccesstoESXimachines.YoucanonlymakechangestoESXisystems inlockdownmodebygoingthroughavCenterServersystemthatmanagestheESXisystem.Youcanusethe vSphereClientorvCLIcommandsthatsupportthe--vihostoption.Thefollowingcommandscannotrun againstvCenterServersystemsandarethereforenotavailableinlockdownmode:

vicfg-snmp vifs vicfg-user vicfg-cfgbackup vihostupdate vmkfstools esxcli vicfg-ipsec

IfyouhaveproblemsrunningacommandonanESXihostdirectly(withoutspecifyingavCenterServer target),checkwhetherlockdownmodeisenabledonthathost.TheESXiConfigurationGuidediscusses lockdownmodeindetail.

Common Options for vCLI Execution


Table 22listsoptionsthatareavailableforallvCLIcommandsinalphabeticalorder.Thetableincludes optionsforuseonthecommandlineandvariablesforuseinconfigurationfiles. IMPORTANTForconnections,vCLIsupportsonlytheIPv4protocol,nottheIPv6protocol.Youcan,however, configureIPv6onthetargethostwithseveralofthenetworkingcommands. SeeTorunavCLIcommandonLinuxonpage 15andTorunavCLIcommandonWindowsonpage 16 forusageexamples. Table 2-2. vCLI Connection Options
Option and Environment Variable --config <cfg_file_full_path> VI_CONFIG=<cfg_file_full_path> --credstore <credstore> Description Usestheconfigurationfileatthespecifiedlocation. Specifyapaththatisreadablefromthecurrentdirectory. Nameofacredentialstorefile.Defaultsto <HOME>/.vmware/credstore/vicredentials.xmlonLinuxand <APPDATA>/VMware/credstore/vicredentials.xmlonWindows. CommandsforsettingupthecredentialstoreareincludedinthevSphere SDKforPerl,whichisinstalledwithvCLI.ThevSphereSDKforPerl ProgrammingGuideexplainshowtomanagethecredentialstore.

VMware, Inc.

23

vSphere Command-Line Interface Installation and Scripting Guide

Table 2-2. vCLI Connection Options (Continued)


Option and Environment Variable --encoding <encoding> VI_ENCODING=<encoding> Description Specifiestheencodingtobeused.Oneofcp936(SimplifiedChinese) ISO-8859-1(German),orShift_JIS(Japanese). Youcanuse--encodingtospecifytheencodingvCLIshouldmaptowhenit isrunonaforeignlanguagesystem. --passthroughauth VI_PASSTHROUGHAUTH Ifyouspecifythisoption,thesystemusestheMicrosoftWindowsSecurity SupportProviderInterface(SSPI)forauthentication.Trustedusersarenot promptedforausernameandpassword.SeetheMicrosoftWebsitefora detaileddiscussionofSSPI. ThisoptionissupportedonlyifyouarerunningvCLIonaWindowssystem andareconnectingtoavCenterServersystem. --passthroughauthpackage <package> VI_PASSTHROUGHAUTHPACKAGE= <package> Usethisoptionwith--passthroughauthtospecifyadomainlevel authenticationprotocoltobeusedbyWindows.Bydefault,SSPIusesthe Negotiateprotocol,whichmeansthatclientandservertrytonegotiatea protocolthatbothsupport. IfthevCenterServersystemtowhichyouareconnectingisconfiguredtouse aspecificprotocol,youcanspecifythatprotocolusingthisoption. ThisoptionissupportedonlyifyouarerunningvCLIonaWindowssystem andconnectingtoavCenterServersystem. --password <passwd> VI_PASSWORD=<passwd> Usesthespecifiedpassword(usedwith--username)tologintotheserver.

If--serverspecifiesavCenterServersystem,theusernameand passwordapplytothatserver.IfyoucanlogintothevCenterServer system,youneednoadditionalauthenticationtoruncommandsonthe ESX/ESXihoststhatservermanages. If--serverspecifiesanESX/ESXihost,theusernameandpasswordapply tothatserver.

Usetheemptystring(' 'onLinuxand onWindows)toindicateno password. Ifyoudonotspecifyausernameandpasswordonthecommandline,the systempromptsyouanddoesnotechoyourinputtothescreen. --portnumber <number> VI_PORTNUMBER=<number> --protocol <HTTP|HTTPS> VI_PROTOCOL=<HTTP|HTTPS> --savesessionfile <file> VI_SAVESESSIONFILE=<file> --server <server> VI_SERVER=<server> Usesthespecifiedporttoconnecttothesystemspecifiedby--server. Defaultis443. Usesthespecifiedprotocoltoconnecttothesystemspecifiedby--server. DefaultisHTTPS. Savesasessiontothespecifiedfile.Thesessionexpiresifithasbeenunused for30minutes. UsesthespecifiedESX/ESXiorvCenterServersystem.Defaultislocalhost. If--serverpointstoavCenterServersystem,youusethe--vihostoption tospecifytheESX/ESXihostonwhichyouwanttorunthecommand.A commandissupportedforvCenterServerifthe--vihostoptionisdefined. UsesthespecifiedservicepathtoconnecttotheESX/ESXihost.Defaultis /sdk/webService. Usesthespecifiedsessionfiletoloadapreviouslysavedsession.Thesession mustbeunexpired. ConnectstothespecifiedvSphereWebServicesSDKURL.

--servicepath <path> VI_SERVICEPATH=<path> --sessionfile <file> VI_SESSIONFILE=<file> --url <url> VI_URL=<url>

24

VMware, Inc.

Chapter 2 Running vCLI Commands

Table 2-2. vCLI Connection Options (Continued)


Option and Environment Variable --username <u_name> VI_USERNAME=<u_name> Description Usesthespecifiedusername.

If--serverspecifiesavCenterServersystem,theusernameand passwordapplytothatserver.IfyoucanlogintothevCenterServer system,youneednoadditionalauthenticationtoruncommandsonthe ESX/ESXihoststhatservermanages. If--serverspecifiesanESX/ESXisystem,theusernameandpassword applytothatsystem.

Ifyoudonotspecifyausernameandpasswordonthecommandline,the systempromptsyouanddoesnotechoyourinputtothescreen. --vihost <host> -h <host WhenyourunavSphereCLIcommandwiththe--serveroptionpointing toavCenterServersystem,use--vihosttospecifytheESX/ESXihosttorun thecommandagainst. NOTE:Thisoptionisnotsupportedforeachcommand.Ifsupported,the optionisincludedintheindividualcommandoptionlist.

Table 23listsoptionsnotusedasconnectionoptionsthatyoucanusewhenyourunavSphereCLIcommand. Table 2-3. vSphere CLI Common Options


Option --help --verbose --version Description Printsabriefusagemessage.Themessagelistsfirsteachcommandspecificoptionandthen eachofthecommonoptions. Displaysadditionaldebugginginformation. Displaysversioninformation.

Using vSphere CLI Commands in Scripts


Mostadministratorsrunscriptstoperformthesametaskrepeatedlyortoperformataskonmultiplehosts. YoucanrunvSphereCLIcommandsfromoneadministrationserveragainstmultipletargetservers. Forexample,whenanewdatastorebecomesavailableinyourenvironment,youmustmakethatdatastore availabletoeachESX/ESXihost.ThefollowingsamplescriptillustrateshowtomakeaNASdatastoreavailable tothreehosts(esxi_server_a,esx_server_b,andesxi_server_c). Thesampleassumesthataconfigurationfile/home/admin/.visdkrc.<hostname>existsforeachhost.For example,theconfigurationfileforesxi_server_ahasthefollowingcontents:
VI_SERVER = esxi_server_a VI_USERNAME = root VI_PASSWORD = xysfdjkat

ThescriptitselfaddstheNASdatastorebycallingthedifferentconfigurationfiles.
#!bin/sh for i in {"esxi_server_a","esx_server_b","esxi_server_c"} do echo "Adding NAS datastore for $i..." vicfg-nas --config /home/admin/.visdkrc.$i -a -o mainnas.x.com -s /shared nas_ds vicfg-nas --config /home/admin/.visdkrc.$i -l done

VMware, Inc.

25

vSphere Command-Line Interface Installation and Scripting Guide

26

VMware, Inc.

Managing Hosts

HostmanagementcommandscanstopandrebootESX/ESXihosts,backupconfigurationinformation,and managehostupdates.YoucanalsouseahostmanagementcommandtomakeyourhostjoinanActive Directorydomainorexitfromadomain. Thechapterincludesthefollowingtopics:


Stopping,RebootingandExaminingHostswithvicfghostopsonpage 27 EnteringandExitingMaintenanceModewithvicfghostopsonpage 28 BackingUpConfigurationInformationwithvicfgcfgbackuponpage 28 ManagingHostUpdateswithvihostupdateonpage 29 ManagingVMkernelModuleswithvicfgmoduleonpage 32 UsingvicfgauthconfigforActiveDirectoryConfigurationonpage 32

Stopping, Rebooting and Examining Hosts with vicfg-hostops


YoucanshutdownorrebootanESX/ESXihostusingthevSphereClientorthevicfg-hostopsvCLI command.ShuttingdownamanagedhostdisconnectsitfromthevCenterServersystem,butdoesnotremove thehostfromtheinventory. Youcanshutdownasinglehostorallhostsinadatacenterorcluster.

SinglehostRunvicfg-hostopswith--operationshutdown.

Ifthehostisinmaintenancemode,runthecommandwithoutthe--forceoption.
vicfg-hostops <conn_options> --operation shutdown

Ifthehostisnotinmaintenancemode,use--forcetoshutdownthehostandallrunningvirtual machines.
vicfg-hostops <conn_options> --operation shutdown --force

MultiplehostsToshutdownallhostsinaclusterordatacenter,specify--clusteror--datacenter.
vicfg-hostops <conn_options> --operation shutdown --cluster <my_cluster> vicfg-hostops <conn_options> --operation shutdown --datacenter <my_datacenter>

Youcanrebootasinglehostorallhostsinadatacenterorcluster.

SinglehostRunvicfg-hostopswith--operationreboot.

Ifthehostisinmaintenancemode,runthecommandwithoutthe--forceoption.
vicfg-hostops <conn_options> --operation reboot

Ifthehostisnotinmaintenancemode,use--forcetoshutdownthehostandallrunningvirtual machines.
vicfg-hostops <conn_options> --operation reboot --force

VMware, Inc.

27

vSphere Command-Line Interface Installation and Scripting Guide

MultiplehostsYoucanspecify--clusteror--datacentertorebootallhostsinaclusteror datacenter.
vicfg-hostops <conn_options> --operation reboot --cluster <my_cluster> vicfg-hostops <conn_options> --operation reboot --datacenter <my_datacenter>

Youcandisplayinformationaboutahostbyrunningvicfg-hostopswith--operationinformation.
vicfg-hostops <conn_options> --operation info

Thecommandreturnsthehostname,manufacturer,model,processortype,CPUcores,memorycapacity,and boottime.ThecommandalsoreturnswhetherVMotionisenabledandwhetherthehostisinmaintenance mode.

Entering and Exiting Maintenance Mode with vicfg-hostops


Youplaceahostinmaintenancemodetoserviceit,forexample,toinstallmorememory.Ahostentersor leavesmaintenancemodeonlyastheresultofauserrequest. IfVMwareDRSisinuse,virtualmachinesthatarerunningonahostthatentersmaintenancemodeare migratedtoanotherhostautomatically.IfVMwareDRSisnotinuse,vicfg-hostopssuspendsvirtual machines.ThehostisinastateofEnteringMaintenanceModeuntilallrunningvirtualmachinesare suspendedormigrated.Whenahostisenteringmaintenancemode,youcannotpoweronvirtualmachines onitormigratevirtualmachinestoit. Afterallvirtualmachinesonthehosthavebeensuspendedormigrated,thehostentersmaintenancemode. Youcannotdeployorpoweronavirtualmachineonhostsinmaintenancemode. To enter maintenance mode 1 2 Runvicfg-hostops --operation entertoentermaintenancemode. Runvicfg-hostops --operation infotocheckwhetherthehostisinmaintenancemodeorinthe EnteringMaintenanceModestate.

Youcanputallhostsinaclusterordatacenterinmaintenancemodebyusingthe--clusteror--datacenter option.Donotusethoseoptionsunlesssuspendingallvirtualmachinesinthatclusterordatacenterisno problem. Youcanlaterrunvicfg-hostops --operation exittoexitmaintenancemode.

Backing Up Configuration Information with vicfg-cfgbackup


AfteryouconfigureanESXihost,youcanbackupthehostconfigurationdata.Alwaysbackupyourhost configurationafteryouchangetheconfigurationorupgradetheESXiimage. IMPORTANTThevicfg-cfgbackupcommandisavailableonlyforESXihosts.Thecommandisnotavailable forESXhostsandisnotavailablethroughavCenterServersystemconnection.

Backup Tasks
Duringaconfigurationbackup,theserialnumberisbackedupwiththeconfiguration.Thenumberisrestored whenyourestoretheconfiguration.ThenumberisnotpreservedwhenyouruntheRecoveryCD(ESXi Embedded)orperformarepairoperation(ESXiInstallable). Thefollowingtasksarerequired(SeetheESXiInstallableandvCenterServerSetupGuide): 1 2 3 Backuptheconfigurationbyusingthevicfg-cfgbackupcommand. RuntheRecoveryCDorrepairoperation Restoretheconfigurationbyusingthevicfg-cfgbackupcommand.

Whenyourestoreaconfiguration,youmustmakesurethatallvirtualmachinesonthehostarestopped.

28

VMware, Inc.

Chapter 3 Managing Hosts

Backing Up Configuration Data


Youcanbackupconfigurationdatabyrunningvicfg-backupwiththe-soption.
vicfg-cfgbackup <conn_options> -s /tmp/ESX_181842_backup.txt

Forthebackupfilename,includethenumberofthebuildthatisrunningonthehostthatyouarebackingup. IfyouarerunningvCLIonvMA,thebackupfileissavedlocallyonvMA.Backupfilescansafelybestored locallybecausevirtualappliancesarestoredinthe/vmfs/volumes/<datastore>directoryonthehost, whichisseparatefromtheESXiimageandconfigurationfiles.

Restoring Configuration Data


Ifyouhavecreatedabackup,youcanlaterrestoreESXiconfigurationdata.Whenyourestoreconfiguration data,thenumberofthebuildrunningonthehostmustbethesameasthenumberofthebuildthatwas runningwhenyoucreatedthebackupfile.Tooverridethisrequirement,includethe-f (force)option. To restore ESXi configuration data 1 2 3 Poweroffallvirtualmachinesthatarerunningonthehostthatyouwanttorestore. LogintoahostonwhichvCLIisinstalled,orlogintovMA. Runvicfg-cfgbackupwiththe-lflagtoloadthehostconfigurationfromthespecifiedbackupfile.

Ifyourunthefollowingcommand,youarepromptedforconfirmation.
vicfg-cfgbackup <conn_options> -l /tmp/ESX_181842_backup.txt

Ifyourunthefollowingcommand,youarenotpromptedforconfirmation.
vicfg-cfgbackup <conn_options> -l /tmp/ESX_181842_backup.txt -q

Torestorethehosttofactorysettings,runvicfg-cfgbackupwiththe-roption:
vicfg-cfgbackup <conn_options> -r

Using vicfg-cfgbackup from vMA


Tobackupahostconfiguration,youcanrunvicfg-cfgbackupfromavMAinstance.ThevMAinstancecan runonthetargethost(thehostthatyouarebackinguporrestoring),oronaremotehost. Torestoreahostconfiguration,youmustrunvicfg-cfgback fromavMAinstancerunningonaremotehost. Thehostmustbeinmaintenancemode,whichmeansallvirtualmachines(includingvMA)mustbe suspendedonthetargethost. Forexample,backupfortwoESXi4.1hosts(host1andhost2)withvMAdeployedonbothhostsworksas follows:

Tobackupaconfiguration(host1orhost2),runvicfg-cfgbackupfromvMArunningoneitherhost1 orhost2.Pointtothehosttobackupusingthe--servercommandlineoption. Torestorethehost1configuration,runvicfg-cfgbackupfromvMArunningonhost2andpointtohost1 inthe--servercommandlineoption. Torestorethehost2configuration,runonhost1andpointtohost2inthe--servercommandlineoption.

Managing Host Updates with vihostupdate


ThevihostupdatecommandappliessoftwareupdatestoESX/ESXiimagesandinstallsandupdates ESX/ESXiextensionssuchasVMkernelmodules,drivers,andCIMproviders. IMPORTANTRunvihostupdateagainstESX/ESXi4.0andlaterhosts.Runvihostupdate35againstESXi3.5 hosts. YoucannotrunvihostupdateagainstvCenterServersystems.

VMware, Inc.

29

vSphere Command-Line Interface Installation and Scripting Guide

Thevihostupdatecommandworkswithbulletins.AbulletinisagroupingofoneormoreVIBs(vSphere InstallationBundle).Eachbulletinaddressesoneormoreissues.Abulletinisconsideredtobeincludedin anotherbulletinifeveryvSpherebundleinthefirstbulletinmeetsoneofthesecriteria:


TheVIBisincludedinthesecondbulletin. TheVIBisobsoletedbyanotherVIBinthesecondbulletin.

Towardstheendofareleasecycle,bulletinsincludealargenumberofotherbulletins. Bulletinsarepackagedasbundlesoravailableindepotswithassociatedmetadata.zipfiles.

AbundleisanarchivethatencapsulatesVIBsandcorrespondingmetadatainaselfcontaineddepotthat isusefulforofflinepatching.Ifyouusebundles,allpatchesandcorrespondingmetadataareavailableas oneZIPfile. Youcanalsouseametadata.zipfilethatpointsdirectlytothelocationofthepatchfilesinadepot.

Thevihostupdate commandsupportsqueryingsoftwareinstalledonahost,listingsoftwareinapatch, scanningforbulletinsthatapplytoahost,andinstallingallorselectivebulletinsinthepatch.SeethevSphere CommandLineInterfaceReferenceforinformationonallsupportedoptions.Youcanspecifyapatchbyusinga bundleZIPfileorthemetadataZIPfilethatdescribesthelocationofadepot.Thedepotcanbeontheremote server,oryoucandownloadabundleZIPfileandusealocaldepot. vihostupdatesupportshttps://,http://,andftp://downloads.Youcanspecifytheprotocolsinthedownload URLforthebundleormetadatafile.Youcanspecifymorethanonebundlefileatthecommandlineeachtime yourunthecommand.MultiplebundlesareusuallyrequiredonlyiftheupdateincludesbothaVMware bundleandathirdpartybundle. SeetheESXiUpgradeGuide.Formoreinformationaboutinstallation,removal,andupdateof3rdParty ExtensionsinvSphere4.x,seetheESXiSetupGuideandDeployingThirdPartyBundlesonpage 31. To update a host using bundles 1 PoweroffallvirtualmachinesrunningontheESX/ESXihostbyrunningthefollowingcommandforeach virtualmachine.
vmware-cmd <conn_options> <vm-path> stop <powerop_mode>

Specifyhardtoforcethepoweroffoperationorsofttohavethesystemtrytoshutdowntheguest operatingsystem. 2 Placethehostintomaintenancemode.


vicfg-hostops <conn_options> --operation enter

Checkthatthehostisinmaintenancemode.Ifnecessary,shutdownormigratevirtualmachines.
vicfg-hostops <conn_options> --operation info

Findoutwhichbulletinsareinstalledonthehost.
vihostupdate <conn_options> --query

Findoutwhichbulletinsareavailableinthebundle.
vihostupdate <conn_options> --list --bundle http://<webserver>/rollup.zip

Findoutwhichbulletinsinthebundleareapplicabletoyourhost.
vihostupdate <conn_options> --scan --bundle http://<webserver>/rollup.zip

Installallorsomebulletinsfromthebundleonthehost.ThefollowingexampleinstallsbothVMware bulletinsandbulletinsmadeavailablebyapartner.
vihostupdate <conn_options> --install --bundle http://<server>/rollup.zip,http://<server>/rollupPartner1.zip

VerifythatthebulletinsareinstalledonyourESX/ESXihost.
vihostupdate <conn_options> --query

30

VMware, Inc.

Chapter 3 Managing Hosts

To update a host using depots 1 PoweroffallvirtualmachinesrunningontheESX/ESXihostbyrunningthefollowingcommandforeach virtualmachine.


vmware-cmd <conn_options> <vm-path> stop <powerop_mode>

Specifyhardtoforcethepoweroffoperationorsofttohavethesystemtrytoshutdowntheguest operatingsystem. 2 Placethehostintomaintenancemode.


vicfg-hostops <conn_options> --operation enter

Checkthatthehostisinmaintenancemode.Ifnecessary,shutdownormigratevirtualmachines.
vicfg-hostops <conn_options> --operation info

Listallbulletinsinthedepotgiventhemetadata.zipfilelocation.
vihostupdate <conn_options> --list --metadata http://<webserver>/depot/metadata.zip

Scanthedepotforbulletinsthatareapplicabletothehost.
vihostupdate <conn_options> --scan --metadata http://<webserver>/depot/metadata.zip

Installbulletinsinthedepotonthehost.

Toinstallallbulletins,runthefollowingcommand.
vihostupdate <conn_options> --install --metadata http://<webserver>/depot/metadata.zip

Toinstallselectedbulletinsinthespecifieddepotonthehost,useacommaseparatedlist.Spaces afterthecommaarenotsupported.
vihostupdate <conn_options> --install --metadata http://<webserver>/depot/metadata.zip --bulletin bulletin1,bulletin3

Deploying Third-Party Bundles


Youcanusethe--bundleoptiontodeployathirdpartybundlethatyouhavedownloadedonyourWeb server. To deploy a third-party bundle 1 PoweroffallvirtualmachinesthatarerunningontheESX/ESXihost.
vmware-cmd <conn_options> <vm-path> stop <powerop_mode>

Specifyhardtoforcethepoweroffoperationorsofttohavethesystemtrytoshutdowntheguest operatingsystem. 2 Placethehostintomaintenancemode.


vicfg-hostops <conn_options> --operation enter

Checkthatthehostisinmaintenancemode.Ifnecessary,shutdownormigratevirtualmachines.
vicfg-hostops <conn_options> --operation info

Installthebundle.
vihostupdate <conn_options> --install --bundle https://<3rdParty_webserver>/Cisco_Swordfish.zip

Removing Bulletins from a Host


YoucanuninstallthirdpartybulletinsorVMwareextensionsfromyourESX/ESXihost. IMPORTANTDonotremovebulletinsthatareVMwarepatchesorupdates.

VMware, Inc.

31

vSphere Command-Line Interface Installation and Scripting Guide

To uninstall a bulletin 1 PoweroffallvirtualmachinesthatarerunningontheESX/ESXihost.


vmware-cmd <conn_options> <vm-path> stop

Placethehostintomaintenancemode.
vicfg-hostops <conn_options> --operation enter

Checkthatthehostisinmaintenancemode,andshutdownormigratevirtualmachinesifnecessary.
vicfg-hostops <conn_options> --operation info

DeterminewhichbulletinsareinstalledonyourESX/ESXihost.
vihostupdate <conn_options> --query

NotethebulletinIDforthebulletintouninstall. 5 Runthevihostupdatecommand,specifyingthebulletintoremove.
vihostupdate <conn_options> --remove --bulletin bulletin1

vihostupdatecanremoveonlyonebulletinatatime.

Managing VMkernel Modules with vicfg-module


Thevicfg-modulecommandsupportssettingandretrievingVMkernelmoduleoptions.vicfg-moduleisa vCLIimplementationoftheesxcfg-moduleserviceconsolecommandthatsupportsonlysomeoftheoptions esxcfg-modulesupports.vicfg-moduleiscommonlyusedwhenVMwareTechnicalSupport,aKnowledge Basearticle,orVMwaredocumentationinstructyoutodoso. To examine and set NetQueue VMkernel modules 1 Runvicfg-module --listtolistthemodulesonthehost.
vicfg-module <conn_options> --list

Runvicfg-module --set-optionswithconnectionoptions,theoptionstringtobepassedtoamodule, andthemodulename.Forexample:


vicfg-module <conn_options> --set-options 'intr_type_2 rx_ring_num=8' s2io

ConfiguresasupportednetworkinterfacetouseNetQueue. Toretrievetheoptionstringconfiguredtobepassedtoamodulewhenthemoduleisloaded,run vicfg-module --get-options.Thisstringisnotnecessarilytheoptionstringcurrentlyinusebythe module.


vicfg-module <conn_options> --get-options s2io

VerifiesthattheNetQueuemoduleisconfigured.

Using vicfg-authconfig for Active Directory Configuration


vicfg-authconfigallowsyoutoremotelyconfigureActiveDirectorysettingsonESX/ESXihosts.Beforeyou runthecommandonanESX/ESXihost,youmustpreparethehost. Youcanlistsupportedandactiveauthenticationmechanisms,listthecurrentdomainandjoinorpartfroman ActiveDirectorydomain. To prepare ESX/ESXi hosts for Active Directory Integration 1 2 3 MakesuretheESX/ESXisystemandtheActiveDirectoryserverareusingthesametimezone.The ESX/ESXisystemstimezoneisUTCbydefault. SetuptheESX/ESXisystemtohavethesametimeastheActiveDirectoryserver. ConfiguretheESX/ESXisystemsDNStobeintheActiveDirectorydomain.

32

VMware, Inc.

Chapter 3 Managing Hosts

Youcannowrunvicfg-authconfigtoaddthehosttothedomain.Auserwhorunsvicfg-authconfigto configureActiveDirectorysettingsmusthavetheappropriateActiveDirectorypermissions,andmusthave administrativeprivilegesontheESX/ESXihost. To set up Active Directory 1 2 3 4 InstalltheESX/ESXihost,asexplainedintheInstallationGuide. InstallWindowsActiveDirectoryonaWindowsServerrunningWindows2000,Windows2003,or Windows2008. SynchronizetimebetweentheESX/ESXisystemandWindowsActiveDirectory(AD)andmakesurethe WindowsADServerandESX/ESXisystemareinthesametimezone. TestthattheWindowsADServercanpingtheESX/ESXihostusingthehostname.
ping <ESX_hostname>

(Optional)IfyoucannotpingtheESX/ESXisystemfromtheWindowsADServer,followthesestepsto resolvetheissue. a AppendthefollowingtoC:\Windows\System32\drivers\etc\hostsfile:


<IP Address of ESX Server> <host name>

Makesurethe/etc/resolv.conffileontheESX/ESXihostcontainsthefollowingstring:
nameserver <Windows AD IP Address> search <Domain Name of Windows AD>

RunthefollowingvCLIcommand:
vicfg-authconfig --server=<ESX Server IP Address> --username=<ESX Server Admin Username> --password=<ESX Server Admin User's Password> --authscheme AD --joindomain <AD Domain Name> --adusername=<Active Directory Administrator User Name> --adpassword=<Active Directory Administrator User's Password>

Thesystempromptsforusernamesandpasswordsifyoudonotspecifythemonthecommandline. Passwordsarenotechoedtothescreen. 7 8 CheckthataSuccessfully Joined <Domain Name>messageappears. Runvicfg-authconfig --listtoverifytheESX/ESXihostisintheintendedWindowsADdomain.

SeethevSphereCommandLineInterfaceReferenceforalistofoptionsandexamples.

VMware, Inc.

33

vSphere Command-Line Interface Installation and Scripting Guide

34

VMware, Inc.

Managing Files

ThevSphereCLIincludestwocommandsforfilemanipulation.vmkfstoolsallowsyoutomanipulateVMFS (VirtualMachineFileSystem)andvirtualdisks.vifssupportsremoteinteractionwithfilesonyourESX/ESXi host. NOTESeeManagingStorageonpage 49forinformationaboutstoragemanipulationcommands. Thischapterincludesthefollowingtopics:


IntroductiontoVirtualMachineFileManagementonpage 35 ManagingtheVirtualMachineFileSystemwithvmkfstoolsonpage 36 UsingvifstoManipulateFilesonRemoteESX/ESXiHostsonpage 46

Introduction to Virtual Machine File Management


YoucanusethevSphereClientorvCLItoaccessdifferenttypesofstoragedevicesthatyourESX/ESXihost discoversandtodeploydatastoresonthem. NOTEDatastoresarelogicalcontainers,analogoustofilesystems,thathidespecificsofeachstoragedevice andprovideauniformmodelforstoringvirtualmachinefiles.DatastorescanbeusedforstoringISOimages, virtualmachinetemplates,andfloppyimages.ThevSphereClientusesthetermdatastoreexclusively.This manualwillusethetermdatastoreandVMFS(orNFS)volumetorefertothesamelogicalcontaineronthe physicaldevice. Dependingonthetypeofstorageyouuse,datastorescanbebackedbythefollowingfilesystemformats:

VirtualMachineFileSystem(VMFS)Highperformancefilesystemthatisoptimizedforstoringvirtual machines.YourhostcandeployaVMFSdatastoreonanySCSIbasedlocalornetworkedstoragedevice, includingFibreChannelandiSCSISANequipment. AsanalternativetousingtheVMFSdatastore,yourvirtualmachinecanhavedirectaccesstorawdevices anduseamappingfile(RDM)asaproxy. YoumanageVMFSandRDMswiththevSphereClientorthevmkfstoolsutility.

NetworkFileSystem(NFS)FilesystemonaNASstoragedevice.ESX/ESXisupportsNFSversion3over TCP/IP.ThehostcanaccessadesignatedNFSvolumelocatedonanNFSserver,mountthevolume,and useitforanystorageneeds.

VMware, Inc.

35

vSphere Command-Line Interface Installation and Scripting Guide

Figure 4-1. Virtual Machines Accessing Different Types of Storage


Host requires TCP/IP connectivity virtual machine virtual machine virtual machine virtual machine virtual machine

local ethernet SCSI bre channel HBA SAN iSCSI hardware initiator LAN software initiator ethernet NIC LAN ethernet NIC LAN

VMFS

Key
physical disk

datastore VMFS fibre array VMFS iSCSI array NFS NAS appliance

virtual disk

Managing the Virtual Machine File System with vmkfstools


VMFSdatastoresprimarilyserveasrepositoriesforvirtualmachines.Youcanstoremultiplevirtualmachines onthesameVMFSvolume.Eachvirtualmachine,encapsulatedinasetoffiles,occupiesaseparatesingle directory.Fortheoperatingsysteminsidethevirtualmachine,VMFSpreservestheinternalfilesystem semantics. Inaddition,youcanusetheVMFSdatastorestostoreotherfiles,suchasvirtualmachinetemplatesandISO images.VMFSsupportsfileandblocksizesthatenablevirtualmachinestorundataintensiveapplications, includingdatabases,ERP,andCRM,invirtualmachines.ThevSphereESXiConfigurationGuideprovides details. YouusethevmkfstoolsvCLItocreateandmanipulatevirtualdisks,filesystems,logicalvolumes,and physicalstoragedevicesonanESX/ESXihost.Youcanusevmkfstoolstocreateandmanageavirtual machinefilesystem(VMFS)onaphysicalpartitionofadiskandtomanipulatefiles,suchasvirtualdisks, storedonVMFS3andNFS.Youcanalsousevmkfstoolstosetupandmanagerawdevicemappings(RDMs). IMPORTANTThevmkfstoolsvCLIsupportsmostbutnotalloftheoptionsthatthevmkfstoolsservice consolecommandsupports.SeeVMwareKnowledgeBasearticle1008194. Youcannotrunvmkfstoolswith--serverpointingtoavCenterServersystem.

vmkfstools Command Syntax


Thevmkfstoolscommandsupportsspecifyingoneormorecommandlineoptions,associatedarguments, andthetarget,resultinginthefollowingsyntax.
vmkfstools <conn_options> <options> <target> Option <conn_options> Description Connectionparameters.Youmustsupplyconnectionoptions.In mostcases,youdonothavetologinastherootusertorunthe vmkfstoolscommand.However,somecommands,suchasthe filesystemcommands,mightrequirerootuserlogin. See vCLIConnectionOptionson page 23.

36

VMware, Inc.

Chapter 4 Managing Files

Option <options> <target>

Description Oneormorecommandlineoptionsandassociatedvalues. Partition,device,orpathtoapplythecommandto.

See SupportedCommandSpecific Optionsonpage 37. SupportedvmkfstoolTargets onpage 38.

Supported Command-Specific Options


YoucanusevmkfstoolsfilesystemoptionstocreateorextendaVMFSfilesystem,andtolistfilesystem attributes.Table 41givesanoverview. Table 4-1. vmkfstools File System Option Overview
Option --blocksize -b --createfs -C --queryfs -P --setfsname -S --spanfs -Z Description Usesthespecifiedsizeforfilesystem creation.Usedwith--createfs. CreatesaVMFSfilesystem. Listsattributesofafilesystem. Setsthelabelforthefilesystem.Used with--createfs. ExtendstheVMFSfilesystem. See CreatingaVMFSFileSystemonpage 38. CreatingaVMFSFileSystemonpage 38. ListingVMFSVolumeAttributesonpage 39. CreatingaVMFSFileSystemonpage 38. ExtendingVMFSPartitionsbySpanningon page 39.

Youcanusevmkfstoolsvirtualdiskoptionstocreate,clone,manipulate,anddeletevirtualdisksandto manageRDMs(RawDeviceMappings).Table 42givesanoverview. Table 4-2. vmkfstools Virtual Disk Option Overview
Option --adaptertype -a --clonevirtualdisk -i --createrdm -r --createrdmpassthru -z --createvirtualdisk -c --deletevirtualdisk -U --diskformat -d --extendvirtualdisk -X --geometry -g --inflatedisk -j Description Usesthespecifiedtypefordisk creation.Usedwith-cand-i. Clonesthespecifiedvirtualdisk. MapsarawdisktoafileonaVMFSfile system. Mapsapassthroughrawdisktoafile onaVMFSfilesystem. Createsavirtualdisk. Deletesthespecifiedvirtualdisk. Usesthespecifiedformatfordisk creation.Usedwith-cand-i. Extendsthespecifiedvirtualdisk. Displaysvirtualdiskgeometry. Convertsathinvirtualdiskto eagerzeroedthickformat,preserving allexistingdata. See CreatingVirtualDisksonpage 41. CloningVirtualorRawDisksonpage 42. CreatingVirtualCompatibilityModeRaw DeviceMappingsonpage 45. CreatingPhysicalCompatibilityModeRaw DeviceMappingsonpage 45. CreatingVirtualDisksonpage 41. DeletingVirtualDisksonpage 42. SupportedDiskFormatsonpage 40. ExtendingVirtualDisksonpage 43. DisplayingVirtualDiskGeometryonpage 43. InflatingThinVirtualDisksonpage 41.

VMware, Inc.

37

vSphere Command-Line Interface Installation and Scripting Guide

Table 4-2. vmkfstools Virtual Disk Option Overview (Continued)


Option --renamevirtualdisk -E --writezeros -w Description Renamesthespecifiedvirtualdisk. Cleansthevirtualdiskbywritingzeros overallitsdata. See RenamingVirtualDiskonpage 42. InitializingVirtualDisksonpage 41.

Supported vmkfstool Targets


Youcanspecifythetargetoftheoperationspecifiedin<options>asafilesystem,partition,orvirtualdisk.You canusearelativeorabsolutepathnameinthe/vmfshierarchy. File System Target SpecifyaVMFSfilesystemorfileusinganabsoluteorrelativepaththatnamesadirectorysymboliclink,a rawdevicemapping,orafileunder/vmfs. VMFSfilesystem VMFSfile
/vmfs/volumes/<file_system_UUID> /vmfs/volumes/<file_system_label> /vmfs/volumes/<file system label|file system UUID>/[dir]/myDisk.vmdk

Youmustuseanabsolutepathnamestartingwith/vmfs/volumes.For example,/vmfs/volumes/datastore1/rh9.vmdk SeevmkfstoolsFileSystemOptionsonpage 38. Disk Partition Target Specifyadiskpartitionusingnaa.<naa_ID>:P,wherenaa.<naa_ID>isthedeviceIDreturnedbythe storagearrayandPisanintegerthatrepresentsthepartitionnumber.Thepartitiondigitmustbegreaterthan zeroandmustcorrespondtoavalidVMFSpartitionoftypefb. SeevmkfstoolsVirtualDiskOptionsonpage 40. Device Target SpecifyadeviceorlogicalvolumeusingapathnameinanESX/ESXidevicefilesystem.Thenamebeginswith /vmfs/devices,whichisthemountpointofthedevicefilesystem.Eachdevicetypehassubmounts,for example:
/vmfs/devices/disks /vmfs/devices/lvm /vmfs/devices/generic

LocalorSANbaseddisks. ESX/ESXilogicalvolumes. GenericSCSIdevices,suchastapedrives.

vmkfstools File System Options


Usingvmkfstoolsfilesystemcommands,youcancreate,query,andextendaVMFSfilesystem.Theoptions donotapplytoNFSfilesystems.Youmustalsospecifyconnectionoptions.SeevCLIConnectionOptions onpage 23.

Creating a VMFS File System


The-CoptioncreatesaVMFSfilesystemonaspecifiedpartition,suchasnaa.<naa_ID>:1.Thespecified partitionbecomesthefilesystemsheadpartition.YoucanhaveonlyoneVMFSvolumeforaLUN.
-C --createfs vmfs3 -b --blocksize <block_size>kK|mM -S --setfsname <fsName>

IMPORTANTWhenyourunthiscommand,youarenotpromptedforconfirmation.Checkcarefullybefore yourunthecommandtoavoiderasingimportantdata.

38

VMware, Inc.

Chapter 4 Managing Files

VMFS2filesystemsarereadonlyonanyESX/ESXihost.YoucannotcreateormodifyVMFS2filesystems butyoucanreadfilesstoredonVMFS2filesystems. The-Coptionhasthefollowingsuboptions.


Option -b blocksize Description BlocksizefortheVMFS3filesystem.Thedefaultfileblocksizeis1MB.Validblocksizesfor VMFS3are1,2,4,8MB Whenenteringasize,indicatetheunittypebyaddingasuffixsuchasmorM.Theunittypeisnot casesensitivevmkfstoolsinterpretsmorMtomeanmegabytesandkorKtomeankilobytes. -S setfsname VolumelabelofaVMFSvolumeforthefilesystemyouarecreating.Use-S onlywiththe-Coption. Thelabelcanbeupto128characterslongandcannotcontainleadingortrailingblankspaces. Afteryoudefineavolumelabel,youcanuseitwheneveryouspecifyaVMFSvolumeinacallto vmkfstools.ThevolumelabelappearsinlistingsgeneratedfortheLinuxls -lcommandandas asymboliclinktotheVMFSvolumeunderthe/vmfs/volumesdirectory. YoucanchangetheVMFSvolumelabelusingthevSphereClientUI.

Whenyourunvmkfstools -C,youcanoptionallyspecifytheblocksizeandvolumelabelforthefilesystem, andspecifythelocation.Forexample:

CreateaVMFS3filesystemnamedmy_vmfswithblocksize2MB.
vmkfstools <conn_options> -C vmfs3 -b 2m -S my_vmfs -vml.<vml_ID>:1

CreateaVMFS3filesystemnamedmy_vmfsandusethedefaultblocksize(1MB).
vmkfstools <conn_options> --createfs vmfs3 --setfsname my_n /vmfs/devices/disks/naa.<naa_id>:1

Listing VMFS Volume Attributes


The-PoptionliststheattributesofafileordirectoryonaVMFSvolume.
-P --queryfs

To list volume attributes Runvmkfstoolswithconnectionoptions,the-P | --queryfsoption,andthevolumetoquery.


vmkfstools <conn_options> --queryfs /vmfs/volumes/my_vmfs

ThelistedattributesareversiondependentbutmightincludetheVMFSversionnumber,thenumberof extentsinthespecifiedVMFSvolume,thevolumelabelifany,theUUID,andalistingofthedevicenames whereeachextentresides,asinthefollowingexample:


VMFS-3.33 file system spanning 1 partitions. Capacity : 65229815808, 64641564672 avail File system label : my_vmfs UUID : 46fd1460-6ec4e2b8-e048-000e0c7f4088 Path : /vmfs/volumes/46fd1460-6ec4e2b8-e048-000e0c7f4088 Partitions spanned: naa.xxxxxxxxxxxxxxxxxxxxxx:3

IfanydevicethatisbackingaVMFSfilesystemgoesoffline,thenumberofextentsandtheavailablespace changeaccordingly.

Extending VMFS Partitions by Spanning


Youcanrunvmkfstools -ZtoextendtheVMFSfilesystemwiththespecifiedheadpartitionbyspanningit acrossthepartitionspecifiedby<span-partition>.
-Z | --spanfs <span-partition> <head-partition>

Theoperationerasesexistingdataonthespannedpartition.AVMFSfilesystemcanhaveatmost32partitions. TheoptionsdoesnotworkonVMFS2volumes.VMFS2volumesarereadonlyinESX/ESXi3.0andlater. CAUTIONWhenyourunthisoption,youlosealldataontheSCSIdevicespecifiedin<span_partition>.

VMware, Inc.

39

vSphere Command-Line Interface Installation and Scripting Guide

Youcanextendapartitionbyrunningvmkfstools -Zwithconnectionoptions,thepartitiontospan,andthe headpartition.


vmkfstools <conn_options> -Z /vmfs/devices/disks/naa.<naa_id_1>:1 /vmfs/devices/disks/naa.<naa_id_2>:3

Thecommandextendsthelogicalfilesystembyallowingittospantoanewpartition.Theextendedfile systemspanstwopartitions,naa.<naa_id_1>:1andnaa.<naa_id_2>:3.Inthisexample, /vmfs/devices/disks/naa.<naa_id_2>:3istheheadpartitionoftheexistingVMFS3filesystem. naa.<naa_id_1>:1isthepartitiontobeadded.

vmkfstools Virtual Disk Options


Avirtualdiskisafileorsetoffilesthatappearsasaphysicaldiskdrivetoaguestoperatingsystem.Virtual diskfilescanbeontheESX/ESXihostoronaremotefilesystem. Thevmkfstoolsvirtualdiskoptionssupportsetup,migration,andmanagementofvirtualdisksstoredin VMFS2,VMFS3,andNFSfilesystems.YoucanperformmostofthesetasksthroughthevSphereClientor vCLI.

Supported Disk Formats


Whenyoucreateorcloneavirtualdisk,youcanusethe-d --diskformatsuboptiontospecifytheformat foryourdisk.Table 43liststhesupportedformats. Table 4-3. Supported Disk Formats
Format zeroedthick (default) eagerzeroedthick Description Spacerequiredforthevirtualdiskisallocatedduringcreation.Anydataremainingonthe physicaldeviceisnoterasedduringcreation,butwillbezeroedoutondemandthefirsttime thevirtualmachinewritestodisk.Thevirtualmachinedoesnotreadstaledatafromdisk. Spacerequiredforthevirtualdiskisallocatedatcreationtime.Incontrasttozeroedthick format,thedataremainingonthephysicaldeviceiszeroedoutduringcreation.Itmighttake muchlongertocreatedisksinthisformatthantocreateothertypesofdisks. Thinprovisionedvirtualdisk.Spacerequiredforthevirtualdiskisnotallocatedduring creation,butissupplied,zeroedout,ondemandatalatertime. Convertthinprovisioneddiskswiththe-joption.SeeInflatingThinVirtualDiskson page 41. rdm rdmp 2gbsparse Virtualcompatibilitymoderawdiskmapping. Physicalcompatibilitymode(passthrough)rawdiskmapping. Sparsediskwith2GBmaximumextentsize.YoucanusedisksinthisformatwithotherVMware productssuchasVMwareWorkstation.YoucannotpoweronasparsediskonanESX/ESXihost unlessyoufirstreimportthediskinacompatibleformat,suchasthin,withvmkfstools.

thin

With -c --createvirtualdisk,vmkfstoolsacceptszeroedthick,eagerzeroedthick,andthin. With-i clonevirtualdisk,vmkfstoolsacceptszeroedthick,thin,eagerzeroedthick, rdm:<device>,rdmp:<device>,and2gbsparse. WithNFSfiles,vmkfstoolssupportsonlythin,zeroedthick,and2gbsparse.BecausetheNFSserverand nottheESX/ESXisystemdecidestheallocationpolicy,zeroedthick,andthinusuallyhavethesameresult. ThedefaultallocationpolicyonmostNFSserversisthin. IMPORTANTIfyourunvCLI4.xagainstvCLI4.xsystems,formatsaresupportedaslisted.Supportislimited ifyourunvCLI4.xagainstvCLI3.5systems.

40

VMware, Inc.

Chapter 4 Managing Files

Creating Virtual Disks


The-coptioncreatesavirtualdiskatthespecifiedlocationonaVMFSvolume.
-c --createvirtualdisk <size>[kK|mM|gG] -a --adaptertype [buslogic|lsilogic|ide] <srcfile> -d --diskformat [thin|zeroedthick|eagerzeroedthick] <location>

Whenyourunvmkfstools -c,--adaptertypedefaultstobuslogicand--diskformatdefaultsto zeroedthick. Youmustspecifythesizeofthevirtualdisk.Indicatetheunittypeforthe<size>optionbyaddingasuffixof korK(kilobytes),m orM(megabytes),orgorG(gigabytes).Ifyoudonotspecifyaunittype,vmkfstools defaultstobytes. Youcanspecifythedevicedriverandthediskformatusing-aand-d.

-aspecifiesthedevicedriverthatisusedtocommunicatewiththevirtualdisks.YoucanselectBusLogic, LSILogicSCSI,orIDEdrivers. -dspecifiesthediskformat,oneofzeroedthick,thin,eagerzeroedthick.SupportedDiskFormats onpage 40discussesallsupporteddiskformats,includingthosesupportedbycreatevirtualdisk.

Whenyoucreateavirtualdisk,youcanusethedefaultfileformatandadapterorspecifythemexplicitly.

Runvmkfstools -candspecifythesizeandfullpathforthevirtualdisk.Forexample:
vmkfstools <conn_options> -c 2g /vmfs/volumes/my_vmfs/myOS.vmdk

CreatesatwogigabytevirtualdiskfilenamedmyOS.vmdkontheVMFSfilesystemnamedmy_vmfs.This filerepresentsanemptyvirtualdiskthatavirtualmachinecanaccess.

Specifyafileformatandadapterforthevirtualdisk.Youchangethedefaultadapterassociatedwiththe virtualmachine(buslogic),usingthe-aoption.Choicesarelsilogicoride.
vmkfstools <conn_options> --createvirtualdisk 20m -d thin -a lsilogic /vmfs/volumes/M1/test.vmdk

Createsavirtualdiskassociatedwithanlsilogicvirtualadapter.SeeAddingandModifyingVMkernel NetworkInterfaceswithvicfgvmkniconpage 117. IMPORTANTTheadaptertypeissetwhenyoucreatethevirtualdisk.Ifyoudonotspecifyatype,thedefault (buslogic)isused.Ifyouspecifyatype,itbecomesthetypeforthatdisk.Youcannotchangetheadaptertype later.

Initializing Virtual Disks


The-woptionerasesavirtualdiskbywritingzerosoverallitsdata.
-w --writezeros

DependingonthesizeofyourvirtualdiskandtheI/Obandwidthtothedevicethatishostingthevirtualdisk, completingthiscommandmighttakealongtime. CAUTIONWhenyouusethiscommand,youloseanyexistingdataonthevirtualdisk.

Youcanrunvmkfstoolswiththe--writezerosoptiontoinitializeavirtualdisk.
vmkfstools <conn_options> --writezeros /vmfs/volumes/my_vmfs/text02.vmdk

Inflating Thin Virtual Disks


Athinprovisionedvirtualdiskstartssmallandexpandsasmorediskspaceisrequired.Administratorscreate avirtualdiskinthinprovisionedformattosavestoragespace.

VMware, Inc.

41

vSphere Command-Line Interface Installation and Scripting Guide

The-joptionconvertsathinvirtualdisktoeagerzeroedthickformatandpreservesallexistingdata. vmkfstoolsallocatesandzeroesoutanyblocksthatwerenotallocated.
-j --inflatedisk

Youcaninflateavirtualdiskbyrunningvmkfstoolswithconnectionoptionsandthe--inflatedisk option.
vmkfstools <conn_options> --inflatedisk /vmfs/volumes/myvmfs/thin.vmdk

Deleting Virtual Disks


The-UoptiondeletesfilesassociatedwiththevirtualdiskatthespecifiedpathontheVMFSvolume.
-U --deletevirtualdisk <conn_options> <location>

Youcandeleteavirtualdiskbyrunningvmkfstoolswithconnectionoptions,the-Uoption,andthenameof thevirtualdisktobedeleted.
vmkfstools <conn_options> -U /vmfs/volumes/store/test.vmdk

Renaming Virtual Disk


The-Eoptionrenamesavirtualdiskfile.
-E --renamevirtualdisk <conn_options> <oldName> <newName>

Youmustspecifytheoriginalfilenameorfilepath<oldName>andthenewfilenameorfilepath<newName>. Youcanrenameavirtualdiskbyrunningvmkfstools -Eandspecifyconnectionoptions,theoldfilepath, andthenewfilepath.


vmkfstools <conn_options> -E /vmfs/volumes/myvmfs/test.vmdk /vmfs/volumes/store/renamed.vmdk

Cloning Virtual or Raw Disks


The-ioptioncreatesacopyofavirtualdiskorarawdiskthatyouspecify.
-i --clonevirtualdisk <srcfile> <destfile> -d --diskformat [zeroedthick| thin| eagerzeroedthick| rdm:<device>|rdmp:<device>| 2gbsparse] -a --adaptertype <type>

The--diskformatoptionspecifiesthediskformatforthecopy.diskformatdefaultstozeroedthickifnot specified.adaptertypedefaultstobuslogicifnotspecified.SeeSupportedDiskFormatsonpage 40. IMPORTANTTomakeacopyoftheredologsofanESX/ESXihostwhilepreservingtheirhierarchy,usethe vifs -ccommandinstead. To clone a virtual or raw disk 1 2 Stopthesourcevirtualmachine. Runvmkfstools -i,specifyingthesourceandtargetandoptionaldiskformatandadaptertype.For example:
vmkfstools <conn_options> -i /vmfs/volumes/templates/gold-master.vmdk /vmfs/volumes/myVMFS/myOS.vmdk -d thin -a lsilogic

Thecloneprocessmighttakesometime.Theexacttimedependsonthesizeofyourdisk. 3 4 5 6 Configureanewvirtualmachine. Whenaskedtoconfigureadisk,chooseUseanexistingdiskandselectthecloneddiskyoujustcreated (myOS.vmdkintheexample). Afterthevirtualmachineiscreated,startit,login,andchangetheIPaddressandhostname. AfteryouhavechangedtheIPaddressfortheclone,youcanpoweronthesourcevirtualmachine.

42

VMware, Inc.

Chapter 4 Managing Files

Migrating VMware Workstation and VMware GSX Server Virtual Machines


YoucannotusethevSphereClienttomigratevirtualmachinescreatedwithVMwareWorkstationor VMware GSXServertoyourESX/ESXisystem.However,youcanusethevmkfstools -icommandtoimport thevirtualdiskintoyourESX/ESXisystem.Youcanthenattachthisdisktoanewvirtualmachinethatyou createintheESX/ESXisystem.Youmustimportthevirtualdiskfirst,becauseyoucannotpowerondisks exportedin2gbsparseformatonanESX/ESXihost. To migrate Workstation virtual machines 1 2 3 ImportaVMwareWorkstationorGSXServerdiskintoyour/vmfs/volumes/myVMFS/directoryorany subdirectoryusingvmkfstools. UsingthevSphereClient,createanewvirtualmachineusingtheCustomconfigurationoption. SelectUseanexistingvirtualdiskandattachtheVMwareWorkstationorGSXServerdiskthatyou importedduringdiskconfiguration.

Extending Virtual Disks


The-Xoptionextendsthesizeofadiskallocatedtoavirtualmachineafterthevirtualmachinehasbeen created.
-X --extendvirtualdisk [-d eagerzeroedthick] <newSize>[kK|mM|gG] <v_disk>

Youmustpoweroffthevirtualmachinethatusesthisdiskfilebeforeyouenterthiscommand.Youmighthave toupdatethefilesystemonthedisksothattheguestoperatingsystemcanrecognizeandusethenewsizeof thediskandtakeadvantageoftheextraspace. IMPORTANTnewSizedefinestheentirenewsize,notjusttheincrementthatyouaddtothedisk. YouspecifythenewSizeoptioninkilobytes,megabytes,orgigabytesbyaddingasuffixofkorK(kilobytes), m orM(megabytes),orgorG(gigabytes).Ifyoudonotspecifyaunittype,vmkfstoolsdefaultstokilobytes. Donotextendthebasediskofavirtualmachinethathassnapshotsassociatedwithit.Ifyoudo,youcanno longercommitthesnapshotorrevertthebasedisktoitsoriginalsize. Bydefault,anydisk,regardlessofformat,isextendedaszeroedthick.Youcanspecify-d eagerzeroedthicktochangetheformattoeagerzeroedthick.Extendvirtualdiskstoeagerzeroedthick onlyiftheyareusedforfaulttoleranceandclusteringandhavetobepreallocatedandzeroed.-dallowsonly eagerzeroedthick,itdoesnotallowotherdiskformats. To extend a virtual disk 1 Shutdownthevirtualmachineassociatedwiththedisk,eitherbyusingthevSphereClientorbyusing vmware-cmd(seeManagingVirtualMachinesonpage 89).
vmware-cmd -H <vc_system> --vihost <esx_host> /vmfs/volumes/Storage2/testvm/testvm.vmx stop <powerop_mode>

Specifyhardtoforcetheshutdown,orsofttohavethesystemattempttoshutdowntheguestoperating system. 2 Runvmkfstools -Xwithconnectionoptions,thenewsize,anoptionalnewformat,andthelocationfor thevirtualdisk.


vmkfstools <conn_options> -X 50M /vmfs/volumes/Storage2/testvm/testvm.vmdk

Displaying Virtual Disk Geometry


The-goptionretrievesinformationaboutthegeometryofavirtualdisk.
-g --geometry

VMware, Inc.

43

vSphere Command-Line Interface Installation and Scripting Guide

TheformisGeometry information C/H/S,whereCisthenumberofcylinders,Histhenumberofheads, andSisthenumberofsectors. IMPORTANTWhenyouimportVMwareWorkstationvirtualdiskstoESX/ESXihost,youmightseeadisk geometrymismatchmessage.Geometrymismatchmightalsocauseproblemswhenyouloadaguest operatingsystemorrunanewlycreatedvirtualmachine.

Managing Raw Device Mapping Files


YoucanstorevirtualmachinedatadirectlyonaSANLUNinsteadofstoringthedatainavirtualdiskfile.Data onaSANLUNisusefulifyourunapplicationsinyourvirtualmachinesthatmusthaveinformationaboutthe physicalcharacteristicsofthestoragedevice.MappingaSANLUNalsoallowsyoutouseexistingSAN commandstomanagestorageforthedisk. WhenyoumapaLUNtoaVMFSvolume,thevCenterServersystemcreatesafilecalledtheRDMfile,which pointstotherawLUN.EncapsulatingdiskinformationinafileallowsvCenterServertolocktheLUNsothat onlyonevirtualmachinecanwritetoit.Asaresult,allVMFS3filelockingmechanismsapplytoRDMs. IMPORTANTAnRDMfilehasa.vmdkextension,butthefilecontainsonlydiskinformationthatdescribesthe mappingtotheLUNontheESX/ESXisystem.TheactualdataisstoredontheLUN. YoucannotdeployavirtualmachinefromatemplateandstoreitsdataonaLUN.Youcanstoreitsdataonly inavirtualdiskfile.

RDM Virtual and Physical Compatibility Modes


YoucanuseRDMsinvirtualcompatibilityorphysicalcompatibilitymodes.Virtualmodespecifiesfull virtualizationofthemappeddevice.PhysicalmodespecifiesminimalSCSIvirtualizationofthemapped device.PhysicalmodeallowsthegreatestflexibilityforSANmanagementsoftware.

Invirtualcompatibilitymode,themappeddeviceappearstotheguestoperatingsystemexactlythesame asavirtualdiskfileinaVMFSvolume.Theactualhardwarecharacteristicsarehidden.Ifyouusearaw diskinvirtualmode,youcanrealizethebenefitsofVMFSsuchasadvancedfilelockingfordata protectionandsnapshotsforstreamliningdevelopmentprocesses.Virtualmodeisalsomoreportable acrossstoragehardwarethanphysicalmode.Avirtualmodemappeddevicepresentsthesamebehavior asavirtualdiskfile. Inphysicalcompatibilitymode,theVMkernelpassesallSCSIcommandstothedevice,withone exception:theREPORTLUNscommandisvirtualizedsothattheVMkernelcanisolatetheLUNforthe owningvirtualmachine.Otherwise,allphysicalcharacteristicsoftheunderlyinghardwareareexposed. PhysicalmodeisusefultorunSANmanagementagentsorotherSCSItargetbasedsoftwareinthevirtual machine.Physicalmodealsoallowsvirtualtophysicalclusteringforcosteffectivehighavailability.

Figure 4-2. Physical and Virtual Compatibility Mode


virtual machine 1 virtualization VMFS virtual machine 1

virtual mode

virtualization VMFS

physical mode

mapping file VMFS volume

mapped device

mapping file VMFS volume

mapped device

44

VMware, Inc.

Chapter 4 Managing Files

Creating Virtual Compatibility Mode Raw Device Mappings


Youcanusethe-roptiontocreateaRawDeviceMapping(RDM)fileinvirtualcompatibilitymodeona VMFS3volumeandtomaparawdisktothisfile.
-r --createrdm <device> <rdm_file>

Whenyouspecifynaa.<naa_id>,theentirerawdiskisused.Usethefollowingformat:
/vmfs/devices/disks/naa.<naa_id>

Afterthismappingisestablished,youcanaccesstherawdiskasyouwouldanormalVMFSvirtualdisk.The filelengthofthemappingisthesameasthesizeoftherawdiskitpointsto. To create and use a virtual compatibility mode RDM 1 Runvmkfstools -r withconnectionoptions,thedevicetomapasarawdisk,andthenameoftheRDM file.
vmkfstools <conn_options> -r /vmfs/devices/disks/naa.<naa_id> /vmfs/volumes/storage1/rdm210.vmdk

ThecommandcreatesavirtualcompatibilitymodeRDMfile/vmfs/volumes/storage1/rdm210.vmdk andmapsthe/vmfs/devices/disks/naa.<naa_id>rawdisktothatfile. 2 Configureavirtualmachinetousethemy_rdm.vmdkmappingfilebyusingthevSphereClientorby addingthefollowinglinestothevirtualmachineconfigurationfile.


scsi0:0.present = TRUE scsi0:0.fileName = /vmfs/volumes/myVMFS/my_rdm.vmdk

YoucanusevifstocopythefilefromtheremoteESX/ESXisystemtoyourlocalmachineandback.See UsingvifstoManipulateFilesonRemoteESX/ESXiHostsonpage 46.

Creating Physical Compatibility Mode Raw Device Mappings


The-zoptionmapsaphysicalcompatibilitymoderawdevicetoafileonaVMFSvolume.
-z --createrdmpassthru <device> <map_file>

ThemappingletsavirtualmachinebypassESX/ESXiSCSIcommandfilteringwhenaccessingitsvirtualdisk. ThistypeofmappingisusefulwhenthevirtualmachineneedstosendproprietarySCSIcommands,for example,whenthevirtualmachinerunsSANawaresoftware. Afteryouestablishthistypeofmapping,youcanusethemappingtoaccesstherawdiskjustasyouwould anyotherVMFSvirtualdisk.Theentirerawdeviceisused.Usethefollowingformat:


/vmfs/devices/disks/naa.<naa_id>

To create a physical compatibility mode RDM 1 Runvmkfstools -z withconnectionoptions,thedevicetomapasarawdisk,andthenameoftheRDM file.


vmkfstools <conn_options> -z /vmfs/devices/disks/naa.<naa_id> /vmfs/volumes/storage1/rdmpass.vmdk

ThecommandcreatesaphysicalcompatibilitymodeRDMfile/vmfs/volumes/storage1/rdmpass.vmdk andmapsthe/vmfs/devices/disks/naa.<naa_id>rawdisktothatfile.Youcannotusethenameofa filethatalreadyexists. 2 Configureavirtualmachinetousetherdmpass.vmdk mappingfilebyusingthevSphereClientorby addingthefollowinglinestothevirtualmachineconfigurationfile:


scsi0:0.present = TRUE scsi0:0.fileName = /vmfs/volumes/myVMFS/rdmpass.vmdk

VMware, Inc.

45

vSphere Command-Line Interface Installation and Scripting Guide

Using vifs to Manipulate Files on Remote ESX/ESXi Hosts


Inmostcases,vmkfstoolsandothercommandsareusedtomanipulatevirtualmachinefiles.Insomecases, youmightneedtoviewandmanipulatefilesonremoteESX/ESXihostsdirectly. CAUTIONIfyoumanipulatefilesdirectly,yourvSpheresetupmightendupinaninconsistentstate.Usethe vSphereClientoroneoftheothervCLIcommandstomanipulatevirtualmachineconfigurationfilesand virtualdisks. Thevifscommandperformscommonoperationssuchascopy,remove,get,andputonESX/ESXifilesand directories.ThecommandissupportedagainstESX/ESXihostsbutnotagainstvCenterServersystems. SomesimilaritiesbetweenvifsandDOSorUNIX/Linuxfilesystemmanagementutilitiesexist,butthereare manydifferences.Forexample,vifsdoesnotsupportwildcardcharactersorcurrentdirectoriesand,asa result,relativepathnames.Usevifsonlyasdocumented. Insteadofusingthiscommand,youcanbrowsedatastorecontentsandhostfilesbyusingaWebbrowser. Connecttothefollowinglocation:
http://ESX_host_IP_Address/host http://ESX_host_IP_Address/folder

YoucanviewdatacenteranddatastoredirectoriesfromthisrootURL. Thevifscommandsupportsdifferentoperationsforthefollowinggroupsoffilesanddirectories.Different operationsareavailableforeachgroup,andyouspecifylocationswithadifferentsyntax.

Host.Hostconfigurationfiles.Youmustspecifythefilesuniquenameidentifier. Specifyhostlocationsusingthehost/<path>syntax.

Temp.The/tmpdirectoryandfilesinthatdirectory. Specifytemplocationsusingthetmp/dir/subdirsyntax.

Datastores.Datastorefilesanddirectories.Youhavetwochoicesforspecifyingadatastore:

Datastoreprefixstyle:'[ds_name] relative_path'.Forexample:
'[myStorage1] testvms/VM1/VM1.vmx'(Linux) or "[myStorage1] testvms/VM1/VM1.vmx" (Windows)

URLstyle:/folder/dir/subdir/file?dsName=<name>.Forexample:
'/folder/testvms/VM1/VM1.vmx?dsName=myStorage1' (Linux) "/folder/testvms/VM1/VM1.vmx?dsName=myStorage1" (Windows)

ThetwoexamplepathsrefertoavirtualmachineconfigurationfileforthevirtualmachineVM1inthe testvms/VM1directoryofthemyStorage1datastore. Toavoidproblemswithdirectorynamesthatusespecialcharactersorspaces,enclosethepathinquotesfor bothoperatingsystems. Whenyourunvifs,youcanspecifytheoperationnameandargumentandoneofthestandardconnection optionsdiscussedinTable 22.Usealiases,symboliclinks,orwrapperscriptstosimplifytheinvocation syntax. IMPORTANTTheconceptsofworkingdirectoryandlastdirectoryorfileoperatedonarenotavailablewith vifs. Options vifscommandspecificoptionsallowyoutoretrieveanduploadfilesfromtheremotehostandperforma numberofotheroperations.Allvifsoptionsworkondatastorefilesordirectories.Someoptionsalsowork onhostfilesandfilesinthetempdirectory.Youmustalsospecifyconnectionoptions.SeevCLIConnection Optionsonpage 23.

46

VMware, Inc.

Chapter 4 Managing Files

Command --copy -c <source> <target>

Description Copiesafileinadatastoretoanotherlocation inadatastore.The<source>mustbearemote sourcepath,the<target>aremotetarget pathordirectory. The--forceoptionreplacesexisting destinationfiles.

For... Datastore Temp

Syntax copy src_file_path dst_directory_path [force] copy src_file_path dst_file_path [force]

--dir -D <remote_dir> --force -F --get -g <remote_path> <local_path>

Liststhecontentsofadatastoredirectory. Overwritesthedestinationfile.Usedwith --moveand--copy. DownloadsafilefromtheESX/ESXihostto themachineonwhichyourunvCLI.This operationusesHTTP GET. Liststhedatacenterpathsavailableonan ESX/ESXisystem. ListsthedatastorenamesontheESX/ESXi system.Whenmultipledatacentersare available,usethe--dc (-Z)argumentto specifythenameofthedatacenterfromwhich youwanttolistthedatastore. Createsadirectoryinadatastore.This operationfailsiftheparentdirectoryof dst_datastore_file_pathdoesnotexist. Movesafileinadatastoretoanotherlocation inadatastore.The<source>mustbearemote sourcepath,the<target>aremotetarget pathordirectory. The--forceoptionreplacesexisting destinationfiles.

Datastore Temp Datastore Temp Datastore Host

dir datastore_directory_path copy src_file_path dst_file_path [force] get src_dstore_file_path dst_local_file_path get src_d store_dir_path dst_local_file_path

--listdc -C --listds -S

Datastore Host Datastore Host vifs --listds

--mkdir -M <remote_dir> --move -m <source> <target>

Datastore Temp Datastore Temp

mkdir dst_directory_path

move src_file_path dst_directory_path [force] move src_file_path dst_file_path [force]

--put -p <local_path> <remote_path>

Uploadsafilefromthemachineonwhichyou runvCLItotheESX/ESXihost.Thisoperation usesHTTP PUT. Thiscommandcanreplaceexistinghostfiles butcannotcreatenewfiles.

Datastore Host Temp

put src_local_file_path dst_file_path put src_local_file_path dst_directory_path rm dst_file_path rmdir dst_directory_path

--rm -r <remote_path> --rmdir -R <remote_dir>

Deletesadatastorefile. Deletesadatastoredirectory.Thisoperation failsifthedirectoryisnotempty.

Datastore Temp Datastore Temp

Youcanlistinformationabouttheremotedirectoriesinseveralways.

Listthecurrentdatastores.
vifs <conn_options> --listds.

Thecommandliststhenamesofalldatastoresonthespecifiedserver.Forexample:
osdc-cx700-02 osdc-cx700-03 osdc-cx700-02 osdc-cx700-03 osdc-cx700-04 osdc-cx700-05

Youcanuseeachnamethathasbeenreturnedtorefertodatastorepathsusingsquarebracketnotation, asfollows:
'[my_datastore] dir/subdir/file'

VMware, Inc.

47

vSphere Command-Line Interface Installation and Scripting Guide

Listthecontentsofoneofthedatastores.
vifs <conn_options> --dir '[osdc-cx700-02]'

Thecommandliststhecompletecontentsofthedatastore.

Listthecontentsofonedirectoryinthedatastore.
vifs <conn_options> --dir '[osdc-cx700-02] winxpPro-sp2'

Thecommandliststhedirectorycontent.Inthisexample,thecommandliststhecontentsofavirtual machinedirectory.
Content Listing _________________ vmware-37.log vmware-38.log ... vmware.log ... winxpPro-sp2.vmdk winxpPro-sp2.vmx winxpPro-sp2.vmxf ...

Thefollowingexamplescenarioillustratesotherusesofvifs. To manage files and directories on the remote ESX/ESXi system 1 Createadirectoryinthedatastore.
vifs <conn_options> --mkdir '[osdc-cx700-03] vcli_test'

Youmustspecifytheprecisepath;thereisnoconceptofarelativepath. 2 Placeafilethatisonthesystemfromwhichyouarerunningthecommandsintothenewlycreated directory.


vifs <conn_options> --put /tmp/test_doc '[osdc-cx700-03] vcli_test/test_doc'

Moveafileintoavirtualmachinedirectory.
vifs <conn_options> --move '[osdc-cx700-03] vcli_test/test_doc' '[osdc-cx700-03] winxpPro-sp2/test_doc

Amessageindicatessuccessorfailure. 4 RetrieveoneofthefilesfromtheremoteESX/ESXisystem. Thefollowingexampleretrievesalogfileforanalysis.


vifs <conn_options> --get '[osdc-cx700-03] winxpPro-sp2/vmware.log' ~user1/vmware.log

Cleanupbyremovingthefileanddirectoryyoucreatedearlier.
vifs <conn_options> --rm '[osdc-cx700-03] vcli_test/test_doc' vifs <conn_options> --rmdir '[osdc-cx700-03] vcli_test'

48

VMware, Inc.

Managing Storage

Avirtualmachineusesavirtualdisktostoreitsoperatingsystem,programfiles,andotherdataassociated withitsactivities.Avirtualdiskisalargephysicalfile,orasetoffiles,thatcanbecopied,moved,archived, andbackedup. Tostorevirtualdiskfilesandmanipulatethefiles,ahostrequiresdedicatedstoragespace.ESX/ESXistorage isstoragespaceonavarietyofphysicalstoragesystems,localornetworked,thatahostusestostorevirtual machinedisks. Thischapterincludesthefollowingtopics:


IntroductiontoStorageonpage 49 ExaminingLUNswithvicfgscsidevsonpage 52 ManagingPathswithvicfgmpathonpage 53 ManagingPathPolicieswithesxclionpage 55 MaskingPathswithesxclicorestorageclaimruleonpage 57 ManagingNFS/NASDatastoreswithvicfgnasonpage 58 MigratingVirtualMachineswithsvmotiononpage 59 ManagingDuplicateVMFSDatastoreswithvicfgvolumeonpage 61 RescanningStorageAdapterswithvicfgrescanonpage 63

Chapter 6,ManagingiSCSIStorage,onpage 65discussesiSCSIstoragemanagement.Chapter 9,Managing ThirdPartyStorageArrayswithesxcli,onpage 97explainshowtomanagethePluggableStorage Architecture,includingPathSelectionPlugin(PSP)andStorageArrayTypePlugin(SATP)configuration.

Introduction to Storage
FibreChannelSANarrays,iSCSISANarrays,andNASarraysarewidelyusedstoragetechnologiessupported byVMwarevSpheretomeetdifferentdatacenterstorageneeds.Thestoragearraysareconnectedtoand sharedbetweengroupsofserversthroughstorageareanetworks.Thisarrangementallowsaggregationofthe storageresourcesandprovidesmoreflexibilityinprovisioningthemtovirtualmachines.

VMware, Inc.

49

vSphere Command-Line Interface Installation and Scripting Guide

Figure 5-1. vSphere Datacenter Physical Topology


vCenter Server vSphere Client Web access terminal

server group 1

server group 2

server group 3

virtual machines VM VM VM VM VM VM fibre channel switch fabric / IP network

ESX/ESXi

fibre channel storage array

iSCSI storage array

NAS storage array

How Virtual Machines Access Storage


Avirtualdiskhidesthephysicalstoragelayerfromthevirtualmachinesoperatingsystem.Regardlessofthe typeofstoragedevicethatyourhostuses,thevirtualdiskalwaysappearstothevirtualmachineasamounted SCSIdevice.Asaresult,youcanrunoperatingsystemsthatarenotcertifiedforspecificstorageequipment, suchasSAN,inthevirtualmachine. Whenavirtualmachinecommunicateswithitsvirtualdiskstoredonadatastore,itissuesSCSIcommands. Becausedatastorescanexistonvarioustypesofphysicalstorage,thesecommandsareencapsulatedintoother forms,dependingontheprotocolthattheESX/ESXihostusestoconnecttoastoragedevice. Figure 52depictsfivevirtualmachinesusingdifferenttypesofstoragetoillustratethedifferencesbetween eachtype. Figure 5-2. Virtual Machines Accessing Different Types of Storage
Host requires TCP/IP connectivity virtual machine virtual machine virtual machine virtual machine virtual machine

local ethernet SCSI bre channel HBA SAN iSCSI hardware initiator LAN software initiator ethernet NIC LAN ethernet NIC LAN

VMFS

Key
physical disk

datastore VMFS fibre array VMFS iSCSI array NFS NAS appliance

virtual disk

50

VMware, Inc.

Chapter 5 Managing Storage

YoucanusethevCLIcommandsdiscussedinthismanualtomanagethevirtualmachinefilesystemand storagedevices.

VMFS.Usevmkfstoolstocreate,modify,andmanageVMFSvirtualdisksandrawdevicemappings. SeeManagingtheVirtualMachineFileSystemwithvmkfstoolsonpage 36. Datastores.Severalcommandsallowyoutomanagedatastoresandareusefulformultipleprotocols.

LUNs.Usevicfg-scsidevstodisplayavailableLUNsandmappingsforeachVMFSvolumetoits correspondingpartition.SeeExaminingLUNswithvicfgscsidevsonpage 52. Pathmanagement.Usevicfg-mpathtolistinformationaboutFibreChanneloriSCSILUNsandto changeapathsstate.SeeManagingPathswithvicfgmpathonpage 53.Usetheesxclicommand toviewandmodifypathpolicies.SeeManagingPathPolicieswithesxclionpage 55. Rescan.Usevicfg-rescantoperformarescanoperationeachtimeyoureconfigureyourstorage setup.SeeRescanningStorageAdapterswithvicfgrescanonpage 63.

Storagedevices.Severalcommandsmanageonlyspecificstoragedevices.

NFSstorage.Usevicfg-nastomanageNASstoragedevices.SeeManagingNFS/NASDatastores withvicfgnasonpage 58. iSCSIstorage.Usevicfg-iscsitomanagebothhardwareandsoftwareiSCSI.SeeManaging iSCSIStorageonpage 65.

Datastores
ESX/ESXihostsusestoragespaceonavarietyofphysicalstoragesystems,includinginternalandexternal devicesandnetworkedstorage.Ahostcandiscoverstoragedevicestowhichithasaccessandformatthemas datastores.Eachdatastoreisaspeciallogicalcontainer,analogoustoafilesystemonalogicalvolume,where thehostplacesvirtualdiskfilesandothervirtualmachinefiles.Datastoreshidespecificsofeachstorage productandprovideauniformmodelforstoringvirtualmachinefiles. Dependingonthetypeofstorageyouuse,datastorescanbebackedbythefollowingfilesystemformats:

VirtualMachineFileSystem(VMFS).Highperformancefilesystemoptimizedforstoringvirtual machines.YourhostcandeployaVMFSdatastoreonanySCSIbasedlocalornetworkedstoragedevice, includingFibreChannelandiSCSISANequipment. AsanalternativetousingtheVMFSdatastore,yourvirtualmachinecanhavedirectaccesstorawdevices anduseamappingfile(RDM)asaproxy.SeeManagingtheVirtualMachineFileSystemwith vmkfstoolsonpage 36.

NetworkFileSystem(NFS).FilesystemonaNASstoragedevice.ESX/ESXisupportsNFSversion3over TCP/IP.ThehostcanaccessadesignatedNFSvolumelocatedonanNFSserver,mountthevolume,and useitforanystorageneeds.

Storage Device Naming


Eachstoragedevice,orLUN,isidentifiedbyseveralnames.

Name.AfriendlynamethattheESX/ESXihostassignstoadevicebasedonthestoragetypeand manufacturer,forexample,DGCFibreChannelDisk.ThisnameisvisibleinthevSphereClient. DeviceUID.Auniversallyuniqueidentifierassignedtoadevice.Thetypeofstoragedeterminesthe algorithmusedtocreatetheidentifier.Theidentifierispersistentacrossrebootsandisthesameforall hostssharingthedevice.Theformatisoftennaa.xxxxxxxoreui.xxxxxxxx. VMLName.AlegacySCSIdevicenamespecifictoVMware.UsethedeviceUIDinstead.

Theruntimenameofthefirstpathtothedeviceisapathidentifierandnotareliableidentifierforthedevice. Runtimenamesarecreatedbythehost,andarenotpersistent.Theruntimenamehastheformat vmhba#:C#:T#:L#.YoucanviewtheruntimenameusingthevSphereClient.

VMware, Inc.

51

vSphere Command-Line Interface Installation and Scripting Guide

Examining LUNs with vicfg-scsidevs


ALUN(LogicalUnitNumber)isanidentifierforadiskvolumeinastoragearraytarget.

Target and Device Representation


IntheESX/ESXicontext,thetermtargetidentifiesasinglestorageunitthatahostcanaccess.Thetermsdevice andLUNdescribealogicalvolumethatrepresentsstoragespaceonatarget.ThetermsdeviceandLUNmean aSCSIvolumepresentedtothehostfromastoragetarget. DifferentstoragevendorspresenttheirstoragesystemstoESX/ESXihostsindifferentways.Somevendors presentasingletargetwithmultipleLUNsonit.OthervendorspresentmultipletargetswithoneLUNeach. Figure 5-3. Target and LUN Representations
target LUN LUN LUN target LUN target LUN target LUN

storage array

storage array

InFigure 53,threeLUNsareavailableineachconfiguration.Ontheleft,thehostseesonetarget,butthat targethasthreeLUNsthatcanbeused.EachLUNrepresentsanindividualstoragevolume.Ontheright,the hostseesthreedifferenttargets,eachhavingoneLUN.

Examining LUNs
Usevicfg-scsidevstodisplayinformationaboutavailableLUNsonESX/ESXi 4.xhosts.ForESX/ESXi3.5 systems,thecorrespondingcommandisvicfg-vmhbadevs. IMPORTANTYoucanrunvicfg-scsidevs--queryandvicfg-scsidevs --vmfsagainstESX/ESXiversion 3.5.TheotheroptionsaresupportedonlyagainstESX/ESXiversion4.0andlater. YoucanrunoneofthefollowingcommandstoexamineLUNs.

Listalllogicaldevicesknownonthissystemwithdetailedinformation.
vicfg-scsidevs <conn_options> --list

Thecommandlistsdeviceinformationforalllogicaldevicesonthissystem.Theinformationincludesthe name(UUID),devicetype,displayname,andmultipathingplugin.Specifythe--deviceoptiontoonly listinformationaboutaspecificdevice.HereisasampleoutputfortwodevicesonanESXhost;theactual listingmightincludemultipledevicesandthepreciseformatdiffersbetweenESXandESXihostsand betweenreleases.


mpx.vmhba2:C0:T1:L0 Device Type: cdrom Size: 0 MB Display Name: Local HL-DT-ST (mpx.vmhba2:C0:T1:L0) Plugin: NMP Console Device: /vmfs/devices/cdrom/mpx.vmhba2:C0:T1:L0 Devfs Path: /vmfs/devices/cdrom/mpx.vmhba2:C0:T1:L0 Vendor: SONY Model: DVD-ROM GDRXX8XX Revis: 3.00 SCSI Level: 5 Is Pseudo: Status: Is RDM Capable: Is Removable: Other Names: vml.000N000000XXXdXXXXXXXXaXXXaXX VAAI Status: nnnn naa.60060... Device Type: disk Size: 614400 MB Display Name: DGC Fibre Channel Disk (naa.60060...) ...
52 VMware, Inc.

Chapter 5 Managing Storage

Listalllogicaldeviceswithabbreviatedinformation.
vicfg-scsidevs <conn_options> --compact-list

TheinformationincludesthedeviceID,devicetype,size,plugin,anddevicedisplayname.

Listalldeviceuniqueidentifiers.
vicfg-scsidevs <conn_options> --uids

ThecommandliststheprimaryUIDforeachdevice(naa.xxxorotherprimaryname)andanyotherUIDs foreachUID(VMLname).Youcanspecify--devicetoonlylistinformationforaspecificdevice.

Listaspecificlogicaldevicewithitsdetailedinformation.
vicfg-scsidevs <conn_options> -l -d mpx.vmhba32:C0:T1:L0

PrintmappingsforVMFSvolumestothecorrespondingpartition,pathtothatpartition,VMFSuuid, extentnumber,andvolumenames.
vicfg-scsidevs <conn_options> --vmfs

PrintHBAdeviceswithidentifyinginformation.
vicfg-scsidevs <conn_options> --hbas

ThereturnvalueincludestheadapterID,driverID,adapterUID,PCI,vendor,andmodel.

PrintamappingbetweenHBAsandthedevicesitprovidespathsto.
vicfg-scsidevs <conn_options> --hba-device-list

Managing Paths with vicfg-mpath


TomaintainaconstantconnectionbetweenanESX/ESXihostanditsstorage,ESX/ESXisupportsmultipathing. Multipathingisatechniquethatletsyouusemorethanonephysicalpathfortransferringdatabetweenthe ESX/ESXihostandtheexternalstoragedevice. IncaseoffailureofanelementintheSANnetwork,suchasanHBA,switch,orcable,theESX/ESXihostcan failovertoanotherphysicalpath.Onsomedevices,multipathingalsooffersloadbalancing,which redistributesI/Oloadsbetweenmultiplepathstoreduceoreliminatepotentialbottlenecks. ThestoragearchitectureinvSphere4.0andlatersupportsaspecialVMkernellayer,PluggableStorage Architecture(PSA).ThePSAisanopenmodularframeworkthatcoordinatesthesimultaneousoperationof multiplemultipathingplugins(MPPs).YoucanmanagePSAusingesxclicommands.SeeManaging ThirdPartyStorageArrayswithesxclionpage 97.ThissectionassumesyouareusingonlyPSAplugins includedinvSpherebydefault.

Multipathing with Local Storage and FC SANs


Inasimplemultipathinglocalstoragetopology,youcanuseoneESX/ESXihostwithtwoHBAs.TheESX/ESXi hostconnectstoadualportlocalstoragesystemthroughtwocables.Thisconfigurationensuresfault toleranceifoneoftheconnectionelementsbetweentheESX/ESXihostandthelocalstoragesystemfails. TosupportpathswitchingwithFCSAN,theESX/ESXihosttypicallyhastwoHBAsavailablefromwhichthe storagearraycanbereachedthroughoneormoreswitches.Alternatively,thesetupcanincludeoneHBAand twostorageprocessorssothattheHBAcanuseadifferentpathtoreachthediskarray. InFigure 54,multiplepathsconnecteachhostwiththestoragedevice.Forexample,ifHBA1orthelink betweenHBA1andtheswitchfails,HBA2takesoverandprovidestheconnectionbetweentheserverandthe switch.TheprocessofoneHBAtakingoverforanotheriscalledHBAfailover.

VMware, Inc.

53

vSphere Command-Line Interface Installation and Scripting Guide

Figure 5-4. FC Multipathing


ESX/ESXi ESX/ESXi

HBA2

HBA1

HBA3

HBA4

switch

switch

SP1

SP2

storage array

IfSP1orthelinkbetweenSP1andtheswitchbreaks,SP2takesoverandprovidestheconnectionbetweenthe switchandthestoragedevice.ThisprocessiscalledSPfailover.ESX/ESXimultipathingsupportsHBAandSP failover. Afteryouhavesetupyourhardwaretosupportmultipathing,youcanusethevSphereClientorvCLI commandstolistandmanagepaths.Youcanperformthefollowingtasks.


Listpathinformationwithvicfg-mpath.SeeListingPathInformationonpage 54. Changepathstatewithvicfg-mpath.SeeChangingtheStateofaPathonpage 55. IMPORTANTUsevicfg-mpathforESX/ESXi4.0orlater.Usevicfg-mpath35forESX/ESXi3.5.

Changepathpolicieswithesxcli.SeeSettingPolicyDetailsforDevicesthatUseRoundRobinon page 56. Maskpathswithesxcli.SeeMaskingPathswithesxclicorestorageclaimruleonpage 57. Rescanwithvicfg-rescan.SeeRescanningStorageAdapterswithvicfgrescanonpage 63.

Listing Path Information


Youcanrunvicfg-mpathtolistinformationaboutFibreChanneloriSCSILUNs. IMPORTANTUseindustrystandarddevicenames,withformateui.xxxornaa.xxxtobesureofconsistency. DonotuseVMLLUNnamesunlessdevicenamesarenotavailable. NamesofvirtualmachineHBAsarenotguaranteedtobevalidacrossreboots. Youcandisplayinformationaboutpathsbyrunningvicfg-mpathwithoneofthefollowingoptions:

Listalldeviceswiththeircorrespondingpaths,stateofthepath,adaptertype,andotherinformation.
vicfg-mpath <conn_options> --list-paths

Displayashortlistingofallpaths.
vicfg-mpath <conn_options> --list-compact

Listallpathswithadapteranddevicemappings.
vicfg-mpath <conn_options> --list-map

54

VMware, Inc.

Chapter 5 Managing Storage

ListpathsanddetailedinformationbyspecifyingthepathUID(longpath).ThepathUIDisthefirstitem inthevicfg-mpath --listdisplay.


vicfg-mpath <conn_options> --list -P sas.5001c231c79c4a00-sas.1221000001000000-naa.5000c5000289c61b

Listpathsanddetailedinformationbyspecifyingthepathruntimename.
vicfg-mpath <conn_options> -l -P vmhba32:C0:T0:L0

Thereturninformationincludestheruntimename,device,devicedisplayname,adapter,adapter identifier,targetidentifier,plugin,state,transport,andadapterandtargettransportdetails.

Listdetailedinformationforthepathsforthedevicespecifiedwith--device.
vicfg-mpath <conn_options> -l -d mpx.vmhba32:C0:T1:L0 vicfg-mpath <conn_options> --list --device naa.60060...

Changing the State of a Path


Youcantemporarilydisablepathsformaintenanceorotherreasons,andenablethepathwhenyouneedit again. To disable a path 1 (Optional)Listalldevicesandcorrespondingpaths.
vicfg-mpath <conn_options> --list-paths

Thedisplayincludesinformationabouteachpathsstate. 2 SetthestateofaLUNpathtooff.
vicfg-mpath <conn_options> --state off --path vmhba32:C0:T1:L0

Ifyouarechangingapathsstate:

ThechangeoperationfailsifI/Oisactivewhenthepathsettingischanged.Reissuethecommand. YoumustissueatleastoneI/Ooperationbeforethechangetakeseffect.

Whenyouareready,setthepathstatetoactiveagain.
vicfg-mpath <conn_options> --state active --path vmhba32:C0:T1:L0

Managing Path Policies with esxcli


ForeachstoragedevicemanagedbyNMP(notPowerPath),anESX/ESXihostusesapathselectionpolicy.By default,VMwaresupportsthefollowingpathselectionpolicies.IfyouhaveathirdpartyPSPinstalledonyour host,itspolicyalsoappearsonthelist.Thefollowingpathpoliciesaresupportedbydefault: Table 5-1. Supported Path Policies
Policy VMW_PSP_FIXED Description Thehostalwaysusesthepreferredpathtothediskwhenthatpathisavailable.Ifthehost cannotaccessthediskthroughthepreferredpath,ittriesthealternativepaths.Ifyouusethe VMW_PSP_FIXEDpolicy,useesxcli nmp fixedtosetorgetthepreferredpath ExtendstheVMW_PSP_FIXEDfunctionalitytoactivepassiveandALUAmodearrays. Thehostusesapathtothediskuntilthepathbecomesunavailable.Whenthepathbecomes unavailable,thehostselectsoneofthealternativepaths.Thehostdoesnotrevertbacktothe originalpathwhenthatpathbecomesavailableagain.Thereisnopreferredpathsettingwith theMRUpolicy.MRUisthedefaultpolicyforactivepassivestoragedevicesandisrequired forthosedevices. Thehostusesanautomaticpathselectionalgorithmrotatingthroughallavailablepaths.This algorithmimplementsloadbalancingacrossalltheavailablephysicalpaths.Loadbalancing istheprocessofspreadingserverI/Orequestsacrossallavailablehostpaths.Thegoalisto optimizeperformanceintermsofthroughput(I/Opersecond,megabytespersecond,or responsetimes).

VMW_PSP_FIXED_AP VMW_PSP_MRU

VMW_PSP_RR

VMware, Inc.

55

vSphere Command-Line Interface Installation and Scripting Guide

Thetypeofarrayandthepathpolicydeterminethebehaviorofthehost,asshowninTable 52. Table 5-2. Path Policy Effects


Policy MostRecentlyUsed Fixed Active/Active Array Administratoractionisrequiredtofail backafterpathfailure. VMkernelresumesusingthepreferred pathwhenconnectivityisrestored. Active/Passive Array Administratoractionisrequiredtofailback afterpathfailure. VMkernelattemptstoresumeusingthe preferredpath.Thiscancausepath thrashingorfailurewhenanotherSPnow ownstheLUN. Nextpathinroundrobinschedulingis selected.

RoundRobin

Nofailback.

To change the path policy 1 Listallmultipathingpluginsloadedintothesystem.


vicfg-mpath <conn_options> --list-plugins

Ataminimum,thiscommandreturnsNMP(NativeMultipathingPlugin)andMASK_PATH.IfotherMPP pluginshavebeenloaded,theyarelistedaswell. 2 Setthepathpolicyusingesxcli.


esxcli <conn_options> nmp device setpolicy --device naa.xxx --psp VMW_PSP_RR

SeeTable 51. 3 (Optional)IfyouspecifiedtheVMW_PSP_FIXEDpolicy,youmustmakesurethepreferredpathisset correctly. a Firstcheckwhichpathisthepreferredpathforadevice.


esxcli <conn_options> nmp fixed getpreferred --device naa.xxx

Ifnecessary,changethepreferredpath.
esxcli <conn_options> nmp fixed setpreferred --device naa.xxx --path vmhba3:C0:T5:L3

Thecommandsetsthepreferredpathtovmhba3:C0:T5:L3

Setting Policy Details for Devices that Use Round Robin


ESX/ESXihostscanusemultipathingforfailover.Withcertainstoragedevices,ESX/ESXihostscanalsouse multipathingforloadbalancing.Toachievebetterloadbalancingacrosspaths,administratorscanspecifythat theESX/ESXihostshouldswitchpathsundercertaincircumstances.Differentsettableoptionsdetermine whentheESX/ESXihostswitchespathsandwhatpathsarechosen. Youcanuseesxcli nmp roundrobintoretrieveandsetroundrobinpathoptionsonadevicecontrolledby theroundrobinPSP. IMPORTANTOnlyalimitednumberofstoragearrayssupportroundrobin.

56

VMware, Inc.

Chapter 5 Managing Storage

To view and manipulate round robin path selection settings 1 RetrievepathselectionsettingsforadevicethatisusingtheroundrobinPSP.


esxcli <conn_options> nmp roundrobin getconfig --device na.xxx

Setthepathselection.Youcanspecifywhenthepathshouldchange,andwhetherunoptimizedpaths shouldbeincluded.

Use--bytesor--iopstospecifywhenthepathshouldchange,asinthefollowingexamples:
esxcli <conn_options> nmp roundrobin setconfig --type "bytes" -B 12345 --device naa.xxx

Setsthedevicespecifiedby--devicetoswitchtothenextpatheachtime12345byteshavebeensent alongthecurrentpath.
esxcli <conn_options> nmp roundrobin setconfig --type=iops --iops 4200 --device naa.xxx

Thecommandsetsthedevicespecifiedby--devicetoswitchafter4200I/Ooperationshavebeen performedonapath.

UseuseANOtospecifythattheroundrobinPSPshouldincludepathsintheactive,unoptimizedstate intheroundrobinset(1)orthatthePSPshoulduseactive,unoptimizedpathsonlyifnoactive optimizedpathsareavailable(0).Ifyoudonotincludethisoption,thePSPincludesonlyactive optimizedpathsintheroundrobinpathset.

Masking Paths with esxcli corestorage claimrule


WithESX/ESXi4.0andlater,youusetheMASK_PATHplugininsteadofanadvancedconfigurationoptionto maskpaths. IMPORTANTToconvertESX/ESXi3.5LUNmaskstoclaimruleformat,youmightbeabletouseesxcli corestorage claimrule convert.SeeConvertingESX3.5LUNMaskstoClaimRuleFormatonpage 107. To mask paths 1 Runesxcli corestorage claimrule listtodeterminethenextavailableruleID. UserruleIDsstartat101.Ifthiscommandshowsthatrule101and102alreadyexist,youcanspecify103 fortheruletoadd. Theclaimrulesareevaluatedinnumericalorderstartingfrom0.

Rules0100arereservedforinternalusebyVMware. Rules10165435areavailableforgeneraluse.Anythirdpartymultipathingpluginsinstalledonyour systemuseclaimrulesinthisrange. Rules6543665535arereservedforinternalusebyVMware.

DecidewhichruleIDtouse. Whenaddingordeletingclaimrules,besuretoworkwithrulesinthecorrectnumericrange.Whenyou addaMASK_PATHclaimrule,choosearulewitharuleIDlowerthantheruleIDthatcausesNMPorsome othermultipathingplugintoclaimthepath.

AddtheMASK_PATHplugintotheclaimrulewiththeIDyoudecidedtouse.
esxcli <conn_options> corestorage claimrule add --plugin MASK_PATH --rule <ruleID> --type <type> -A <adapter>

Verifythattheclaimrulewasaddedcorrectly.
esxcli <conn_options> corestorage claimrule list

Loadthepathclaimingrules.
esxcli <conn_options> corestorage claimrule load

VMware, Inc.

57

vSphere Command-Line Interface Installation and Scripting Guide

Releasethedevicefromthecurrentpluginsothatitcanbeclaimedbyanotherrule.Forexample,you mightrunthefollowingcommandforeachpath:
esxcli <conn_options> corestorage claiming unclaim -t location -A vmhba0 -C 0 -T 0 -L 149

Runthepathclaimingrules,whichincludethenewlyaddedrules.
esxcli <conn_options> corestorage claimrule run

To unmask a path 1 DeletetheMASK_PATHclaimrule.


esxcli <conn_options> corestorage claimrule delete -r <rule#>

Verifythattheclaimrulewasdeletedcorrectly.
esxcli <conn_options> corestorage claimrule list

ReloadthepathclaimingrulesfromtheconfigurationfileintotheVMkernel.
esxcli <conn_options> corestorage claimrule load

Runesxcli corestorage claiming unclaimforeachpathtothemaskeddevice,forexample:


esxcli <conn_options> corestorage claiming unclaim -t location -A vmhba0 -C 0 -T 0 -L 149

Runthepathclaimingrules.
esxcli <conn_options> corestorage claimrule run

Managing NFS/NAS Datastores with vicfg-nas


ESX/ESXihostscanaccessadesignatedNFSvolumelocatedonaNAS(NetworkAttachedStorage)server,can mountthevolume,andcanuseitforitsstorageneeds.YoucanuseNFSvolumestostoreandbootvirtual machinesinthesamewaythatyouuseVMFSdatastores.

Capabilities Supported by NFS/NAS


ESX/ESXihostssupportthefollowingsharedstoragecapabilitiesonNFSvolumes:

VMwareVMotion VMwareDRSandVMwareHA ISOimages,whicharepresentedasCDROMstovirtualmachines Virtualmachinesnapshots

NASstoresvirtualmachinefilesonremotefileserversthatareaccessedoverastandardTCP/IPnetwork.The NFSclientbuiltintotheESX/ESXisystemusesNFSversion3tocommunicatewithNAS/NFSservers.For networkconnectivity,thehostrequiresastandardnetworkadapter. InadditiontostoringvirtualdisksonNFSdatastores,youcanalsouseNFSasacentralrepositoryforISO images,virtualmachinetemplates,andsoon. TouseNFSasasharedrepository,youcreateadirectoryontheNFSserverandthenmountthedirectoryasa datastoreonallhosts.IfyouusethedatastoreforISOimages,youcanconnectthevirtualmachinesCDROM devicetoanISOfileonthedatastoreandinstallaguestoperatingsystemfromtheISOfile.

58

VMware, Inc.

Chapter 5 Managing Storage

Adding and Deleting NAS File Systems


Thefollowingscenarioillustrateshowtolist,add,anddeleteaNASfilesystemwithvicfg-nas. To manage a NAS file system 1 ListallknownNASfilesystems.
vicfg-nas <conn_options> -l

ForeachNASfilesystem,thecommandliststhemountname,sharename,andhostnameandwhether thefilesystemismounted.IfnoNASfilesystemsareavailable,thesystemreturnsthefollowing:
No NAS datastore found

AddanewNASfilesystemtotheESX/ESXihost.
vicfg-nas <conn_options --add nfsstore-dir42

--nasserver dir42.eng.vmware.com -s /<mount_dir>

ThiscommandaddsanentrytotheknownNASfilesystemlistandsuppliesthesharenameofthenew NASfilesystem.YoumustsupplythehostnameandthesharenameforthenewNASfilesystem. 3 AddasecondNASfilesystemwithreadonlyaccess.


vicfg-nas <conn_options> -a -y --n esx42nas2 -s /home FileServerHome2

DeleteoneoftheNASfilesystems.
vicfg-nas <conn_options> -d FileServerHome1

ThiscommandunmountstheNASfilesystemandremovesitfromthelistofknownfilesystems.

Migrating Virtual Machines with svmotion


Thesvmotioncommandmovesavirtualmachinesconfigurationfile,and,optionally,itsdisks,whilethe virtualmachineisrunning. Youcanplacethevirtualmachineandallofitsdisksinasinglelocation,orchooseseparatelocationsforthe virtualmachineconfigurationfileandeachvirtualdisk.Youcannotchangethevirtualmachinesexecution hostduringamigrationwithsvmotion.

Storage VMotion Uses


StorageVMotionhasseveralusesinadministeringyourvSphereenvironment.

UpgradeESX/ESXiwithoutvirtualmachinedowntime.DuringanupgradefromESXServer2.xto ESX/ESXi3.5orlater,youcanmigraterunningvirtualmachinesfromaVMFS2datastoretoaVMFS3 datastore,andupgradetheVMFS2datastorewithnoimpactonvirtualmachines.Youcanthenuse StorageVMotiontomigratevirtualmachinesbacktotheoriginaldatastorewithnovirtualmachine downtime. Performstoragemaintenanceandreconfiguration.YoucanuseStorageVMotiontomovevirtual machinesoffastoragedevicetoallowmaintenanceorreconfigurationofthestoragedevicewithout virtualmachinedowntime. Redistributestorageload.YoucanuseStorageVMotiontomanuallyredistributevirtualmachinesor virtualdiskstodifferentstoragevolumestobalancecapacityorimproveperformance.

VMware, Inc.

59

vSphere Command-Line Interface Installation and Scripting Guide

Storage VMotion Requirements and Limitations


YoucanmigratevirtualmachinediskswithStorageVMotionifthevirtualmachineanditshostmeetthe followingresourceandconfigurationrequirements:

Thevirtualmachinecannothavesnapshots. Virtualmachinedisksmustbeinpersistentmodeorberawdevicemappings(RDMs).Forphysicaland virtualcompatibilitymodeRDMs,youcanmigratethemappingfileonly.Forvirtualcompatibilitymode RDMs,youcanusethevSphereClienttoconverttothickprovisionedorthinprovisioneddisksduring migrationaslongasthedestinationisnotanNFSdatastore.Youcannotusethesvmotioncommandto performthisconversion. ThehostonwhichthevirtualmachineisrunningmusthavealicensethatincludesStorageVMotion. ESX/ESXi3.5hostsmustbelicensedandconfiguredforVMotion.ESX/ESXi4.0andlaterhostsdonot requireVMotionconfigurationtoperformmigrationwithStorageVMotion. Thehostonwhichthevirtualmachineisrunningmusthaveaccesstoboththesourceandtarget datastores. AparticularhostcanbeinvolvedinuptotwomigrationswithVMotionorStorageVMotionatonetime. vSpheresupportsamaximumofeightsimultaneousVMotion,cloning,deployment,orStorageVMotion accessestoasingleVMFS3datastore,andamaximumoffoursimultaneousVMotion,cloning, deployment,orStorageVMotionaccessestoasingleNFSorVMFS2datastore.AmigrationwithVMotion involvesoneaccesstothedatastore.AmigrationwithStorageVMotioninvolvesoneaccesstothesource datastoreandoneaccesstothedestinationdatastore.

IfyouusethevSphereClientformigrationwithsvmotion,thesystemperformsanumberofcompatibility checks.ThesechecksarenotsupportedbythesvmotionvCLI.

Running svmotion in Interactive Mode


Youcanrunsvmotionininteractivemodeusingthe--interactiveoption.Thecommandpromptsyoufor theinformationitneedstocompletethestoragemigration.
svmotion <conn_options> --interactive

Whenyouuse--interactive,allotheroptionsareignored. IMPORTANTWhenrespondingtotheprompts,usequotesaroundinputstringswithspecialcharacterson Windows.

Running svmotion in Noninteractive Mode


IMPORTANTWhenyourunsvmotion,--servermustpointtoavCenterServersystem. Innoninteractivemode,thesvmotioncommandusesthefollowingsyntax:
svmotion [standard vCLI options] --datacenter=<datacenter_name> --vm <VM config datastore path>:<new datastore> [--disks <virtual disk datastore path>:<new datastore>, <virtual disk datastore path>:<new datastore>]

Squarebracketsindicateoptionalelements,notdatastores. The--vmoptionspecifiesthevirtualmachineanditsdestination.Bydefault,allvirtualdisksarerelocatedto thesamedatastoreasthevirtualmachine.Thisoptionrequiresthecurrentvirtualmachineconfigurationfile location.SeeTodeterminethepathtothevirtualmachineconfigurationfileanddiskfileonpage 61. The--disksoptionrelocatesindividualvirtualdiskstodifferentdatastores.The--disksoptionrequiresthe currentvirtualdiskdatastorepathasanoption.SeeTodeterminethepathtothevirtualmachine configurationfileanddiskfileonpage 61.

60

VMware, Inc.

Chapter 5 Managing Storage

To determine the path to the virtual machine configuration file and disk file 1 Runvmware-cmd -ltolistallvirtualmachineconfigurationfiles(VMXfiles).
vmware-cmd -H <vc_server> -U <login_user> -P <login_password> -h <esx_host> -l

ChoosetheVMXfileforthevirtualmachineofinterest. Bydefault,thevirtualdiskfilehasthesamenameastheVMXfilebuthasa.vmdkextension.

(Optional)UsevifstoverifythatyouareusingthecorrectVMDKfile.

To relocate a virtual machines storage (including disks) 1 2 Determinethepathtothevirtualmachineconfigurationfile. Runsvmotion,forexample:


svmotion --url=https://myvc.mycorp.com/sdk --datacenter=DC1 --vm=[storage1] myvm/myvm.vmx:new_datastore

TheexampleisforWindows.UsesinglequotesonLinux. To relocate a virtual machines configuration file, but leave virtual disks 1 2 Determinethepathtothevirtualdiskfilesandthevirtualmachineconfigurationfile. Runsvmotion,forexample:
svmotion <conn_options> --datacenter='My DC' --vm='[old_datastore] myvm/myvm.vmx:new_datastore' --disks='[old_datastore] myvm/myvm_1.vmdk:old_datastore, [old_datastore] myvm/myvm_2.vmdk: old_datastore'

Thiscommandrelocatesthevirtualmachinesconfigurationfiletonew_datastore,butleavesthetwodisks (myvm_1.vmdkandmyvm_2.vmdk)inold_datastore.TheexampleisforLinux.Usedoublequoteson Windows.Thesquarebracketssurroundthedatastorenameanddonotindicateanoptionalelement.

Managing Duplicate VMFS Datastores with vicfg-volume


EachVMFSdatastorecreatedinaLUNhasauniqueUUIDthatisstoredinthefilesystemsuperblock.When theLUNisreplicatedorasnapshotmade,theresultingLUNcopyisidentical,byteforbyte,totheoriginal LUN.Asaresult,iftheoriginalLUNcontainsaVMFSdatastorewithUUIDX,theLUNcopyappearsto containanidenticalVMFSdatastore,oraVMFSdatastorecopy,withthesameUUIDX. ESX/ESXihostscandeterminewhetheraLUNcontainstheVMFSdatastorecopy,andeithermountthe datastorecopywithitsoriginalUUIDorchangetheUUIDtoresignaturethedatastore. WhenaLUNcontainsaVMFSdatastorecopy,youcanmountthedatastorewiththeexistingsignatureor assignanewsignature.TheESXConfigurationGuideandtheESXiConfigurationGuidediscussvolume resignaturingindetail.

Mounting Datastores with Existing Signatures


YoucanmountaVMFSdatastorecopywithoutchangingitssignatureiftheoriginalisnotmounted.For example,youcanmaintainsynchronizedcopiesofvirtualmachinesatasecondarysiteaspartofadisaster recoveryplan.Intheeventofadisasterattheprimarysite,youcanmountthedatastorecopyandpoweron thevirtualmachinesatthesecondarysite. IMPORTANTYoucanmountaVMFSdatastoreonlyifitdoesnotconflictwithanalreadymountedVMFS datastorethathasthesameUUID.

VMware, Inc.

61

vSphere Command-Line Interface Installation and Scripting Guide

WhenyoumounttheVMFSdatastore,ESX/ESXiallowsbothreadandwriteoperationstothedatastore residingontheLUNcopy.TheLUNcopymustbewritable.Thedatastoremountsarepersistentandvalid acrosssystemreboots.BecauseESX/ESXipreventsyoufromresignaturingthemounteddatastore,unmount thedatastorebeforeresignaturing. To mount a datastore 1 Listallvolumesthathavebeendetectedassnapshotsorreplicas.


vicfg-volume <conn_options> --list

Runvicfg-volume --persistent-mount withtheVMFSUUIDorlabelasanargumenttomounta volume.


vicfg-volume <conn_options> --persistent-mount <VMFS-UUID|label>

Thiscommandfailsiftheoriginalcopyisonline. Youcanlaterrunvicfg-volume --unmounttounmountthesnapshotorreplicavolume.


vicfg-volume <conn_options> --unmount <VMFS-UUID|label>

Thevicfg-volumecommandsupportsresignaturingasnapshotvolumeandmountingandunmountingthe volume.Youcanalsomakethemountedvolumepersistentacrossrebootsandqueryalistofsnapshot volumesandoriginalvolumes.

Resignaturing VMFS Copies


UsedatastoreresignaturingtoretainthedatastoredontheVMFSdatastorecopy.WhenresignaturingaVMFS copy,theESX/ESXihostassignsanewUUIDandanewlabeltothecopy,andmountsthecopyasadatastore distinctfromtheoriginal. Thedefaultformatofthenewlabelassignedtothedatastoreissnap<snapID><oldLabel>,where<snapID> isanintegerand<oldLabel>isthelabeloftheoriginaldatastore. Whenyouperformdatastoreresignaturing,considerthefollowingpoints:

Datastoreresignaturingisirreversible. TheLUNcopythatcontainstheVMFSdatastorethatyouresignatureisnolongertreatedasaLUNcopy. Aspanneddatastorecanberesignaturedonlyifallitsextentsareonline. Theresignaturingprocessiscrashandfaulttolerant.Iftheprocessisinterrupted,youcanresumeitlater. YoucanmountthenewVMFSdatastorewithoutariskofitsUUIDconflictingwithUUIDsofanyother datastore,suchasanancestororchildinahierarchyofLUNsnapshots.

To resignature a VMFS copy 1 2 Makesurethecopyisnotmounted. Runvicfg-volumewiththeresignatureoption.


vicfg-volume <conn_options> --resignature <VMFS-UUID|label>

Thecommandreturnstothepromptorsignalsanerror. Afterresignaturing,youmighthavetodothefollowing:

Iftheresignatureddatastorecontainsvirtualmachines,updatereferencestotheoriginalVMFSdatastore inthevirtualmachinefiles,including.vmx,.vmdk,.vmsd,and.vmsn. Topoweronvirtualmachines,registerthemwiththevCenterServersystem.

62

VMware, Inc.

Chapter 5 Managing Storage

Rescanning Storage Adapters with vicfg-rescan


Youmustperformarescanoperationeachtimeyoureconfigureyourstoragesetup.Youcanrescanusingthe vSphereClientorthevicfg-resanvCLIcommand.Thecommandrequiresthatyouspecifytheadapterfor whichyouwanttorescantheLUNs. To rescan a storage adapter Runvicfg-rescan,specifyingtheadaptername.
vicfg-rescan <conn_options> vmhba1

Thecommandreturnsanindicationofsuccessorfailure,butnodetailedinformation.

VMware, Inc.

63

vSphere Command-Line Interface Installation and Scripting Guide

64

VMware, Inc.

Managing iSCSI Storage

ESX/ESXisystemsincludeiSCSItechnologytoaccessremotestorageusinganIPnetwork.Youcanusethe vSphereClientorthevicfg-iscsivCLIcommandtoconfigurebothhardwareandsoftwareiSCSIstorage foryourESX/ESXisystem. Thischapterincludesthefollowingtopics:


iSCSIStorageOverviewonpage 65 ProtectinganiSCSISANonpage 67 iSCSIStorageSetuponpage 69 vicfgiscsiCommandSyntaxonpage 73 ListingandSettingiSCSIOptionsonpage 77 ListingandSettingiSCSIParametersonpage 77 EnablingiSCSIAuthenticationonpage 79 SettingUpPortsforiSCSIMultipathingonpage 80 ManagingiSCSISessionsonpage 80

Chapter 5,ManagingStorage,onpage 49discussesotherstoragecommands.Chapter 9,Managing ThirdPartyStorageArrayswithesxcli,onpage 97explainshowtomanagethePluggableStorage Architecture,includingPathSelectionPlugin(PSP)andStorageArrayTypePlugin(SATP)configuration.See theiSCSISANConfigurationGuideforadetaileddiscussionofiSCSIsetup.

iSCSI Storage Overview


WithiSCSI,SCSIstoragecommandsthatyourvirtualmachineissuestoitsvirtualdiskareconvertedinto TCP/IPprotocolpacketsandtransmittedtoaremotedevice,ortarget,onwhichthevirtualdiskislocated. Fromthepointofviewofthevirtualmachine,thedeviceappearsasalocallyattachedSCSIdrive. Toaccessremotetargets,thehostusesiSCSIinitiators.InitiatorstransportSCSIrequestsandresponses betweenthehostandthetargetstoragedeviceontheIPnetwork.ESX/ESXisupportsthesetypesofinitiators:

SoftwareiSCSIadapter.VMwarecodebuiltintotheVMkernel.AllowsanESX/ESXihosttoconnectto theiSCSIstoragedevicethroughstandardnetworkadapters.ThesoftwareinitiatorhandlesiSCSI processingwhilecommunicatingwiththenetworkadapter. HardwareiSCSIadapter.OffloadsalliSCSIandnetworkprocessingfromyourhost.HardwareiSCSI adapterarebrokenintotwotypes.

DependenthardwareiSCSIadapter.LeveragestheVMwareiSCSImanagementandconfiguration interfaces. IndependenthardwareiSCSIadapter.LeveragesitsowniSCSImanagementandconfiguration interfaces.

VMware, Inc.

65

vSphere Command-Line Interface Installation and Scripting Guide

SeetheiSCSISANConfigurationGuidefordetailsonsetupandfailoverscenarios. YoumustconfigureiSCSIinitiatorsforthehosttoaccessanddisplayiSCSIstoragedevices. Figure 6-1. iSCSI Storage


hardware iSCSI host 1 software adapter HBA2 HBA1 NIC2 NIC1 software iSCSI host 2

IP network

SP

iSCSI storage

Figure 61depictstohoststhatusedifferenttypesofiSCSIinitiators.

ThehostontheleftusesanindependenthardwareiSCSIadaptertoconnecttotheiSCSIstoragesystem. ThehostontherightusesathirdpartyEthernetNICwithiSCSIoffloadcapabilities.

iSCSIstoragedevicesfromthestoragesystembecomeavailabletothehost.Youcanaccessthestoragedevices andcreateVMFSdatastoresforyourstorageneeds.

Discovery Sessions
AdiscoverysessionispartoftheiSCSIprotocol.Thediscoverysessionreturnsthesetoftargetsthatyoucan accessonaniSCSIstoragesystem.ESX/ESXisystemssupportdynamicandstaticdiscovery.

Dynamicdiscovery.AlsoknownasSendTargetsdiscovery.EachtimetheESX/ESXihostcontactsa specifiediSCSIserver,itsendsaSendTargetsrequesttotheserver.Inresponse,theiSCSIserversupplies alistofavailabletargetstotheESX/ESXihost. Staticdiscovery.TheESX/ESXihostdoesnothavetoperformdiscovery.Instead,theESX/ESXihostuses theIPaddressesordomainnamesandiSCSItargetnames(IQNorEUIformatnames)tocommunicate withtheiSCSItarget.

Thevicfg-iscsi-Dand-Soptionsmonitorandmanagetargetdiscoveryaddresses.Youcanalsousethe vSphereClienttoperformthesametask. Foreithercase,yousetuptargetdiscoveryaddressessothattheinitiatorcandeterminewhichstorage resourceonthenetworkisavailableforaccess.Youcandothissetupwithdynamicdiscoveryorstatic discovery.Withdynamicdiscovery,alltargetsassociatedwithanIPaddressorhostnameandtheiSCSIname arediscovered.Withstaticdiscovery,youmustspecifytheIPaddressorhostnameandtheiSCSInameofthe targetyouwanttoaccess.TheiSCSIHBAmustbeinthesameVLANasbothportsoftheiSCSIarray.

66

VMware, Inc.

Chapter 6 Managing iSCSI Storage

Discovery Target Names


ThetargetnameiseitheranIQNnameoranEUIname.

TheIQNnameusesthefollowingformat:
iqn.yyyy-mm.{reversed domain name}:id_string

Forexample:iqn.2007-05.com.mydomain:storage.tape.sys3.abc TheESX/ESXihostgeneratesanIQNnameforsoftwareiSCSIanddependenthardwareiSCSIadapters. YoucanchangethatdefaultIQNname.

TheEUInameisdescribedinIETFrfc3720asfollows: TheIEEERegistrationAuthorityprovidesaserviceforassigninggloballyuniqueidentifiers[EUI].The EUI64formatisusedtobuildaglobalidentifierinothernetworkprotocols.Forexample,FibreChannel definesamethodofencodingitintoaWorldWideName. Theformatiseui.followedbyanEUI64identifier(16ASCIIencodedhexadecimaldigits). Forexample:


Type EUI-64 identifier (ASCII-encoded hexadecimal) +--++--------------+ | || | eui.02004567A425678D

TheIEEEEUI64iSCSInameformatcanbeusedwhenamanufacturerisregisteredwiththeIEEE RegistrationAuthorityandusesEUI64formattedworldwideuniquenamesforitsproducts. CheckintheUIofthestoragearraywhetheranarrayusesanIQNnameoranEUIname.

Protecting an iSCSI SAN


WhenyouplanyouriSCSIconfiguration,takemeasurestoimprovetheoverallsecurityoftheiSCSISAN.Your iSCSIconfigurationisonlyassecureasyourIPnetwork.Byenforcinggoodsecuritystandardswhenyouset upyournetwork,youhelpsafeguardyouriSCSIstorage.

Protecting Transmitted Data


AprimarysecurityriskiniSCSISANsisthatanattackermightsnifftransmittedstoragedata.Neitherthe iSCSIadapternortheESX/ESXihostiSCSIinitiatorencryptsthedatathatittransmitstoandfromthetargets, makingthedatavulnerabletosniffingattacks.Youmustthereforetakeadditionalmeasurestoprevent attackersfromeasilyseeingiSCSIdata. AllowingyourvirtualmachinestosharevirtualswitchesandVLANswithyouriSCSIconfiguration potentiallyexposesiSCSItraffictomisusebyavirtualmachineattacker.Tohelpensurethatintruderscannot listentoiSCSItransmissions,makesurethatnoneofyourvirtualmachinescanseetheiSCSIstoragenetwork. ProtectyoursystembygivingtheiSCSISANadedicatedvirtualswitch.

IfyouuseanindependenthardwareiSCSIadapter,makesurethattheiSCSIadapterandESX/ESXi physicalnetworkadapterarenotinadvertentlyconnectedoutsidethehost.Suchaconnectionmight resultfromsharingaswitch. IfyouconfigureiSCSIdirectlythroughtheESX/ESXihost,configureiSCSIstoragethroughadifferent virtualswitchthantheoneusedbyyourvirtualmachines.

YoucanalsoconfigureyouriSCSISANonitsownVLANtoimproveperformanceandsecurity.Placingyour iSCSIconfigurationonaseparateVLANensuresthatnodevicesotherthantheiSCSIadaptercansee transmissionswithintheiSCSISAN.WithadedicatedVLAN,networkcongestionfromothersourcescannot interferewithiSCSItraffic.

VMware, Inc.

67

vSphere Command-Line Interface Installation and Scripting Guide

Securing iSCSI Ports


WhenyouruniSCSIdevices,theESX/ESXihostdoesnotopenportsthatlistenfornetworkconnections.This measurereducesthechancesthatanintrudercanbreakintotheESX/ESXihostthroughspareportsandgain controloverthehost.Therefore,runningiSCSIdoesnotpresentanadditionalsecurityrisksattheESX/ESXi hostendoftheconnection. AniSCSItargetdevicemusthaveoneormoreopenTCPportstolistenforiSCSIconnections.Ifsecurity vulnerabilitiesexistintheiSCSIdevicesoftware,yourdatacanbeatriskthroughnofaultoftheESX/ESXi system.Tolowerthisrisk,installallsecuritypatchesthatyourstorageequipmentmanufacturerprovidesand limitthedevicesconnectedtotheiSCSInetwork.

Setting iSCSI CHAP


iSCSIstoragesystemsauthenticateaninitiatorusinganameandkeypair.ESX/ESXisystemssupport ChallengeHandshakeAuthenticationProtocol(CHAP),whichVMwarerecommendsforyourSAN implementation.TheESX/ESXihostandtheiSCSIstoragesystemmusthaveCHAPenabledandmusthave commoncredentials.DuringiSCSIlogin,theiSCSIstoragesystemexchangesitscredentialswiththeESX/ESXi systemandchecksthem. YoucansetupiSCSIauthenticationusingthevSphereClient,asdiscussedintheiSCSISANConfiguration Guideorusingthevicfg-iscsicommand,discussedinEnablingiSCSIAuthenticationonpage 79.Touse CHAPauthentication,youmustenableCHAPonboththeinitiatorsideandthestoragesystemside.After authenticationisenabled,itappliesfortargetstowhichnoconnectionhasbeenestablished,butdoesnotapply totargetstowhichaconnectionisestablished.Afterthediscoveryaddressisset,thenewvolumestowhich youaddaconnectionareexposedandcanbeused. ForsoftwareiSCSIanddependenthardwareiSCSI,ESX/ESXihostssupportperdiscoveryandpertarget CHAPcredentials.ForindependenthardwareiSCSI,ESX/ESXihostssupportonlyonesetofCHAP credentialsperinitiator.YoucannotassigndifferentCHAPcredentialsfordifferenttargets. WhenyouconfigureindependenthardwareiSCSIinitiators,ensurethattheCHAPconfigurationmatches youriSCSIstorage.IfCHAPisenabledonthestoragearray,itmustbeenabledontheinitiator.IfCHAPis enabled,youmustsetuptheCHAPauthenticationcredentialsontheESX/ESXihosttomatchthecredentials ontheiSCSIstorage. Supported CHAP Levels TosetCHAPlevelswithvicfg-iscsi,specifyoneofthevaluesinTable 61for<level>.Onlytwolevelsare supportedforindependenthardwareiSCSI. Table 6-1. Supported Levels for CHAP
Level chapProhibited Description HostdoesnotuseCHAPauthentication.If authenticationisenabled,specify chapProhibitedtodisableit. HostusesanonCHAPconnection,butallowsa CHAPconnectionasfallback. HostusesCHAPiftheCHAPconnection succeeds,butusesnonCHAPconnectionsas fallback. HostrequiressuccessfulCHAPauthentication. TheconnectionfailsifCHAPnegotiationfails. vSphere Client text DonotuseCHAP Supported SoftwareiSCSI IndependenthardwareiSCSI DependenthardwareiSCSI DonotuseCHAPunless requiredbytarget UseCHAPunless prohibitedbytarget SoftwareiSCSI DependenthardwareiSCSI SoftwareiSCSI IndependenthardwareiSCSI DependenthardwareiSCSI UseCHAP SoftwareiSCSI DependenthardwareiSCSI

chapDiscouraged

chapPreferred

chapRequired

MutualCHAPissupportedforsoftwareiSCSIandfordependenthardwareiSCSI,butnotforindependent hardwareiSCSI. IMPORTANTEnsurethatCHAPissetbeforeyousetmutualCHAP,andusecompatiblelevelsforCHAPand mutualCHAP.


68 VMware, Inc.

Chapter 6 Managing iSCSI Storage

Returning Authentication to Default Inheritance ThevaluesofiSCSIauthenticationsettingsassociatedwithadynamicdiscoveryaddressorastaticdiscovery targetareinheritedfromthecorrespondingsettingsoftheparent.Forthedynamicdiscoveryaddress,the parentistheadapter.Forthestatictarget,theparentistheadapterordiscoveryaddress.

IfyouusethevSphereClienttomodifyauthenticationsettings,youmustdeselecttheInheritfromParent checkboxbeforeyoucanmakeachangetothediscoveryaddressordiscoverytarget. Ifyouusevicfg-iscsi,thevalueyousetoverridestheinheritedvalue.

Inheritanceisrelevantonlyifyouwanttoreturnadynamicdiscoveryaddressorastaticdiscoverytargetto itsinheritedvalue.Inthatcase,usethe--reset_authoption,whichrequiresthe--nameoptionforstatic discoveryaddresses,butnotfordynamicdiscoverytargets.UsingthisoptionresetsbothCHAPandmutual CHAP. NOTEThe--reset-authoptionresetstargetlevelCHAPauthenticationpropertiestobeinheritedfromthe adapterlevel.Resettingadapterlevelpropertiesisnotsupported.

iSCSI Storage Setup


YoucansetupiSCSIstorageusingthevSphereClientorthevicfg-iscsicommand.Afteryouhave completedtheinitialsetup(seeSettingUpSoftwareiSCSIonpage 69andSettingUpIndependent HardwareiSCSIonpage 72),youcanexamineandchangeoptionsandparameters(seeListingandSetting iSCSIOptionsonpage 77andListingandSettingiSCSIParametersonpage 77).

Setting Up Software iSCSI


SoftwareiSCSIsetuprequiresanumberofhighleveltasks.Foreachtask,seethediscussionofthe correspondingcommandlineoptioninthischapter,themanpage(Linux),orthereferenceinformation. 1 DeterminetheHBAtypeandretrievetheHBAID.
vicfg-iscsi --adapter --list

EnablesoftwareiSCSIfortheHBA.
vicfg-iscsi --swiscsi --enable

(Optional)Checkthestatus.
vicfg-iscsi --swiscsi --list

ThesystemprintsSoftware iSCSI is enabledorSoftware iSCSI is not enabled. 4 (Optional)SettheiSCSInameandalias.


vicfg-iscsi vicfg-iscsi vicfg-iscsi vicfg-iscsi -I -n <iscsi_name> <adapter_name> --iscsiname --name <iscsi_name> <adapter_name> -I -a <alias_name> <adapter_name> --iscsiname --alias <alias_name> <adapter_name>

Addadynamicdiscoveryaddressorastaticdiscoveryaddress. Thetwotypesoftargetdifferasfollows:

Withdynamicdiscovery,allstoragetargetsassociatedwithahostnameorIPaddressarediscovered. Yourunthefollowingcommand:
vicfg-iscsi <conn_options> --discovery --add --ip <ip_addr | domain_name> <adapter_name>

Withstaticdiscovery,youmustspecifythehostnameorIPaddressandtheiSCSInameofthestorage target.Yourunthefollowingcommand:
vicfg-iscsi <conn_options> --static --add --ip <ip_addr | domain_name> --name <iscsi_name> <adapter_name>

Whenyoulaterremoveadiscoveryaddress,itmightstillbedisplayedastheparentofastatictarget.You canaddthediscoveryaddressandrescantodisplaythecorrectparentforthestatictargets.
VMware, Inc. 69

vSphere Command-Line Interface Installation and Scripting Guide

(Optional)SettheauthenticationinformationforCHAP(seeSettingiSCSICHAPonpage 68and ReturningAuthenticationtoDefaultInheritanceonpage 69).


vicfg-iscsi -A -c <level> -m <auth_method> -u <auth_u_name> -w <auth_password> [-i <stor_ip_addr|stor_hostname> [:<portnum>] [-n <iscsi_name]] <adapter_name> 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>

Thetarget(-i)andname(-n)optiondeterminewhatthecommandappliesto.
Option -iandn Onlyi Neither-inorn Result CommandappliestopertargetCHAPforstatictargets. Commandappliestothediscoveryaddress. CommandappliestoperadapterCHAP.

(Optional)SettheauthenticationinformationformutualCHAPbyrunningvicfg-iscsi -Aagainwith the-boptionandadifferentauthenticationusernameandpassword. For<level>,specifychapProhibitedorchapRequired.

chapProhibitedThehostdoesnotuseCHAPauthentication.Ifauthenticationisenabled,specify chapProhibitedtodisableit. chapRequiredThehostrequiressuccessfulCHAPauthentication.TheconnectionfailsifCHAP negotiationfails.YoucansetthisvalueformutualCHAPonlyifCHAPissettochapRequired.

For<auth_method>,CHAPistheonlyvalidvalue. IMPORTANTYouareresponsibleformakingsurethatCHAPissetbeforeyousetmutualCHAP,andfor usingcompatiblelevelsforCHAPandmutualCHAP. 8 9 (Optional)SetiSCSIparametersbyrunningvicfg-iscsi -W. Aftersetupiscomplete,runvicfg-rescantorescanallstoragedevices.

Setting Up Dependent Hardware iSCSI


DependenthardwareiSCSIsetuprequiresanumberofhighleveltasks.Foreachtask,seethediscussionof thecorrespondingcommandlineoptioninthischapter,themanpage(Linux),orthereferenceinformation. 1 DeterminetheHBAtypeandretrievetheHBAID.
vicf-iscsi --adapter --list

(Optional)SettheiSCSInameandalias.
vicfg-iscsi vicfg-iscsi vicfg-iscsi vicfg-iscsi -I -n <iscsi_name> <adapter_name> --iscsiname --name <iscsi_name> <adapter_name> -I -a <alias_name> <adapter_name> --iscsiname --alias <alias_name> <adapter_name>

Setupportbindingbyfollowingthesesteps: a IdentifytheVMkernelportofthedependenthardwareiSCSIadapter.
esxcli <conn_options> swiscsi vmknic list -d <vmhba>

ConnectthedependenthardwareiSCSIinitiatortotheiSCSIVMkernelportsbyrunningthe followingcommandforeachport.
esxcli <conn_options> swiscsi nic add -n <port_name> -d <vmhba>

70

VMware, Inc.

Chapter 6 Managing iSCSI Storage

VerifythattheportswereaddedtothedependenthardwareiSCSIinitiator.
esxcli <conn_options> swiscsi nic list -d <vmhba>

RescanthedependenthardwareSCSIinitiator.
vicfg-rescan <conn_options> <vmhba>

Addadynamicdiscoveryaddressorastaticdiscoveryaddress. Thetwotypesoftargetdifferasfollows:

Withdynamicdiscovery,allstoragetargetsassociatedwithahostnameorIPaddressarediscovered. Yourunthefollowingcommand:
vicfg-iscsi <conn_options> --discovery --add --ip <ip_addr | domain_name> <adapter_name>

Withstaticdiscovery,youmustspecifythehostnameorIPaddressandtheiSCSInameofthestorage target.Yourunthefollowingcommand:
vicfg-iscsi <conn_options> --static --add --ip <ip_addr | domain_name> --name <iscsi_name> <adapter_name>

Whenyoulaterremoveadiscoveryaddress,itmightstillbedisplayedastheparentofastatictarget.You canaddthediscoveryaddressandrescantodisplaythecorrectparentforthestatictargets. 5 (Optional)SettheauthenticationinformationforCHAP(seeSettingiSCSICHAPonpage 68and ReturningAuthenticationtoDefaultInheritanceonpage 69).


vicfg-iscsi -A -c <level> -m <auth_method> -u <auth_u_name> -w <auth_password> [-i <stor_ip_addr|stor_hostname> [:<portnum>] [-n <iscsi_name]] <adapter_name> 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>

Thetarget(-i)andname(-n)optiondeterminewhatthecommandappliesto.
Option -iandn Onlyi Neither-inorn Result CommandappliestopertargetCHAPforstatictargets. Commandappliestothediscoveryaddress. CommandappliestoperadapterCHAP.

(Optional)SettheauthenticationinformationformutualCHAPbyrunningvicfg-iscsi -Aagainwith the-boptionandadifferentauthenticationusernameandpassword. For<level>,specifychapProhibitedorchapRequired.

chapProhibitedThehostdoesnotuseCHAPauthentication.Ifauthenticationisenabled,specify chapProhibitedtodisableit. chapRequiredThehostrequiressuccessfulCHAPauthentication.TheconnectionfailsifCHAP negotiationfails.YoucansetthisvalueformutualCHAPonlyifCHAPissettochapRequired.

For<auth_method>,CHAPistheonlyvalidvalue. IMPORTANTYouareresponsibleformakingsurethatCHAPissetbeforeyousetmutualCHAP,andfor usingcompatiblelevelsforCHAPandmutualCHAP. 7 8 (Optional)SetiSCSIparametersbyrunningvicfg-iscsi -W. Aftersetupiscomplete,runvicfg-rescantorescanallstoragedevices.

VMware, Inc.

71

vSphere Command-Line Interface Installation and Scripting Guide

Setting Up Independent Hardware iSCSI


WithindependenthardwarebasediSCSIstorage,youuseaspecializedthirdpartyadaptercapableof accessingiSCSIstorageoverTCP/IP.ThisiSCSIinitiatorhandlesalliSCSIandnetworkprocessingand managementforyourESX/ESXisystem. YoumustinstallandconfiguretheindependenthardwareiSCSIadapterforyourhostbeforeyoucanaccess theiSCSIstoragedevice.Forinstallationinformation,seevendordocumentation. HardwareiSCSIsetuprequiresanumberofhighleveltasks.Foreachtask,seethediscussionofthe correspondingcommandlineoptioninthischapter,themanpage(Linux),orthereferenceinformation. 1 DeterminetheHBAtypeandretrievetheHBAID.
vicf-iscsi --adapter --list

Configurethehardwareinitiator(HBA)byrunningvicfg-iscsi -Nwithoneormoreofthefollowing options.


--listListnetworkproperties. --ip <ip_addr>SetHBAIPv4address. --subnetmask <subnet_mask>SetHBAnetworkmask. --gateway <default_gateway>SetHBAgateway. --set ARP=true|falseEnableordisableARPredirect.

YoucanalsosettheHBAIPv4addressandnetworkmaskandgatewayinonecommand.
--ip <ip_addr> --subnetmask <subnet_mask> --gateway <default_gateway>

(Optional)SettheiSCSInameandalias.
vicfg-iscsi vicfg-iscsi vicfg-iscsi vicfg-iscsi -I -n <iscsi_name> <adapter_name> --iscsiname --name <iscsi_name> <adapter_name> -I -a <alias_name> <adapter_name> --iscsiname --alias <alias_name> <adapter_name>

Addadynamicdiscoveryaddressorastaticdiscoveryaddress. Thetwotypesoftargetdifferasfollows:

Withdynamicdiscovery,allstoragetargetsassociatedwithanIPaddressarediscovered.Runthe followingcommand:
vicfg-iscsi <conn_options> --discovery --add --ip <ip_addr> <adapter_name>

Withstaticdiscovery,youmustspecifytheIPaddressandtheiSCSInameofthestoragetargettobe added.Runthefollowingcommand:
vicfg-iscsi <conn_options> --static --add --ip <ip_addr> --name <iscsi_name> <adapter_name>

Whenyoulaterremoveadiscoveryaddress,itmightstillbedisplayedastheparentofastatictarget.You canlateraddthediscoveryaddressandrescantodisplaythecorrectparentforthestatictargets.

72

VMware, Inc.

Chapter 6 Managing iSCSI Storage

(Optional)SettheauthenticationinformationforCHAPbyrunningvicfg-iscsi -A. Youcansettheinformationforperadapter,perdiscovery,andpertargetCHAP.SeeSettingiSCSI CHAPonpage 68andReturningAuthenticationtoDefaultInheritanceonpage 69.


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>

Thetarget(-i)andname(-n)optiondeterminewhatthecommandappliesto.
Option -iandn Onlyi Neither-inorn Result CommandappliestopertargetCHAPforstatictargets. Commandappliestothediscoveryaddress. CommandappliestoperadapterCHAP.

MutualCHAPisnotsupportedforindependenthardwareiSCSIstorage. 6 7 (Optional)SetadditionaliSCSIparametersbyrunningvicfg-iscsi -W. Aftersetupiscomplete,callvicfg-rescantorescanallstoragedevices.

vicfg-iscsi Command Syntax


CommandsforiSCSImanagementusuallyincludeanoption,asuboption,anoptionalparameter,andthe adaptername.Foreachoption,theshortandthelongformsareequivalent.Thecommandshavethefollowing syntax:
vicfg-iscsi <conn-params> [option][suboption][parameters][<adapter_name>]

Thefollowingoptionsaresupported:

-D --discovery -S --static -A --authentication -P --phba -T --target -L --lun -N --network(IndependenthardwareiSCSIonly) -p --pnp(IndependenthardwareiSCSIonly) -I --iscsiname -W --parameter -E --swiscsi -H --adapter

Suboptionisoneofthefollowingoperations:

-l --list -a --add -r --remove

Parametersdifferdependingontheoptionandsuboptionused. Exceptfor--adapterand--help,allcommandsrequirethe<adapter_name>argument.Theadaptername shouldbethenamethattheESX/ESXihostassignedorconfiguredforthesoftwareorhardwareiSCSIinitiator. TheESXConfigurationGuideandtheESXiConfigurationGuidediscussiSCSIinitiatorsinavSphere environment.

VMware, Inc.

73

vSphere Command-Line Interface Installation and Scripting Guide

Youcanuse--listtofindtheadaptername.
vicfg-iscsi --adapter --list vicfg-iscsi -H -l

vicfg-iscsisupportsacomprehensivesetofoptions,listedinTable 62. Table 6-2. Options for vicfg-iscsi


Option Suboptions Description

-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> -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> -A --authentication -l <adapter_name> --list <adapter_name> -D --discovery -a -i <stor_ip_addr|stor_hostname[:<portnum>] <adapter_name> --add --ip <stor_ip_addr|stor_hostname> [:<portnum>] <adapter_name> -D --discovery -l <adapter_name> --list <adapter_name> -D --discovery -r -i <stor_ip_addr|stor_hostname>[:<portnum>] <adapter_name> --remove --ip <stor_ip_addr|stor_hostname> [:<portnum>] <adapter_name> -H -l [<adapter_name>] --list [<adapter_name>] -L --lun -l <adapter_name> --list <adapter_name> ListsLUNinformation. ListsalliSCSIadaptersora specifiedadapter. Removesadynamicdiscovery address. Listsdynamicdiscovery addresses. Addsadynamicdiscovery address. Listssupportedauthentication methods. Enablesauthenticationusingthe specifiedoptions. Enablesmutualauthentication. Youmustenableauthentication beforeyoucanenablemutual authentication.

74

VMware, Inc.

Chapter 6 Managing iSCSI Storage

Table 6-2. Options for vicfg-iscsi (Continued)


Option -L --lun -l -t <target_ID> <adapter_name> --list --target_id <target_id> <adapter_name> -N --network (Independent hardware iSCSI only) -l <adapter_name> --list <adapter_name> -N --network (Independent hardware iSCSI only) -i <ip_addr> <adapter_name> --ip <ip_addr> <vmhba> -N --network (Independent hardware iSCSI only) -s <subnet_mask> <adapter_name> --subnetmask <subnet_mask> <adapter_name> -N --network (Independent hardware iSCSI only) -g <default_gateway> <adapter_name> --gateway <default_gateway> <adapter_name> -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> -p --pnp (Independent hardware iSCSI only) -l <adapter_name> --list <adapter_name> -p --pnp (Independent hardware iSCSI only) -M <mtu_size> <adapter_name> --mtu <mtu-size> <adapter_name> -I --iscsiname -a <alias_name> <adapter_name> --alias <alias_name> <adapter_name> -I --iscsiname -n <iscsi_name> <adapter_name> --name <iscsi_name> <adapter_name> -I --iscsiname -l <adapter_name> --list <adapter_name> -M --mtu -p -M <mtu_size> <adapter_name> --pnp --mtu <mtu-size> <adapter_name> -S --static -l <adapter_name> --list <adapter_name> -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> Removesastaticdiscovery address. Listsstaticdiscoveryaddresses. SetsMTUsize.Usedwiththe --pnpoption. ListsiSCSIinitiatoroptions. SetstheiSCSIinitiatorname. SetstheiSCSIinitiatoralias. Setsphysicalnetworkportal options. Listsphysicalnetworkportal options. SetstheIPaddress,subnetmask, anddefaultgatewayinone command. SetstheHBAgatewayto default_gateway. SetstheHBAnetworkmaskto subnet_mask. SetstheHBAIPv4addressto ip_addr. Listsnetworkproperties. ListsLUNinformationfora specifictarget. Suboptions Description

VMware, Inc.

75

vSphere Command-Line Interface Installation and Scripting Guide

Table 6-2. Options for vicfg-iscsi (Continued)


Option Suboptions Description

-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> -P --phba -l <adapter_name> --list <adapter_name> -T --target -l <adapter_name> --list <adapter_name> -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> -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> -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> -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> -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> Resetstargetlevelauthentication propertiestobeinheritedfrom adapterlevel.Usedwiththe --authenticationoption. Returnsparametersindiscovery targetorsendtargettodefault inheritancebehavior. SetsiSCSIparameters. ListsiSCSIparameterdetails. ListsiSCSIparameter information. Liststargetinformation. Listsexternal,vendorspecific propertiesofaniSCSIadapter. Addsastaticdiscoveryaddress.

76

VMware, Inc.

Chapter 6 Managing iSCSI Storage

Listing and Setting iSCSI Options


Usevicfg-iscsiinformationretrievaloptionstolistexternalHBAproperties,informationabouttargets,and LUNs.Youcanusethefollowingvicfg-iscsioptionstolistiSCSIparameters.

Runvicfg-iscsi -P|--phbatolistexternal(vendorspecific)propertiesofaniSCSIadapter.
vicfg-iscsi -P -l <adapter_name> vicfg-iscsi --phba --list <adapter_name>

Thesystemreturnsinformationaboutthevendor,model,description,andserialnumberoftheHBA.

Runvicfg-iscsi -T| --targettolisttargetinformation.


vicfg-iscsi -T -l <adapter_name> vicfg-iscsi --target --list <adapter_name>

Thesystemreturnsinformationabouttargetsforthespecifiedadapter,includingtheiSCSIname(IQNor EUIformat)andalias.SeeDiscoveryTargetNamesonpage 67.

Runvicfg-iscsi -L|--luntolistLUNinformation.
vicfg-iscsi -L -l <adapter_name> vicfg-iscsi --lun --list <adapter_name>

Thecommandreturnstheoperatingsystemdevicename,busnumber,targetID,LUNID,andLUNsize fortheLUN.

Runvicfg-iscsi -Lwith-ttolistonlyLUNsonaspecifiedtarget.
vicfg-iscsi -L -l -t <target_ID> <adapter_name> vicfg-iscsi --lun --list --target_id <target_id> <adapter_name>

ThesystemreturnstheLUNsonthespecifiedtargetandthecorrespondingdevicename,devicenumber, LUNID,andLUNsize.

Runvicfg-iscsi -p|--pnptolistphysicalnetworkportalinformationforindependenthardwareiSCSI devices.Youalsousethisoptionwith--mtu.


vicfg-iscsi -p -l <adapter_name> vicfg-iscsi --pnp --list <adapter_name>

ThesystemreturnsinformationabouttheMACaddress,MTU,andcurrenttransferrate.

Runvicfg-iscsi -I -ltolistinformationabouttheiSCSIinitiator.ESX/ESXisystemsusea softwarebasediSCSIinitiatorintheVMkerneltoconnecttostorage.ThecommandreturnstheiSCSI name,aliasname,andaliassettablebitfortheinitiator.


vicfg-iscsi <conn_options> -I -l vmhba42

Runvicfg-iscsi -p -MtosettheMTUfortheadapter.Youspecifythesizeandadaptername.
vicfg-iscsi -p -M <mtu_size> <adapter_name> vicfg-iscsi --pnp --mtu <mtu-size> <adapter_name>

Listing and Setting iSCSI Parameters


YoucanlistandsetiSCSIparametersbyrunningvicfg-iscsi -W.Table 63listsallsettableparameters. TheseparametersarealsodescribedintheIETFrfc3720.Youcanalsorunvicfg-iscsi --parameter --list --detailstodeterminewhetheraparameterissettableornot. TheparametersinTable 63applytosoftwareiSCSIanddependenthardwareiSCSI.

VMware, Inc.

77

vSphere Command-Line Interface Installation and Scripting Guide

Table 6-3. Settable iSCSI Parameters


Parameter DataDigestType Description Increasesdataintegrity.Whendatadigestisenabled,thesystemperformsachecksumover eachPDUsdatapartandverifiesusingtheCRC32Calgorithm. Note:SystemsthatuseIntelNehalemprocessorsoffloadtheiSCSIdigestcalculationsfor softwareiSCSI,thusreducingtheimpactonperformance. ValidvaluesaredigestProhibited,digestDiscouraged,digestPreferred,or digestRequired. HeaderDigest Increasesdataintegrity.Whenheaderdigestisenabled,thesystemperformsachecksumover theheaderpartofeachiSCSIProtocolDataUnit(PDU)andverifiesusingtheCRC32C algorithm. MaxOutstandingR2TdefinestheReadytoTransfer(R2T)PDUsthatcanbeintransitionbefore anacknowledgementPDUisreceived. MaximumamountofunsoliciteddataaniSCSIinitiatorcansendtothetargetduringthe executionofasingleSCSIcommand,inbytes. MaximumSCSIdatapayloadinaDataInorasolicitedDataOutiSCSIsequence,inbytes. Maximumdatasegmentlength,inbytes,thatcanbereceivedinaniSCSIPDU. Timeinterval,inseconds,betweenNOPOutrequestssentfromyouriSCSIinitiatortoaniSCSI target.TheNOPOutrequestsserveasthepingmechanismtoverifythataconnectionbetween theiSCSIinitiatorandtheiSCSItargetisactive. Supportedonlyattheinitiatorlevel. NoopTimeout Amountoftime,inseconds,thatcanlapsebeforeyourhostreceivesaNOPInmessage.The messageissentbytheiSCSItargetinresponsetotheNOPOutrequest.Whenthe NoopTimeoutlimitisexceeded,theinitiatorterminatesthecurrentsessionandstartsanew one. Supportedonlyattheinitiatorlevel. RecoveryTimeout DelayedAck Amountoftime,inseconds,thatcanlapsewhileasessionrecoveryisperformed.Ifthetimeout exceedsitslimit,theiSCSIinitiatorterminatesthesession. Allowssystemstodelayacknowledgmentofreceiveddatapackets.

MaxOutstandingR2T FirstBurstLength MaxBurstLength MaxRecvDataSegLen NoopInterval

Youcanusethefollowingvicfg-iscsioptionstolistparameteroptions.

Runvicfg-iscsi -W -ltolistparameteroptionsfortheHBA.
vicfg-iscsi -W -l [-i <stor_ip_addr|stor_hostname> [:<portnum>] [-n <iscsi_name>]] <adapter_name> vicfg-iscsi --parameter --list [--ip <stor_ip_addr|stor_hostname> [:<portnum>] [--name <iscsi_name>]] <adapter_name>

Thetarget(-i)andname(-n)optiondeterminewhatthecommandappliesto.
Option -iandn Onlyi Neither-inorn Result Commandappliestostatictargets. Commandappliestothediscoveryaddress. Commandappliestoperadapterparameters.

Runvicfg-iscsi -W -l -k tolistiSCSIparametersandwhethertheyaresettable.
vicfg-iscsi -W -l -k [-i <stor_ip_addr|stor_hostname>[:<port_num>] [-n <iscsi_name>]] <adapter_name>

vicfg-iscsi --parameter --list --detail [--ip <stor_ip_addr|stor_hostname>[:<port_num>][--name <iscsi_name>]] <adapter_name>

78

VMware, Inc.

Chapter 6 Managing iSCSI Storage

Runvicfg-iscsi -W -jtosetiSCSIparameteroptions.
vicfg-iscsi -W -j <name>=<value> -i <stor_ip_addr|stor_hostname>[:port_num>][-n <iscsi_name>]] <adapter_name> vicfg-iscsi --parameter --set <name>=<value> --ip <stor_ip_addr|stor_hostname>[:port_num>][--name <iscsi_name>]] <adapter_name>

Thetarget(-i)andname(-n)optiondeterminewhatthecommandappliesto.
Option -iandn Onlyi Neither-inorn Result CommandappliestopertargetCHAPforstatictargets. Commandappliestothediscoveryaddress. CommandappliestoperadapterCHAP.

Ifspecialcharactersareinthe<name>=<value>sequence,forexample,ifyouaddaspace,youmustsurround thesequencewithdoublequotes(<name> = <value>).

Returning Parameters to Default Inheritance


ThevaluesofiSCSIparametersassociatedwithadynamicdiscoveryaddressorastaticdiscoverytargetare inheritedfromthecorrespondingsettingsoftheparent.Forthedynamicdiscoveryaddress,theparentisthe adapter.Forthestatictarget,theparentistheadapterordiscoveryaddress.

IfyouusethevSphereClienttomodifyauthenticationsettings,youdeselecttheInheritfromParent checkboxbeforeyoucanmakeachangetothediscoveryaddressordiscoverytarget. Ifyouusevicfg-iscsi,thevalueyousetoverridestheinheritedvalue.

Inheritanceisrelevantonlyifyouwanttoreturnadynamicdiscoveryaddressorastaticdiscoverytargetto itsinheritedvalue.Inthatcase,usethe--reset <param_name>option,whichrequiresthe--nameoptionfor staticdiscoveryaddresses,butnotfordynamicdiscoverytargets.


vicfg-iscsi <conn_options> --parameter --reset <param_name> --ip <stor_ip_addr | stor_hostname>[:port_num>] <adapter_name> vicfg-iscsi <conn_options> -W -o <param_name> -i <stor_ip_addr|stor_hostname>[:port_num>] <adapter_name>

Enabling iSCSI Authentication


Thevicfg-iscsi-A -coptionsenableiSCSIauthentication.Mutualauthenticationissupportedforsoftware iSCSIanddependenthardwareiSCSI,butnotforindependenthardwareiSCSI.SeeSettingiSCSICHAPon page 68. To enable mutual authentication 1 EnableauthenticationontheESX/ESXihost.
vicfg-iscsi -A -c <level> -m <auth_method> -u <auth_u_name> -w <auth_password> [-i <stor_ip_addr|stor_hostname> [:<portnum>] [-n <iscsi_name]] <adapter_name>

Thespecifiedusernameandpasswordmustbesupportedonthestorageside. 2 EnablemutualauthenticationontheESX/ESXihost.
vicfg-iscsi -A -c <level> -m <auth_method> -b -u <ma_username> -w <ma_password> [-i <stor_ip_addr|stor_hostname> [:<portnum>] [-n <iscsi_name]] <adapter_name>

Makesurethefollowingrequirementsaremet.

CHAPauthenticationisalreadysetupwhenyoustartsettingupmutualCHAP. CHAPandmutualCHAPusedifferentusernamesandpasswords.Thesecondusernameand passwordaresupportedformutualauthenticationonthestorageside. CHAPandmutualCHAPusecompatibleCHAPlevels.

VMware, Inc.

79

vSphere Command-Line Interface Installation and Scripting Guide

Setting Up Ports for iSCSI Multipathing


Withportbinding,youcreateaseparateVMkernelportforeachphysicalNICusing1:1mapping.Youcanadd allnetworkadapterandVMkernelportpairstoasinglevSwitch.TheiSCSISANConfigurationGuideexplains howtospecifyportbindingindetail. To specify port binding 1 FindoutwhichuplinksareavailableforusewithiSCSIadapters.
esxcli <conn_options> swiscsi vmnic list -d <vmhba>

ConnectthesoftwareiSCSIordependenthardwareiSCSIinitiatortotheiSCSIVMkernelportsbyrunning thefollowingcommandforeachport.
esxcli <conn_options> swiscsi nic add -n <port_name> -d <vmhba>

VerifythattheportswereaddedtotheiSCSIinitiatorbyrunningthefollowingcommand:
esxcli <conn_options> swiscsi nic list -d <vmhba>

RescantheiSCSIinitiator.
vicfg-rescan <conn_options> <vmhba>

5 6

(Optional)IfthereareactiveiSCSIsessionsbetweenyourhostandtargets,discontinuethem.See RemovingiSCSISessionsonpage 81. TodisconnecttheiSCSIinitiatorfromtheports,runthefollowingcommand.


esxcli <conn_options> swiscsi nic remove -n <port_name> -d <vmhba>

Youcanalsouseesxcli swiscsi vmknictoidentifyuplinkssuitableforiSCSIandesxcli swiscsi vmnic toidentifyVMkernelnetworkinterfacessuitableforusewithsoftwareiSCSIanddependenthardwareiSCSI.

Managing iSCSI Sessions


Youcanuseesxcli swiscsi sessiontolistandmanageiSCSIsessionsforsoftwareiSCSIanddependent hardwareiSCSIenvironments.Thefollowingsamplescenariousestheavailablecommands.Runesxcli swiscsi session --helpandeachcommandwith--helpforreferenceinformation.Theexampleusesa configurationfiletologintothehost.

Listing iSCSI Sessions

ListasoftwareiSCSIsessionattheadapterlevel.
esxcli <conn_options> swiscsi session list -d <iscsi_adapter>

Forexample:
esxcli --config /host-config-file swiscsi session list -d vmhba36

ListasoftwareiSCSIsessionatthetargetlevel.
esxcli <conn_options> swiscsi session list -t <iqn.xxxxx> -d <iscsi_adapter>

Forexample:
esxcli --config /host-config-file swiscsi session list -t iqn.xxx -d vmhba36

80

VMware, Inc.

Chapter 6 Managing iSCSI Storage

Logging in to iSCSI Sessions


Youcanuseesxcli swiscsi sessiontologintoasession.

LogintoasessiononthecurrentsoftwareiSCSIordependenthardwareiSCSIconfigurationatthe adapterlevel.
esxcli <conn_options> swiscsi session add -d <iscsi_adapter>

Forexample:
esxcli --config /host-config-file swiscsi session add -d vmhba36

LogintoasessiononthecurrentsoftwareiSCSIordependenthardwareiSCSIconfigurationatthetarget level.
esxcli <conn_options> swiscsi session add -t <iqn> -d <iscsi_adapter>

Forexample:
esxcli --config /host-config-fileswiscsi session add -t iqn.xxx -d vmhba36

AddduplicatesessionswithtargetandsessionIDsincurrentsoftwareiSCSIordependenthardware iSCSIconfiguration.
esxcli <conn_options> swiscsi session add --target <iqn.xxxx> --isid <session_id> --adapter <iscsi_adapter>

iqn.xxxxisthetargetIQN,whichyoucandeterminebylistingallsessions.session_idisthesessions iSCSIID.Forexample:
esxcli --config /host-config-file swiscsi session add -t iqn.xxx -s '00:02:3d:00:00:01' -d vmhba36

Removing iSCSI Sessions


Youcanuseesxcli swiscsi sessiontoremoveiSCSIsessions.

RemovesessionsfromthecurrentsoftwareiSCSIordependenthardwareiSCSIconfigurationatthe adapterlevel.
esxcli <conn_options> swiscsi session remove -d <iscsi_adapter>

Forexample:
esxcli --config /host-config-file swiscsi session remove -d vmhba36

RemovesessionsfromthecurrentsoftwareiSCSIordependenthardwareiSCSIconfigurationatthetarget level.
esxcli <conn_options> swiscsi session remove -t <iqn> -d <iscsi_adapter>

Forexample:
esxcli --config /host-config-file swiscsi session remove -t iqn.xxx -d vmhba38

RemovesessionsfromthecurrentsoftwareiSCSIordependenthardwareiSCSIconfigurationwithtarget andsessionID.
esxcli <conn_options> swiscsi session remove --target <iqn.xxxx> --isid <session id> --adapter <iscsi_adapter>

iqn.xxxxisthetargetIQN,whichyoucandeterminebylistingallsessions.session_idisthesessions iSCSIID. Forexample:


esxcli --config /host-config-file swiscsi session remove -t iqn.xxx -s '00:02:3d:01:00:01' -d vmhba36

VMware, Inc.

81

vSphere Command-Line Interface Installation and Scripting Guide

82

VMware, Inc.

Managing Users

AnESX/ESXisystemgrantsaccesstoitsresourceswhenaknownuserwithappropriatepermissionslogson tothesystemwithapasswordthatmatchestheonestoredforthatuser.YoucanusethevSphereClientorthe vSphereSDKforallusermanagementtasks.Youcanusethevicfg-usercommandtocreate,modify,delete, andlistlocaldirectaccessusersandgroupsofusersonanESX/ESXihost.Youcannotrunthiscommand againstavCenterServersystem. Thischapterincludesthefollowingtopics


UsersandGroupsinthevSphereEnvironmentonpage 83 vicfguserCommandSyntaxonpage 83 ManagingUserswithvicfguseronpage 84 ManagingGroupswithvicfguseronpage 86

Users and Groups in the vSphere Environment


Users,groups,androlescontrolwhohasaccesstoyourvSpherecomponentsandwhatactionseachusercan perform. IMPORTANTYoucannotusevicfg-usertocreateroles.Youcanusetherolesthatarepredefinedbythe system. vCenterServerandESX/ESXisystemsauthenticateauserwithacombinationofusername,password,and permissions.Theserversandhostsmaintainlistsofauthorizedusersandthepermissionsassignedtoeach user. Privilegesdefinebasicindividualrightsthatarerequiredtoperformactionsandretrieveinformation. ESX/ESXiandvCenterServerusesetsofprivileges,orroles,tocontrolwhichusersorgroupscanaccess particularvSphereobjects.ESX/ESXiandvCenterServerprovideasetofpreestablishedroles. TheprivilegesandrolesassignedonanESX/ESXihostareseparatefromtheprivilegesandrolesassignedon avCenterServersystem.WhenyoumanageahostusingvCenterServersystem,onlytheprivilegesandroles assignedthroughthevCenterServerareavailable.IfyouconnectdirectlytothehostbyusingthevSphere Client,onlytheprivilegesandrolesassigneddirectlyonthehostareavailable. UsermanagementisdiscussedindetailintheESXConfigurationGuide,theESXiConfigurationGuide,andthe DatacenterAdministrationGuide.

vicfg-user Command Syntax


Thevicfg-usersyntaxdiffersfromothervCLIcommands.Youspecifyoperationsasfollows:
vicfg-user <conn_options> -e <user|group> -o <add|modify|delete|list>

IMPORTANTIfyoucreateauserwithoutspecifyingtherole(--role),theuserhasnopermissions.
VMware, Inc. 83

vSphere Command-Line Interface Installation and Scripting Guide

Options vicfg-usercommandspecificoptionsmanipulateusersandgroups.Youmustalsospecifyconnection options.SeevCLIConnectionOptionsonpage 23.


Option --addgroup <group_list> -g <group_list> --adduser <user_list> -u <user_list> --entity <group|user> -e <group|user> --group <name> -d <name> --groupid <group_id> -D <group_id> --login <login_id> -l <login_id> --newpassword <p_wd> -p <p_wd> --newuserid <UUID> -i <UUID> --newusername <name> -n <name> --operation -o --removegroup <group_list> -G <group_list> --removeuser <user_list> -U <user_list> --role <administrator|read-only|no-access> -r <administrator|read-only|no-access> Description Commaseparatedlistofgroupstoaddtheuserto. Addsthespecifieduserstoaspecifiedgroup.Takesa commaseparatedlistofusers. Entitytoperformtheoperationon.Specifyeitheruseror group. Groupnameofthegroup. GroupIDofthegroup. LoginIDoftheuser. Passwordforthetargetuser. NewUUIDforthetargetuser. Newusernameforthetargetuser. Operationtoperform.Specifyadd,modify,delete,orlist. Commaseparatedlistofgroupstoremovethetargetuser from. Commaseparatedlistofuserstoberemovedfromthetarget group. Roleforthetargetuserorgroup.Specifyoneof administrator,read-only,orno-access. Ifyoucreateauserwithoutassigningpermissions,theuserhas nopermissions. --shell -s Grantshellaccesstothetargetuser.Defaultisnoshellaccess. Usethiscommandtochangethedefaultortorevokeshell accessrightsaftertheyhavebeengranted. Validvaluesareyesandno. ThisoptionissupportedonlyagainstESX.Theoptionisnot supportedagainstESXi.

Managing Users with vicfg-user


AuserisanindividualauthorizedtologintoanESX/ESXiorvCenterServersystem. vSpheredoesnotexplicitlyrestrictuserswiththesameauthenticationcredentialsfromaccessingandtaking actionwithinthevSphereenvironmentsimultaneously. YoumanageusersdefinedonthevCenterServersystemandusersdefinedonindividualhostsseparately.

ManageESX/ESXidefineduserswiththevSphereClient,thevSphereWebServicesSDK,orvicfg-user. ManagevCenterServeruserswiththevSphereClientorthevSphereWebServicesSDK.

84

VMware, Inc.

Chapter 7 Managing Users

EveniftheuserlistsofahostandavCenterServersystemappeartohavecommonusers(forinstance,auser calleddevuser),theseusersareseparateuserswiththesamename.TheattributesofdevuserinvCenter Server,includingpermissions,passwords,andsoforth,areseparatefromtheattributesofdevuseronthe ESX/ESXihost.IfyoulogintovCenterServerasdevuser,youmighthavepermissiontoviewanddeletefiles fromadatastore.IfyoulogintoanESX/ESXihostasdevuser,youmightnothavethesepermissions. UsersauthorizedtoworkdirectlyonanESX/ESXihostareaddedtotheinternaluserlistwhenESX/ESXiis installedorcanbeaddedbyasystemadministratorafterinstallation.Youcanusevicfg-usertoaddusers, removeusers,changepasswords,setgroupmembership,andconfigurepermissions. CAUTIONSeetheAuthenticationandUserManagementchapteroftheESXConfigurationGuideorESXi ConfigurationGuideforinformationaboutrootusersbeforeyoumakeanychangestothedefaultusers. Mistakesregardingrootuserscanhaveseriousaccessconsequences. EachESX/ESXihosthasanumberofdefaultusers:

Therootuserhasfulladministrativeprivileges.Administratorsusethisloginanditsassociatedpassword tologintoahostthroughthevSphereClient.Rootuserscancontrolallaspectsofthehostthattheyare loggedonto.Rootuserscanmanipulatepermissions,creatinggroupsandusers(onESX/ESXihostsonly), workingwithevents,andsoon. ThevpxuseruserisavCenterServerentitywithrootrightsontheESX/ESXihost,allowingittomanage activitiesforthathost.ThesystemcreatesvpxuserwhenanESX/ESXihostisattachedtovCenterServer. vpxuserisnotpresentontheESX/ESXihostunlessthehostisbeingmanagedthroughvCenterServer. Otherusersmightbedefinedbythesystem,dependingonthenetworkingsetupandotherfactors.

Thefollowingexamplescenarioillustratessomeofthetasksthatyoucanperform. To create, modify, and delete users 1 Listtheexistingusers.


vicfg-user <conn_options> -e user -o list

Thelistdisplaysallusersthatarepredefinedbythesystemandallusersthatwereaddedlater. 2 Addanewuser,specifyingaloginIDandpassword.
vicfg-user <conn_options> -e user -o add -l user27 -p 27_password

Thecommandcreatestheuser.Bydefault,thecommandautogeneratesaUIDfortheuseranddoesnot giveshellaccess. 3 ListtheusersagaintoverifythatthenewuserwasaddedandaUIDwasgenerated.


vicfg-user <conn_options> -e user -o list USERS ------------------Principal -: root Full Name -: root UID -: 0 Shell Access -> 1 ------------------... -------------------Principal -: user27 Full Name -: UID -: 501 Shell Access -> 0

Modifythepasswordforuseruser27.
vicfg-user <conn_options> -e user -o modify -l user27 -p 27_password2

ThesystemmightreturnUpdated user user27 successfully.

VMware, Inc.

85

vSphere Command-Line Interface Installation and Scripting Guide

Assignreadonlyprivilegestotheuser(whichcurrentlyhasnoaccess).
vicfg-user <conn_options> -e user -o modify -l user27 --role read-only

Thesystempromptswhetheryouwanttochangethepassword,whichmightbeadvisableiftheuserdoes notcurrentlyhaveapassword.Answeryorn.Thesystemthenupdatestheuser.
Updated user user27 successfully. Assigned the role read-only

Listtheexistinggroups.
vicfg-user <conn_options> -e group -o list

Thesystemprintsanextensivelistofallgroupsandtheusersineachgroup. 7 Createagroup.
vicfg-user <conn_options> -e group -o add -d test

Thesystemaddsthegroup,andassignsagroupID.Whenyounowlistallgroups,thenewgroupis included.
---------Group Information: Principal -: test Full Name -: GID -: 500 ----------

Adduseruser27tothenewgroup.
vicfg-user <conn_options> -e user -o modify -l user27 -g test

Thesystemassignstheusertothegrouptest.Whenyounowlistallgroups,thenewgroupandthe assigneduserareincluded.
---------Group Information: Principal -: test Full Name -: GID -: 500 Users in group test: Principal -: user27 Full Name -: ___________

RemovetheuserwithloginIDuser27
vicfg-user <conn_options> -e user -o delete -l user27

Thesystemremovestheuserandprintsamessage.
Removed the user user27 successfully.

Managing Groups with vicfg-user


Youcanefficientlymanagesomeuserattributesbycreatinggroups.Agroupisasetofusersthatyoumanage throughacommonsetofpermissions. Ausercanbeamemberofmorethanonegroup.Whenyouassignpermissionstoagroup,allusersinthe groupinheritthosepermissions.Usinggroupscanreducethetimeittakestosetupyourpermissionsmodel. ThegrouplistinanESX/ESXihostisdrawnfromatablethatismaintainedbythehost.Youcanchangethe grouplistbyusingthevSphereClientorvCLI.

UsetheUsersandGroupstabinthevSphereClientwhenthevSphereClientisconnecteddirectlytothe host. Usethevicfg-uservCLIcommand.

86

VMware, Inc.

Chapter 7 Managing Users

Beforeyoucanadduserstoagroup,youmustcreatethegroupbyusingthevicfg-user addcommand,as inthefollowingexamples.

Addgroup40totheexistinggroups.IfyoudonotspecifyagroupID,thesystemassignsanIDforthe group.
vicfg-user <conn_options> -e group -o add -d group40 -D 55

Createagroupwithpredefinedreadonlyprivilegesthatyoucanlaterusetoassignreadonlyprivileges tomultipleusers.
vicfg-user <conn_options> --entity group --operation add --group group42 --groupid 4242 --role read-only

Youcanthenaddandremoveusersfromthegroup,asinthefollowingexamplescenario. To add and remove users from groups 1 Addauserwithusernametesttoagroupgroup42.


vicfg-user <conn_options> -e group -o modify -d group45 --adduser test

Youmustspecifytheusernametoaddausertoagroup.TheuserIDisnotacceptable. 2 Adduserswithusernamesu1,u2,andu3togroup45,whichhasreadonlyprivileges.
vicfg-user <conn_options> -e group -o modify -d group42 --adduser u1,u2,u3

Removetheuserwithusernameu3fromthegroup.
vicfg-user <conn_options> -e group -o modify -d group42 --removeuser u3

Removethegroupwithgroupnamegroup45.
vicfg-user <conn_options> -e group -o delete -d group42

VMware, Inc.

87

vSphere Command-Line Interface Installation and Scripting Guide

88

VMware, Inc.

Managing Virtual Machines

YoucanmanagevirtualmachineswiththevSphereClientorthevmware-cmdvCLIcommand.Using vmware-cmdyoucanregisterandunregistervirtualmachines,retrievevirtualmachineinformation,manage snapshots,turnthevirtualmachineonandoff,addandremovevirtualdevices,andpromptforuserinput. Thechapterincludesthesetopics:


vmwarecmdOverviewonpage 89 ListingandRegisteringVirtualMachinesonpage 90 RetrievingVirtualMachineAttributesonpage 91 ManagingSnapshotswithvmwarecmdonpage 92 PoweringVirtualMachinesOnandOffonpage 93 ConnectingandDisconnectingVirtualDevicesonpage 94 RetrievingUserInputonpage 95 ForciblyStoppingVirtualMachinesonpage 95

SomevirtualmachinemanagementutilityapplicationsareincludedinthevSphereSDKforPerl.

vmware-cmd Overview
vmware-cmdwasincludedinearlierversionoftheESXServiceConsole.Avmware-cmdvCLIhasbeen availablesinceESXiversion3.0. IMPORTANTOlderserviceconsoleversionsofvmware-cmdsupportasetofconnectionoptionsandgeneral optionsthatdifferfromtheoptionsinothervCLIcommands.Thevmware-cmdvCLIcommandsupports theseoptions.ThevCLIcommandalsosupportsthestandardvCLI--server,--username,--password,and --vihostoptions.vmware-cmddoesnotsupportotherconnectionoptions.

Connection Options for vmware-cmd


Thevmware-cmdvCLIcommandsupportsonlythefollowingconnectionoptions.OthervCLIconnection optionsarenotsupported,forexample,youcannotusevariablesbecausethecorrespondingoptionisnot supported.
Option --server <host> -H <host> --vihost <target> -h <target> -O <port> Whenyourunvmware-cmdwiththe-HoptionpointingtoavCenterServersystem,use --vihosttospecifytheESX/ESXihosttorunthecommandagainst. Alternativeconnectionport.Thedefaultportnumberis902. Description TargetESX/ESXiorvCenterServersystem.

VMware, Inc.

89

vSphere Command-Line Interface Installation and Scripting Guide

Option username <username> -U <username> password <password> -P <password> -Q <protocol>

Description Userwhoisauthorizedtologintothehostspecifiedby--serveror--vihost. Passwordfortheuserspecifiedby-U. Protocoltouse,eitherhttporhttps.Defaultishttps.

General Options for vmware-cmd


Thevmware-cmdvCLIcommandsupportsthefollowinggeneraloptions.
Option --help -q -v Description Printsahelpmessagethatliststheoptionsforthiscommand. Runsinquietmodewithminimaloutput.Theoutputdoesnotdisplaythespecifiedoperationand arguments. Runsinverbosemode.

Format for Specifying Virtual Machines


Whenyourunvmware-cmd,thevirtualmachinepathisusuallyrequired.Youcanspecifythevirtualmachine usingoneofthefollowingformats:

Datastoreprefixstyle:'[ds_name] relative_path',forexample:
'[myStorage1] testvms/VM1/VM1.vmx'(Linux)

"[myStorage1] testvms/VM1/VM1.vmx" (Windows)

UUIDbasedpath: folder/subfolder/file,forexample:
'/vmfs/volumes/mystorage/testvms/VM1/VM1.vmx'(Linux)

"/vmfs/volumes/mystorage/testvms/VM1/VM1.vmx"(Windows)

Listing and Registering Virtual Machines


RegisteringorunregisteringavirtualmachinemeansaddingthevirtualmachinetothevCenterServeror ESX/ESXihostinventoryorremovingthevirtualmachine. IMPORTANTIfyouregisteravirtualmachinewithavCenterServersystem,andthenremoveitfromthe ESX/ESXihost,anorphanedvirtualmachineresults.Callvmware-cmd -s unregisterwiththevCenter Serversystemasthetargettoresolvetheissue. ThefollowingexamplescenariolistsallregisteredvirtualmachinesonavCenterServer,unregistersavirtual machine,andreregistersthevirtualmachine. To list, unregister, and register virtual machines 1 Runvmware-cmd -ltolistallregisteredvirtualmachinesonaserver.
vmware-cmd -H <vc_server> -U <login_user> -P <login_password> --vihost <esx_host> -l

ThecommandliststheVMXfileforeachvirtualmachine.
/vmfs/volumes/<storage>/winxpPro-sp2/winxpPro-sp2.vmx /vmfs/volumes/<storage>/RHEL-lsi/RHEL-lsi.vmx /vmfs/volumes/<storage>/VIMA0809/VIMA0809.vmx .....

90

VMware, Inc.

Chapter 8 Managing Virtual Machines

Runvmware-cmd -s unregistertoremoveavirtualmachinefromtheinventory.
vmware-cmd -H <vc_server> -U <login_user> -P <login_password> --vihost <esx_host> -s unregister /vmfs/volumes/Storage2/testvm/testvm.vmx

Thesystemreturns0toindicatesuccess,1toindicatefailure. NOTEWhenyourunagainstavCenterServersystem,youmustspecifythedatacenterandtheresource pooltoregisterthevirtualmachinein.Thedefaultdatacenterisha-datacenterandthedefaultresource poolisResources. WhenyourunagainstanESX/ESXihost,youusuallydonotspecifytheresourcepoolanddatacenter. However,iftwovirtualmachineswiththesamenameexistintworesourcepools,youmustspecifythe resourcepool. 3 4 Runvmware-cmd -lagaintoverifythatthevirtualmachinewasremovedfromtheinventory. Runvmware-cmd -s registertoaddthevirtualmachinebacktotheinventory.
vmware-cmd -H <vc_server> -U <login_user -P <login_password --vihost <esx_host> -s register /vmfs/volumes/Storage2/testvm/testvm.vmx

Thesystemreturns0toindicatesuccess,1toindicatefailure.

Retrieving Virtual Machine Attributes


vmware-cmdincludesanumberofoptionsforretrievinginformationaboutavirtualmachine.Eachoption requiresthatyouspecifythevirtualmachinepath(seeFormatforSpecifyingVirtualMachinesonpage 90). Youmustalsospecifyconnectionoptions,whichdifferfromothervCLIcommands(seeConnectionOptions forvmwarecmdonpage 89). Youcanusevmware-cmdoptionstoretrieveanumberofdifferentvirtualmachineattributes.

Thegetuptimeoptionretrievestheuptimeoftheguestoperatingsystemonthevirtualmachine,in seconds.
vmware-cmd -H <vc_system> -U <user> -P <password> --vihost <esx_host> /vmfs/volumes/Storage2/testvm/testvm.vmx getuptime getuptime() = 17921

Thegetproductinfo productoptionliststheVMwareproductthevirtualmachinerunson.
vmware-cmd -H <vc_system> -U <user> -P <password> --vihost <esx_host> /vmfs/volumes/Storage2/testvm/testvm.vmx getproductinfo product

Thereturnvalueisesx(VMwareESX),embeddedESX(VMwareESXi),orunknown.

Thegetproductinfo platformoptionliststheplatformthevirtualmachinerunson.
vmware-cmd -H <vc_system> -U <user> -P <password> --vihost <esx_host> /vmfs/volumes/Storage2/testvm/testvm.vmx getproductinfo platform

Thereturnvalueiswin32-x86(x86basedWindowssystem,linux-x86(x86basedLinuxsystem),or vmnix-x86(x86basedESX/ESXimicrokernel).

Thegetproductinfo build,getproductinfo majorversion,orgetproductinfo minorversion optionsretrieveversioninformation. Thegetstateoptionretrievestheexecutionstateofthevirtualmachine,whichcanbeon,off, suspended,orunknown.


vmware-cmd -H <vc_system> -U <user> -P <password> --vihost <esx_host> /vmfs/volumes/Storage2/testvm/testvm.vmx getstate getstate() = on

VMware, Inc.

91

vSphere Command-Line Interface Installation and Scripting Guide

ThegettoolslastactiveoptionindicateswhetherVMwareToolsisinstalledandwhethertheguest operatingsystemisrespondingnormally.
vmware-cmd -H <vc_system> -U <user> -P <password> --vihost <esx_host> /vmfs/volumes/Storage2/testvm/testvm.vmx gettoolslastactive

Thecommandreturnsanintegerindicatinghowmuchtimehaspassed,inseconds,sincethelast heartbeatwasdetectedfromtheVMwareToolsservice.Thisvalueisinitializedtozerowhenavirtual machinepowerson.Thevaluestaysatzerountilthefirstheartbeatisdetected.Afterthefirstheartbeat, thevalueisalwaysgreaterthanzerountilthevirtualmachineispowercycledagain.Thecommand returnsoneofthefollowing:


0VMwareToolsisnotinstalledornotrunning. 1Guestoperatingsystemisrespondingnormally. 5Intermittentheartbeat.Theremightbeaproblemwiththeguestoperatingsystem. 100Noheartbeat.Guestoperatingsystemmighthavestoppedresponding.

NOTEYouusuallyusethevmware-cmd guestinfooptiononlywhenVMwareSupportinstructsyoutodo so.Thecommandisthereforenotdiscussedinthisdocument.

Managing Snapshots with vmware-cmd


Asnapshotcapturestheentirestateofthevirtualmachineatthetimeyoutakethesnapshot. Virtualmachinestateincludesthefollowingaspectsofthevirtualmachine.

MemorystateContentsofthevirtualmachinesmemory. SettingsstateVirtualmachinesettings. DiskstateStateofallthevirtualmachinesvirtualdisks.

Whenyoureverttoasnapshot,youreturntheseitemstothestatetheywereinatthetimeyoutookthe snapshot.Ifyouwantthevirtualmachinetoberunningortobeshutdownwhenyoustartit,makesurethat itisinthatstatewhenyoutakethesnapshot. Youcanusesnapshotsasrestorationpointswhenyouinstallupdatepackages,orduringabranchingprocess, suchasinstallingdifferentversionsofaprogram.Takingsnapshotsensuresthateachinstallationbeginsfrom anidenticalbaseline.TheVirtualMachineAdministrationmanualdiscussessnapshotsindetail. IMPORTANTUsethevSphereClienttoreverttoanamedsnapshot.vmware-cmdonlysupportsrevertingto thecurrentsnapshot.

Taking Snapshots
Youcantakeasnapshotwhileavirtualmachineisrunning,shutdown,orsuspended.Ifyouareintheprocess ofsuspendingavirtualmachine,waituntilthesuspendoperationhasfinishedbeforetakingasnapshot. Ifavirtualmachinehasmultipledisksindifferentdiskmodes,youmustshutdownthevirtualmachinebefore takingasnapshot.Forexample,ifyouhaveaspecialpurposeconfigurationthatrequiresyoutousean independentdisk,youmustshutdownthevirtualmachinebeforetakingasnapshot. To take a snapshot 1 (Optional)Ifthevirtualmachinehasmultipledisksindifferentdiskmodes,shutdownthevirtual machine.
vmware-cmd -H <vc_system> -U <user> -P <password> --vihost <esx_host> /vmfs/volumes/Storage2/testvm/testvm.vmx stop soft

92

VMware, Inc.

Chapter 8 Managing Virtual Machines

(Optional)Checkthattheshutdownoperationhasbeencompleted.
vmware-cmd -H <vc_system> -U <user> -P <password> --vihost <esx_host> /vmfs/volumes/Storage2/testvm/testvm.vmx getstate

Runvmware-cmdwiththecreatesnapshotoption. Youmustspecifythedescription,quiesceflag(0or1)andmemoryflag(0or1).
vmware-cmd -H <vc_system> -U <user> -P <password> --vihost <esx_host> /vmfs/volumes/Storage2/testvm/testvm.vmx createsnapshot VM1Aug09 test snapshot August 09 0 0

Checkthatthevirtualmachinehasasnapshotusingthehassnapshotoption. Thecallreturns1ifthevirtualmachinehasasnapshotandreturns0otherwise.
vmware-cmd -H <vc_system> -U <user> -P <password> --vihost <esx_host> /vmfs/volumes/Storage2/testvm/testvm.vmx hassnapshot hassnapshot () = 1

Reverting and Removing Snapshots


Youcanusevmware-cmdtoreverttothecurrentsnapshotortoremoveasnapshot. IMPORTANTYoucannotusevmware-cmdtoreverttoanamedsnapshot.UsethevSphereClienttoreverttoa namedsnapshot. Runvmware-cmdwiththerevertsnapshotoptiontoreverttothecurrentsnapshot.Ifnosnapshotexists,the commanddoesnothingandleavesthevirtualmachinestateunchanged.
vmware-cmd -H <vc_system> -U <user> -P <password> --vihost <esx_host> /vmfs/volumes/Storage2/testvm/testvm.vmx revertsnapshot

Runvmware-cmdwiththeremovesnapshotsoptiontoremoveallsnapshotsassociatedwithavirtual machine.Ifnosnapshotexists,thecommanddoesnothing.
vmware-cmd -H <vc_system> -U <user> -P <password> --vihost <esx_host> /vmfs/volumes/Storage2/testvm/testvm.vmx removesnapshots

Powering Virtual Machines On and Off


Youcanstart,reboot,stop,andsuspendvirtualmachinesusingvmware-cmd.Youmustsupplyavalueforthe powerop_modeflag,whichcanbesoftorhard. IMPORTANTYoumusthavethecurrentversionofVMwareToolsinstalledandrunningintheguestoperating systemtouseasoftpoweroperation.

Softpoweroperations.Whenyouspecifysoftasthepowerop_modevalue,theresultofthecalldepends ontheoperation.
Operation Stop Reset Suspend Result vmware-cmdattemptstoshutdowntheguestoperatingsystem,andthenpowersoffthe virtualmachine. vmware-cmdattemptstoshutdowntheguestoperatingsystem,andthenrebootsthe virtualmachine. vmware-cmdattemptstorunascriptintheguestoperatingsystembeforesuspendingthe virtualmachine.

Hardpoweroperations.vmware-cmdimmediatelyandunconditionallyshutsdown,resets,orsuspends thevirtualmachine.

VMware, Inc.

93

vSphere Command-Line Interface Installation and Scripting Guide

Thefollowingexamplesillustratehowtousevmware-cmd.

StartUsethestartoptiontopoweronavirtualmachineortoresumeasuspendedvirtualmachine. Thepowerop_mode,eitherhardorsoft,isrequired.
vmware-cmd -H <vc_system> -U <user> -P <password> --vihost <esx_host> /vmfs/volumes/Storage2/testvm/testvm.vmx start soft

ResetWhenyouresetthevirtualmachinewiththesoftpower_opmode(thedefault),theguest operatingsystemisshutdownbeforethereset. a CheckthatVMwaretoolsisinstalledsothatyoucanresetthevirtualmachinewiththedefault power_opmode,whichissoft.


vmware-cmd -H <vc_system> -U <user> -P <password> --vihost <esx_host> /vmfs/volumes/Storage2/testvm/testvm.vmx gettoolslastactive

SeeRetrievingVirtualMachineAttributesonpage 91. b Usetheresetoptiontoshutdownandrestartthevirtualmachine.


vmware-cmd -H <vc_system> -U <user> -P <password> --vihost <esx_host> /vmfs/volumes/Storage2/testvm/testvm.vmx reset soft

IfVMwareToolsisnotcurrentlyinstalledonthevirtualmachine,youcanperformonlyahardreset operation.

SuspendYouhavetwooptionsforsuspendingavirtualmachine.

Thesuspendoptionwiththehardpoweropmodeunconditionallyshutsdownavirtualmachine.
vmware-cmd -H <vc_system> -U <user> -P <password> --vihost <esx_host> /vmfs/volumes/Storage2/testvm/testvm.vmx suspend hard

Thesuspendoptionwiththesoftpoweropmoderunsscriptsthatresultinagracefulshutdownof theguestoperatingsystemandshutsdownthevirtualmachine.VMwareToolsmustbeinstalledfor softpowerop_mode.


vmware-cmd -H <vc_system> -U <user> -P <password> --vihost <esx_host> /vmfs/volumes/Storage2/testvm/testvm.vmx suspend soft

Connecting and Disconnecting Virtual Devices


Youcanaddandremovevirtualdevicesbyusingtheconnectdeviceanddisconnectdeviceoptions.The selectedguestoperatingsystemdetermineswhichoftheavailabledevicesyoucanaddtoagivenvirtual machine. ThevirtualhardwarethatyouaddappearsinthehardwarelistthatisdisplayedintheVirtualMachine Propertieswizard. Youcanreconfigurevirtualmachinehardwarewhilethevirtualmachineisrunning,ifthefollowing conditionsaremet:

Thevirtualmachinehasaguestoperatingsystemthatsupportshotplugfunctionality.SeetheGuest OperatingSystemInstallationGuide. Thevirtualmachineisusinghardwareversion7.

Thefollowingexamplesillustrateconnectinganddisconnectingavirtualdevice.

TheconnectdeviceoptionconnectsthevirtualIDEdeviceCD/DVDDrive2tothespecifiedvirtual machine.
vmware-cmd -H <vc_system> -U <user> -P <password> --vihost <esx_host> /vmfs/volumes/Storage2/testvm/testvm.vmx connectdevice "CD/DVD Drive 2"

Thedisconnectdeviceoptiondisconnectsthevirtualdevice.
vmware-cmd -H <vc_system> -U <user> -P <password> --vihost <esx_host> /vmfs/volumes/Storage2/testvm/testvm.vmx disconnectdevice "CD/DVD Drive 2"

94

VMware, Inc.

Chapter 8 Managing Virtual Machines

Retrieving User Input


Youcanusetheansweroptiontopromptforuserinputandusetheinputinyourscript. Youmightusethisoptionwhenyouwanttoconfigureavirtualmachinebasedonauserssinput.Forexample: 1 2 Cloneavirtualmachineandprovidethedefaultvirtualdisktype. Whenyoupoweronthevirtualmachine,itpromptsforthedesiredvirtualdisktype.

Forcibly Stopping Virtual Machines


Insomecases,virtualmachinesdonotrespondtothenormalshutdownorstopcommands.Inthesecases,it mightbenecessarytoforciblyshutdownthevirtualmachines.Forciblyshuttingdownavirtualmachine mightresultinguestoperatingsystemdatalossandissimilartopullingthepowercableonaphysical machine. Youcanforciblystopvirtualmachinesthatarenotrespondingtonormalstopoperationwiththeesxcli vms vm killcommand. To forcibly stop a virtual machine 1 ListallrunningvirtualmachinesonthesystemtoseetheWorldIDofthevirtualmachineyouwantto stop.
esxcli vms vm list

Stopthevirtualmachinebyrunningthefollowingcommand.
esxcli vms vm kill --type <kill_type> --world-id <ID>

Thecommandsupportsthree--typeoptions.Trythetypessequentially(softbeforehard,hardbefore force).Thefollowingtypesaresupportedthroughthe--typeoption:

softGivestheVMXprocessachancetoshutdowncleanly(likekillorkill -SIGTERM) hardStopstheVMXprocessimmediately(likekill -9orkill -SIGKILL) forceStopstheVMXprocesswhenotheroptionsdonotwork.

Ifallthreeoptionsdonotwork,rebootyourESX/ESXihosttoresolvetheissue.

VMware, Inc.

95

vSphere Command-Line Interface Installation and Scripting Guide

96

VMware, Inc.

Managing Third-Party Storage Arrays with esxcli

Theesxclicommandisavailableasaserviceconsolecommand(noauthentication)onESXhostsandasa vCLIforbothESXandESXihosts.Thenamespacesandcommandsthatesxclimakesavailabledepend entirelyonthesystemonwhichitisinstalled.Runesxcli--helpforinformationonavailabilityonyour system.Becauseesxclioptionsdependcompletelyontheenvironment,nomanpageisavailable. IMPORTANTThischapterdiscussesthirdpartystoragemanagementoptions.Itisnotacompletereferenceto esxcli.SeeManagingPathPolicieswithesxclionpage 55,MaskingPathswithesxclicorestorage claimruleonpage 57,andManagingiSCSISessionsonpage 80foradditionalusesofesxcli.Seeesxcli CommandOverviewonpage 136foracompletereference. esxcliisnotincludedinthevSphereCommandLineReference.Usetheinformationinthismanualorthe commandlinehelpforinformation. ThischapterexplainshowtouseesxcliforPSA(pluggablestoragearchitecture)management.TheESX ConfigurationGuideandtheESXiConfigurationGuidediscussPSAfunctionalityindetail.Thosedocuments explainhowtousethevSphereClienttomanagethePSA,theassociatednativemultipathingplugin(NMP) andthirdpartypluginswiththevSphereClient. Thischapterusesthefollowingacronyms.
Acronym PSA NMP PSP SATP Meaning PluggableStorageArchitecture. NativeMultipathingPlugin.GenericVMwaremultipathingmodule. PathSelectionPlugin.Handlespathselectionforagivendevice. StorageArrayTypePlugin.Handlespathfailoverforagivenstoragearray.

Thechapterincludesthesetopics:

esxcliCommandSyntaxonpage 98 ManagingNMPwithesxclinmponpage 99 ManagingSATPswithesxclinmpsatponpage 102 ManagingClaimRuleswithesxclicorestorageclaimruleonpage 106

VMware, Inc.

97

vSphere Command-Line Interface Installation and Scripting Guide

esxcli Command Syntax


TheesxclivCLIcommandhasthefollowingsyntax:
esxcli <conn_options> <namespace> <app> <cmd> [cmd options] Option <conn_options> Description ConnectionparametersforthevCLImustprecedeallotherparameters,oryoumustperform authenticationinotherways.Forexample,youcanperformauthenticationbyusingvifastpass onvMA,orbyusingenvironmentvariables.SeevCLIConnectionOptionsonpage 23.esxcli doesnotsupportthecredentialstore. Namespace.Examplesincludethefollowingnamespaces:

<namespace>

nmpVMwarenativemultipathingcommands. swiscsiCommandsinthesoftwareiSCSInamespace. corestorageVMwarecorestoragecommands.

<app> <cmd> <cmd options>

Areawithinthenamespacetowhichthecommandapplies. Commandtobecalled. Commandoptions.

IncontrasttoothervCLIcommands,esxcliisnotaPerlscriptanddoesnotrunwitha.plextension.Only thecommandoptionssupportcorrespondingshortoptions.Therearenoshortoptionsforotherelements (namespace,app,orcommand). IMPORTANTYoucanrunesxcliwith--serverpointingtoanESX/ESXihost,butnotwith--server pointingtoavCenterServersystem. esxclidoesnotsupportcredentialstoreauthenticationorthe--credstoreoption. CommandlinehelpfortheesxclivCLIisavailableonaperlevelbasis.Youcancallhelpasfollows:


Command esxcli esxcli --help esxcli -? esxcli <conn_options> --help esxcli <conn_options> -? esxcli <conn_parms> <namespace> --help esxcli <conn_parms> <namespace> -? esxcli <conn_options> <namespace> <app> --help esxcli <conn_options> <namespace> <app> -? esxcli <conn_options> <namespace> <app> <command> --help esxcli <conn_options> <namespace> <app> <command> -? Example esxcli <Enter> esxcli --help esxcli -? esxcli --server S1 --help esxcli --server S1 -? esxcli --server S1 nmp --help esxcli --server S1 nmp -? esxcli --server S1 nmp device --help esxcli --server S1 nmp device -? esxcli --server S1 nmp device setpolicy --help esxcli --server S1 nmp device setpolicy -? Output Listsallsupportedname spacesonthissystem. Displayshelpforsupported connectionoptions. Displayshelpforsupported namespaces. Displayshelpforsupported appsforthisnamespace. Displayshelpforsupported commandsforthisapp.

Displayshelpforsupported optionsforthiscommand.

98

VMware, Inc.

Chapter 9 Managing Third-Party Storage Arrays with esxcli

Managing NMP with esxcli nmp


TheNMP(NativeMultipathingPlugin)isanextensiblemultipathingmodulethatESX/ESXisupportsby default.Youcanuseesxcli nmptomanagedevicesassociatedwithNMPandtosetpathpolicies. TheNMPsupportsallstoragearrayslistedontheVMwarestorageHardwareCompatibilityList(HCL)and providesapathselectionalgorithmbasedonthearraytype.TheNMPassociatesasetofphysicalpathswith astoragedevice(LUN).AStorageArrayTypePlugin(SATP)determineshowpathfailoverishandledfora specificstoragearray.APathSelectionPlugin(PSP)determineswhichphysicalpathisusedtoissueanI/O requesttoastoragedevice.SATPsandPSPsarepluginswithintheNMPplugin. IMPORTANTTheesxcli nmp bootoptionisinternaluseonlyandnotdiscussedinthisdocument.

Device Management with esxcli nmp device


ThedeviceoptionperformsoperationsondevicescurrentlyclaimedbytheVMwareNMPplugin.

esxcli nmp device list


ThelistcommandliststhedevicescontrolledbyVMwareNMPandshowstheSATPandPSPinformation associatedwitheachdevice.ToshowthepathsclaimedbyNMP,callesxcli nmp path list.
Options --device <device> -d <device> Description Filterstheoutputofthecommandtoshowinformationaboutasingledevice.Defaultisall devices.

esxcli nmp device setpolicy


ThesetpolicycommandsetsthePathSelectionPolicy(PSP)forthespecifieddevicetooneofthepolicies loadedonthesystem.
Options --default -E --device <device> -d <device> --psp <PSP> -P <PSP> Description SetsthePSPbacktothedefaultfortheSATPassignedtothisdevice. DevicetosetthePSPfor. PSPtoassigntothespecifieddevice.Callesxcli nmp psp listtodisplayallcurrently availablePSPs.SeeTable 51,SupportedPathPolicies,onpage 55. SeetheESXConfigurationGuideandtheESXiConfigurationGuideforadiscussionofpath policies.

TosetthepathpolicyforthespecifieddevicetoVMW_PSP_FIXED,runthefollowingcommand:
esxcli <conn_options> nmp device setpolicy --device naa.xxx --psp VMW_PSP_FIXED

Listing Paths with esxcli nmp path


UsethepathoptiontolistpathsclaimedbyNMP.Bydefault,thecommanddisplaysinformationaboutall pathsonalldevices.Youcanfilterinthefollowingways:

Onlyshowpathstoasingedevice(esxcli nmp path list --device <device>). Onlyshowinformationforasinglepath(esxcli nmp path list --path <path>andesxcli nmp path --device <device>).

Tolistdevices,callesxcli nmp device list.

VMware, Inc.

99

vSphere Command-Line Interface Installation and Scripting Guide

Managing Path Selection Policy Plugins with esxcli nmp psp


Useesxcli nmp psptomanageVMwarepathselectionpolicypluginsincludedwiththeVMwareNMP pluginandtomanagethirdpartyPSPs. IMPORTANTWhenusedwiththirdpartyPSPs,thesyntaxdependsonthethirdpartyPSPimplementation.

Retrieving PSP Information


Theesxcli nmp pspgetconfigcommandretrievesPSPconfigurationparameters.ThetypeofPSP determineswhetheryouspecify--device,--path,orboth.

Use--deviceforPSPsthataresettoVMW_PSP_RR,VMW_PSP_FIXEDorVMW_PSP_MRU. Use--pathforPSPsthataresettoVMW_PSP_FIXEDorVMW_PSP_MRU.Nopathconfigurationinformation isavailableforVMW_PSP_RR.

ToretrievePSPconfigurationparameters,runesxcli nmp psp getconfigwiththe--deviceorthe--path option.

RetrievethePSPconfigurationforthespecifieddevice.SeeTable 51,SupportedPathPolicies,on page 55.


esxcli <conn_options> nmp psp getconfig --device naa.xxx

RetrievethePSPconfigurationforthespecifiedpath.
esxcli <conn_options> nmp psp getconfig --path vmhba4:C1:T2:L23

Theesxcli nmp psp listcommandshowsthelistofPathSelectionPluginsonthesystemandabrief descriptionofeachplugin.

Setting Configuration Parameters for Third-Party Extensions


The esxcli nmp psp setconfigcommandsupportsfuturethirdpartyPSAexpansion.Thesetconfig commandsetsPSPconfigurationparametersforthosethirdpartyextensions. NOTEUseesxcli nmp roundrobin setconfigforotherpathpolicyconfiguration.SeeCustomizing RoundRobinSetupwithesxclinmproundrobinonpage 101. Theoptionsdependonthecurrentlysetpathpolicy.
Options --config <config_string> -c <config_string> --device <device> -d <device> --path <path> -p <path> Description Configurationstringtosetforthedevicespecifiedby--path.SeeTable 51, SupportedPathPolicies,onpage 55. Deviceforwhichyouwanttocustomizethepathpolicy. Pathforwhichyouwanttocustomizethepathpolicy.

Fixed Path Selection Policy Operations with esxcli nmp fixed


ThefixedoptiongetsandsetsthepreferredpathpolicyforNMPdevicesconfiguredtouseVMW_PSP_FIXED.

esxcli nmp fixed getpreferred


ThegetpreferredcommandretrievesthepreferredpathonaspecifieddevicethatisusingNMPandthe VMW_PSP_FIXEDPSP.
Options --device <device> -d <device> Description Deviceforwhichyouwanttogetthepreferredpath.Thisdevicemustbecontrolledbythe VMW_PSP_FIXEDPSP.

100

VMware, Inc.

Chapter 9 Managing Third-Party Storage Arrays with esxcli

Toreturnthepathconfiguredasthepreferredpathforthespecifieddevice,runthefollowingcommand:
esxcli <conn_options> nmp device getpreferred --device naa.xxx

esxcli nmp fixed setpreferred


ThesetpreferredcommandsetsthepreferredpathonaspecifieddevicethatisusingNMPandthe VMW_PSP_FIXEDpathpolicy.
Options --device <device> -d <device> Description Deviceforwhichyouwanttosetthepreferredpath.Thisdevicemustbecontrolledbythe VMW_PSP_FIXEDPSP. Useesxcli nmp device --listtolistthepoliciesforalldevices. --path <path> -p <path> Pathtosetasthepreferredpathforthespecifieddevice.

Tosetthepreferredpathforthespecifieddevicetovmhba3:C0:T5:L3,runthefollowingcommand:
esxcli <conn_options> nmp fixed setpreferred --device naa.xxx --path vmhba3:C0:T5:L3

Customizing Round Robin Setup with esxcli nmp roundrobin


TheroundrobinoptionsetsroundrobinpathoptionsonadevicecontrolledbytheVMW_PSP_RRPSP. To specify and customize round robin path policies 1 Setthepathpolicytoroundrobin.
esxcli <conn_options> nmp device setpolicy --device naa.xxx --psp VMW_PSP_RR

Specifywhentoswitchpaths. YoucanchoosethenumberofI/Ooperations,numberofbytes,andwhetheractiveunoptimizedpathsare used(seeesxclinmproundrobinsetconfigonpage 101).Forexample:


esxcli <conn_options> nmp roundrobin setconfig --type "bytes" -B 12345 --device naa.xxx

Setsthedevicespecifiedby--devicetoswitchtothenextpatheachtime12345byteshavebeensent alongthecurrentpath.
esxcli <conn_options> nmp roundrobin setconfig --type=iops --iops 4200 --device naa.xxx

Setsthedevicespecifiedby--devicetoswitchafter4200I/Ooperationshavebeenperformedonapath.

esxcli nmp roundrobin getconfig


ThegetconfigcommandretrievespathselectionsettingsforadevicethatisusingtheroundrobinPSP.
Options -d <device> --device <device> Description Devicetogetroundrobinpropertiesfor.

esxcli nmp roundrobin setconfig


ThesetconfigcommandspecifiesunderwhichconditionsadevicethatisusingtheVMW_PSP_RRPSP changestoadifferentpath.Youcanuse--bytesor--iopstospecifywhenthepathshouldchange.
Options --bytes -B --device -d Description NumberofbytestosendalongonepathforthisdevicebeforethePSPswitchestothenextpath. Youcanusethisoptiononlywhen--typeissettobytes. Devicetosetroundrobinpropertiesfor.Thisdevicemustbecontrolledbytheroundrobin (VMW_PSP_RR)PSP.

VMware, Inc.

101

vSphere Command-Line Interface Installation and Scripting Guide

Options --iops -I --type -t

Description NumberofI/OoperationstosendalongonepathforthisdevicebeforethePSPswitchestothe nextpath.Youcanusethisoptiononlywhen--typeissettoiops. Typeofroundrobinpathswitchingtoenableforthisdevice.Validvaluesfortypeare:


bytes:Setthetriggerforpathswitchingbasedonthenumberofbytessentdownapath. default:Setthetriggerforpathswitchingbacktodefaultvalues. iops:SetthetriggerforpathswitchingbasedonthenumberofI/Ooperationsonapath.

Anequalsign(=)beforethetypeordoublequotesaroundthetypeareoptional. --useANO -U Ifsetto1,theroundrobinPSPincludespathsintheactive,unoptimizedstateintheroundrobin set.Ifsetto0,thePSPusesactive,unoptimizedpathsonlyifnoactiveoptimizedpathsare available.Otherwise,thePSPincludesonlyactiveoptimizedpathsintheroundrobinpathset.

Managing SATPs with esxcli nmp satp


ThesatpoptionmanagesSATPsandallowsyoutoperformthefollowingtasks:

Retrieveandsetconfigurationparameters AddanddeleterulesfromthelistofclaimrulesforaspecifiedSATP SetthedefaultPSPforaspecifiedSATP ListSATPsthatarecurrentlyloadedintoNMPandtheassociatedclaimrules

Bydefault,thedefaultSATPforanactiveactiveFCarraywithavendorandmodelnotlistedintheSATPrules isVMW_SATP_DEFAULT_AA.

Retrieving Information About SATPs


ThelistcommandliststheSATPsthatarecurrentlyloadedintotheNMPsystemanddisplaysinformation aboutthoseSATPs.ThiscommandsupportsnooptionsanddisplaysinformationabouttheseSATPs.
esxcli <conn_options> nmp --satp|-s list

ThelistrulescommandliststheclaimrulesforSATPs. esxcli <conn_options> nmp --satp|-s listrules

Adding SATP Rules


Claimrulesspecifythatastoragedevicethatusesacertaindriverortransportorhasacertainvendorormodel shoulduseacertainSATP.Theaddrulecommandaddsarulethatperformssuchamappingtothelistofclaim rules.Thedeleterulecommanddeletesanexistingrule.Theoptionsyouspecifydefinetherule.For example,thefollowingcommandspecifiesthatifapathhasvendorVMWAREandmodelVirtual,thePSA assignsittotheVMW_SATP_LOCALSATP.
esxcli <conn_options> nmp satp addrule --satp="VMW_SATP_LOCAL" --vendor="VMWARE" --model="Virtual" --description="VMware virtual disk Option --driver -D --device -d --force -f --model -M ModelstringtosetwhenaddingtheSATPclaimrule.Canbethemodelnameorapattern ^mod*,whichmatchesalldevicesthatstartwithmod.Thatis,thepatternsuccessfullymatches mod1andmodz,butnotmymod1. Thecommandsupportsthestart/end(^)andwildcard(*)functionalitybutnootherregular expressions. DevicetosetwhenaddingSATPclaimrules.Devicerulesaremutuallyexclusivewith vendor/modelanddriverrules. Forceclaimrulestoignorevaliditychecksandinstalltheruleevenifchecksfail. Description DriverstringtosetwhenaddingtheSATPclaimrule.

102

VMware, Inc.

Chapter 9 Managing Third-Party Storage Arrays with esxcli

Option --transport -R --vendor -V --satp -s --claim-option c --description -e --option -o --psp -P --psp-option -O

Description TransportstringtosetwhenaddingtheSATPclaimrule.DescribesthetypeofstorageHBA, forexample,iscsiorfc. VendorstringtosetwhenaddingtheSATPclaimrule. SATPforwhichtheruleisadded. ClaimoptionstringtosetwhenaddingtheSATPclaimrule. DescriptionstringtosetwhenaddingtheSATPclaimrule. OptionstringtosetwhenaddingtheSATPclaimrule. DefaultPSPfortheSATPclaimrule. PSPoptionsfortheSATPclaimrule.

ThefollowingexamplesillustrateaddingSATPrules.

AddaSATPrulethatspecifiesthatdiskswithvendorstringVMWAREandmodelstringVirtualshouldbe addedtoVMW_SATP_LOCAL.
esxcli <conn_options> nmp satp addrule --satp="VMW_SATP_LOCAL" --vendor="VMWARE" --model="Virtual" --description="VMware virtual disk"

AddaSATPrulethatspecifiesthatdiskswiththedriverstringsomedrivershouldbeaddedto VMW_SATP_LOCAL.
esxcli <conn_options> nmp satp addrule --satp="VMW_SATP_LOCAL" --driver="somedriver"

AddarulethatspecifiesthatallstoragedeviceswithvendorstringABCandamodelnamethatstartswith 120shoulduseVMW_SATP_DEFAULT_AA(VMW_SATP_DEFAULT_AAisanexample).
esxcli <conn_options> nmp satp addrule --satp VMW_SATP_DEFAULT_AA --vendor="ABC" --model="^120*

Deleting SATP Rules


ThedeleterulecommanddeletesanexistingSATPrule.Theoptionsyouspecifydefinetheruletodelete. TheoptionslistedforAddingSATPRulesonpage 102aresupported. ThefollowingexampledeletestherulethatassignsdeviceswithvendorstringVMWAREandmodelstring VirtualtoVMW_SATP_LOCAL.
C:\WINDOWS\system32>esxcli <conn_options> nmp satp deleterule --satp="VMW_SATP_LOCAL" --vendor="VMWARE" --model="Virtual"

Retrieving and Setting SATP Configuration Parameters


Theesxcli nmp satp getconfigcommandretrievesperpathorperdeviceSATPconfiguration parameters.ForeachSATP,specifyeither--deviceor--path,butnotboth.

IMPORTANTNotallSATPssupportgetconfigfordevicesorgetconfigforpaths.

VMware, Inc.

103

vSphere Command-Line Interface Installation and Scripting Guide

UsethiscommandtoretrieveperdeviceorperpathSATPconfigurationparameters,andtoseewhetheryou cansetcertainconfigurationparametersforadeviceorpath.Forexample:
# esxcli --config /my-config-file nmp satp getconfig --device naa.60019b9000dd21c500002d974a0acfa0 SATP VMW_SATP_LSI does not support device configuration. # esxcli --config /my-config-file nmp satp getconfig -path vmhba1:C0:T0:L8 INIT,AVT OFF,v5.4,DUAL ACTIVE,ESX FAILOVER

Theesxcli nmp satp setconfigcommandsetsconfigurationparametersforthirdpartySATPsthatare loadedintothesystem,iftheysupportdeviceconfiguration.YoucansetperpathorperdeviceSATP configurationparameters.Thecommandsetstheconfigurationforaspecifieddeviceorpath,regardlessofthe SATPcurrentlyassociatedwiththatdeviceorpath.VMwaresupportsthefollowingconfigurationstrings. OtherstringsmightbesupportedbyathirdpartySATP.


Options --config -c Description Configurationstringtosetforthepathspecifiedby--pathorthedevicespecifiedby --device. YoucansettheconfigurationforthefollowingSATPs:

VMW_SATP_ALUA_CX VMW_SATP_ALUA VMW_SATP_CX VMW_SATP_INV navireg_onstartsautomaticregistrationofthedevicewithNavisphere. navireg_offstopstheautomaticregistrationofthedevice. ipfilter_onstopsthesendingofthehostnameforNavisphereregistration.Usedifhost isknownaslocalhost. ipfilter_offenablesthesendingofthehostnameduringNavisphereregistration.

Youcanspecifyoneofthefollowingdeviceconfigurationstrings:

--device -d --path -p

DevicetosetSATPconfigurationfor.NotallSATPssupportthesetconfigoptionondevices. PathtosetSATPconfigurationfor.NotallSATPssupportthesetconfigoptiononpaths.

Setting the Default PSP


Theesxcli nmp satp setdefaultcommandsetsthedefaultPSPforaspecifiedSATP.
Options --psp -P --satp -s Description DefaultpathselectionpolicytosetfortheSATPspecifiedby--satp. SATPnameforthepluginforwhichyouwanttosetthedefaultPSP.

Path Claiming with esxcli corestorage claiming


Theesxcli corestorage claimingoptionincludesanumberoftroubleshootingcommands.These commandsarenotpersistentandareusefulonlytodeveloperswhoarewritingPSApluginsor troubleshootingasystem.IfI/Oisactiveonthepath,unclaimandreclaimactionsfail. IMPORTANTThehelpforesxcli corestorage claiming includestheautoclaimcommand.Donotuse thiscommandunlessinstructedtodosobyVMwaresupportstaff.

esxcli corestorage claiming reclaim


Thereclaimtroubleshootingcommandfirstattemptstounclaimallpathstoadevice.Thecommandthen runstheloadedclaimrulesoneachoftheunclaimedpathstoreclaimthosepaths.Itisnormalforthis commandtonotsucceedifadeviceisinuse.OnlyPSAplugindevelopersoradministratorswhotroubleshoot PSApluginsusethiscommand.
104 VMware, Inc.

Chapter 9 Managing Third-Party Storage Arrays with esxcli

Options --device <device> -d <device> --help

Description Nameofthedeviceonwhichallpathsarereclaimed. Displaysthehelpmessage.

esxcli corestorage claiming unclaim


Theunclaimcommandunclaimsapathorsetofpaths,disassociatingthosepathsfromaPSAplugin.Itis normalforthiscommandstonotsucceedifthedeviceisinuse. Youcanonlyunclaimactivepathswithnooutstandingrequests.YoucannotunclaimtheESXiUSBpartition ordeviceswithVMFSvolumesonthem.Itisthereforenormalforthiscommandtofail,especiallywhenyou specifyapluginoradaptertounclaim. Unclaimingdoesnotpersist.Periodicpathclaimingreclaimsunclaimedpathsunlessclaimrulesare configuredtomaskapath(seeMaskingPathswithesxclicorestorageclaimruleonpage 57). IMPORTANTTheunclaimcommandunclaimspathsassociatedwithadevice.Youcannotusethiscommand tounclaimpathsassociatedwiththeMASK_PATHpluginbecausethosepathsarenotassociatedwitha device.
Options --adapter <adapter> -A <adapter> --channel <channel> -C <channel> --claimrule-class <cl> -c <cl> --device <device> -d <device> --driver <driver> -D <driver> --lun <lun_number> -L <lun_number> --model <model> -m <model> --path <path> -p <path> --plugin <plugin> -P Description If--typeissettolocation,specifiesthenameoftheHBAforthepathsthatyouwantto unclaim.Ifyoudonotspecifythisoption,unclaimingrunsonpathsfromalladapters. If--typeissettolocation,specifiestheSCSIchannelnumberforthepathsthatyouwant tounclaim.Ifyoudonotspecifythisoption,unclaimingrunsonpathsfromallchannels. Claimruleclasstouseinthisoperation.YoucanspecifyMP(Multipathing),Filter,orVAAI. Multipathingisthedefault.FilterisusedonlyforVAAI.Specifyclaimrulesforboth VAAI_FILTERandVAAIplugintouseit. If--typeissettodevice,attemptstounclaimallpathstothespecifieddevice.Ifthereare activeI/Ooperationsonthespecifieddevice,atleastonepathcannotbeunclaimed. If--typeisdriver,unclaimsallpathsspecifiedbythisHBAdriver. If--typeislocation,specifiestheSCSILUNforthepathstounclaim.Ifyoudonotspecify --lun,unclaimingrunsonpathswithanyLUNnumber. If--typeisvendor,attemptstounclaimallpathstodeviceswithspecificmodelinformation (formultipathingplugins)orunclaimthedeviceitself(forfilterplugins).Ifthereareactive I/Ooperationsonthisdevice,atleastonepathfailstounclaim. If--typeispath,unclaimsapathspecifiedbyitspathUIDorruntimename. If--typeisplugin,unclaimsallpathsforaspecifiedmultipathplugin. <plugin>canbeanyvalidPSApluginonthesystem.BydefaultonlyNMPandMASK_PATH areavailable,butadditionalpluginsmightbeinstalled. If--typeislocation,unclaimsthepathswiththeSCSItargetnumberspecifiedbytarget. Ifyoudonotspecify--target,unclaimingrunsonpathsfromalltargets. Typeofunclaimoperationtoperform.Validvaluesarelocation,path,driver,device, plugin,andvendor. If--typeisvendor,attemptstounclaimallpathstodeviceswithspecificvendorinfo(for multipathingplugins)orunclaimthedeviceitself(forfilterplugins).Ifthereareanyactive I/Ooperationsonthisdevice,atleastonepathfailstounclaim

--target <target> -T <target> --type <type> -t <type> --vendor <vendor> -v <vendor>

Thefollowingtroubleshootingcommandunclaimsallpathstovmhba1.Runvicfg-mpath <conn_options> -ltoverifythecommandsucceeded.


esxcli <conn_options> corestorage claiming unclaim --type location -A vmhba1

VMware, Inc.

105

vSphere Command-Line Interface Installation and Scripting Guide

Managing Claim Rules with esxcli corestorage claimrule


ThePSAusesclaimrulestodeterminewhichmultipathingmoduleshouldclaimthepathstoaparticular deviceandtomanagethedevice.esxclicorestorage claimrulemanagesclaimrules. ClaimrulemodificationdoesnotoperateontheVMkerneldirectly.Insteaditoperatesontheconfiguration filebyaddingandremovingrules. To change the current claim rules in the VMkernel 1 2 Runoneoftheesxcli corestorageclaimrulemodificationcommands(add,remove,ormove). Runesxcli corestorage claimrule loadtoreplacethecurrentrulesintheVMkernelwiththe modifiedrulesfromtheconfigurationfile.

Youcanalsorunesxcli corestorage claimrule pluginlisttolistallplugins.

Adding Claim Rules with esxcli corestorage claimrule add


Theaddcommandaddsaclaimruletothesetofclaimrulesonthesystem.Youcanusethiscommandtoadd newclaimrulesortomaskapathusingtheMASK_PATHclaimrule.SeeMaskingPathswithesxclicorestorage claimruleonpage 57.Youmustloadtherulesafteryouaddthem.
Options --adapter <adapter> -A <adapter> --autoassign -u --claimrule-class <cl> -c <cl> Addsaclaimrulebasedonitscharacteristics.Therulenumberisnotrequired. Claimruleclasstouseinthisoperation.YoucanspecifyMP(default),Filter,orVAAI. Toconfigurehardwareaccelerationforanewarray,addtwoclaimrules,oneforthe VAAIfilterandanotherfortheVAAIplugin.SeetheFibreChannelSANConfiguration GuideandtheiSCSISANConfigurationGuidefordetailedinstructions. Channelofthepathstouse.Validonlyif--typeislocation. DriverfortheHBAofthepathstouse.Validonlyif--typeisvendor. Forceclaimrulestoignorevaliditychecksandinstalltherule. LUNofthepathstouse.Validonlyif--typeislocation. Modelofthepathstouse.Validonlyif--typeisvendor. ValidvaluesarevaluesoftheModelstringfromtheSCSIinquirystring.Run vicfg-scsidevs <conn_options> -loneachdevicetoseemodelstringvalues. PSAplugintouse.Currently,thevaluesareNMPorMASK_PATH,butthirdpartiescan shiptheirownPSApluginsinthefuture. MASK_PATHreferstothepluginMASK_PATH_PLUGIN.Thecommandaddsclaimrules forthispluginiftheuserwantstomaskthepath. ESX3.5includestheMaskLUNsadvancedconfigurationoption.Thisoptionisnot availableinESX/ESXi4.IthasbeenreplacedbytheMASK_PATH_PLUGIN.Youcanadd aclaimrulethatcausestheMASK_PATH_PLUGINtoclaimthepathtomaskapathor LUNfromtheESX/ESXihost.SeeMaskingPathswithesxclicorestorageclaimrule onpage 57. --rule <rule_ID> -r <rule_ID> --target <target> -T <target> RuleIDtouse.Runesxcli corestorage claimrule listtoseetheruleID.The ruleIDindicatestheorderinwhichtheclaimruleistobeevaluated.Userdefined claimrulesareevaluatedinnumericorderstartingwith101. Targetofthepathstouse.Validonlyif--typeislocation. Description Adapterofthepathstouse.Validonlyif--typeislocation.

--channel <channel> -C <channel> --driver <driver> -D <driver> --force -f --lun <lun_number> -L <lun_number> --model <model> -M <model> --plugin -P

106

VMware, Inc.

Chapter 9 Managing Third-Party Storage Arrays with esxcli

Options --transport <transport> -R <transport>

Description Transportofthepathstouse.Validonlyif--typeistransport.Thefollowingvalues aresupported:


blockblockstorageconnection fcFibreChanneltransmission iscsivendoriSCSIconnection iscsinotcurrentlyused ideIDEstorageconnection sasSASstorageconnection sataSATAstorageconnection usbUSBstorageconnection parallelparalleltransmission unknown

--type <type> -t <type> --vendor -V

Typeofmatchingtousefortheoperation.Validvaluesarevendor,location,driver, andtransport. Vendorofthepathstouse.Validonlyif--typeisvendor. ValidvaluesarevaluesofthevendorstringfromtheSCSIinquirystring.Run vicfg-scsidevs <conn_options> -loneachdevicetoseevendorstringvalues.

Thefollowingexamplesillustrateaddingclaimrules:

Addrule321,whichclaimsthepathonadaptervmhba0,channel0,target0,LUN0fortheNMPplugin.
esxcli <conn_options> corestorage claimrule add -r 321 -t location -A vmhba0 -C 0 -T 0 -L 0 -P NMP

Addrule429,whichclaimsallpathsprovidedbyanadapterwiththemptscsidriverfortheMASK_PATH plugin.
esxcli <conn_options> corestorage claimrule add -r 429 -t driver -D mptscsi -P MASK_PATH

Addrule914,whichclaimsallpathswithvendorstringVMWAREandmodelstringVirtualfortheNMP plugin.
esxcli <conn_options> corestorage claimrule add -r 914 -t vendor -V VMWARE -M Virtual -P NMP

Addrule1015,whichclaimsallpathsprovidedbyFCadaptersfortheNMPplugin.
esxcli <conn_options> corestorage claimrule add -r 1015 -t transport -R fc -P NMP

Converting ESX 3.5 LUN Masks to Claim Rule Format


TheconvertcommandconvertsLUNmasksinESX3.5format(/adv/Disk/MaskLUNs)toclaimruleformat. ThecommandwritestheconvertedlistanderasestheoldLUNmaskdata. To convert ESX 3.5 format LUN masks to claim rule format 1 Runesxcli corestorage claimrule convertwithoutoptions. Thatcalldisplaysthelistofclaimrulesthatresultfromtheconversion.Forexample: Rule 120 121 122 2 Plugin MASK_PATH MASK_PATH MASK_PATH HbaName vmhba11 vmhba11 vmhba4 Controller 0 0 0 Target 0 0 2 LUN 11 10 1

Runesxcli corestorage claimrule convert --committoactuallycommitthechange.

VMware, Inc.

107

vSphere Command-Line Interface Installation and Scripting Guide

WhenyouconvertLUNmaskingtotheclaimruleformatafteranupgradefromESX/ESXi3.5toESX/ESXi4.x, thiscommandconvertsthe/adv/Disk/MaskLUNsadvancedconfigurationentryintheesx.conffiletoclaim ruleswithMASK_PATHastheplugin. IMPORTANTThisconversiondoesnotworkforallinputMaskLUNvariations.Forexample,roleconversion forsoftwareiSCSILUNsisnotsupported. Inspectthelistofgeneratedclaimrulescarefullybeforeyoucommitthembyusing--commit. Table 9-1. esxcli corestorage claimrule convert Options
Options --commit -C Description ForcesLUNmaskconfigurationchangestobesaved.Ifyoucallthecommandwithoutthis parameter,changesarenotsaved,andyoucanfirstinspectthegeneratedclaimrules.

Deleting Claim Rules with esxcli corestorage claimrule delete


Thedeletecommanddeletesaclaimrulefromthesetofclaimrulesonthesystem. IMPORTANTBydefault,thePSAclaimrule101masksDellarraypseudodevices.Donotdeletethisrule, unlessyouwanttounmaskthesedevices.
Option --rule <rule_ID> -r <rule_ID> Description IDoftheruletobedeleted.Runesxcli corestorage claimrule listtoseetheruleID.

Thefollowingexampledeletesrule1015.
esxcli <conn_options> corestorage claimrule delete -r 1015

Listing Claim Rules with esxcli corestorage claimrule list


Thelistcommandlistsallclaimrulesonthesystem.Youcanspecifytheclaimruleclassasanargument.
Option --claimrule-class <cl> -c <cl> Description Claimruleclasstouseinthisoperation.YoucanspecifyMP(Multipathing),Filter,or VAAI.Multipathingisthedefault.FilterisusedonlyforVAAI.Specifyclaimrulesfor bothVAAI_FILTERandVAAIplugintouseit.

Youcanrunthecommandasfollows.Theequalsignisoptional,sobothformsofthecommandhavethesame result.
esxcli --config /vmc-store09 corestorage claimrule list -c Filter esxcli --config /vmc-store09 corestorage claimrule list --claimrule-class=Filter

Loading Claim Rules with esxcli corestorage claimrule load


Theloadcommandloadsclaimrulesfromtheesx.confconfigurationfileintotheVMkernel.Developersand experiencedstorageadministratorsmightusethiscommandforboottimeconfiguration. Thiscommandhasnooptions,italwaysloadsallclaimrulesfromesx.conf.

108

VMware, Inc.

Chapter 9 Managing Third-Party Storage Arrays with esxcli

Moving Claim Rules with esxcli corestorage claimrule move


ThemovecommandmovesaclaimrulefromoneruleIDtoanother.
Options --claimrule-class <cl> -c <cl> --new-rule <rule_ID> -n <rule_ID> --rule <rule_ID> -r <rule_ID> Description Claimruleclasstouseinthisoperation. NewruleIDyouwanttogivetotherulespecifiedbythe--ruleoption. IDoftheruletobedeleted.Runesxcli corestorage claimrule listtodisplay theruleID.

Thefollowingexamplerenamesrule1016torule1015anddeletesrule1016.
esxcli <conn_options> corestorage claimrule move -r 1015 -n 1016

esxcli corestorage claimrule run


Theruncommandrunspathclaimingrules.Thiscommandisfortroubleshootingandboottime configuration.
Options --adapter <adapter> -A <adapter> --channel <channel> -C <channel> --claimrule-class -c --lun <lun> -L <lun> --path <path_UID> -p <path_UID> --target <target> -T <target> --type <location|path|all> -t <location|path|all> --wait -w Description If--typeislocation,nameoftheHBAforthepathstoruntheclaimruleson.To runclaimrulesonpathsfromalladapters,omitthisoption. If--typeislocation,valueoftheSCSIchannelnumberforthepathstorunthe claimruleson.Torunclaimrulesonpathswithanychannelnumber,omitthis option. Claimruleclasstouseinthisoperation. If--typeislocation,valueoftheSCSILUNforthepathstorunclaimruleson.To runclaimrulesonpathswithanyLUN,omitthisoption. If--typeispath,thisoptionindicatestheuniquepathidentifier(UID)orthe runtimenameofapathtorunclaimruleson. If--typeislocation,valueoftheSCSItargetnumberforthepathstorunclaim ruleson.Torunclaimrulesonpathswithanytargetnumber,omitthisoption Typeofclaimtoperform.Bydefault,usesall,whichmeansclaimrulesrunwithout restrictiontospecificpathsorSCSIaddresses.Validvaluesarelocation,path,and all. Ifthisoptionisincluded,theclaimwaitsforpathstosettlebeforerunningtheclaim operation.Inthatcase,thesystemdoesnotstarttheclaimingprocessuntilitislikely thatallpathsonthesystemhaveappearedbeforestartingtheclaimprocess. Aftertheclaimingprocesshasstarted,thecommanddoesnotreturnuntildevice registrationhascompleted. Ifyouaddorremovepathsduringtheclaimingorthediscoveryprocess,thisoption mightnotworkcorrectly.Youcanusethisoptiononlyifyoualsouse--typeall.

VMware, Inc.

109

vSphere Command-Line Interface Installation and Scripting Guide

110

VMware, Inc.

10

Managing vSphere Networking

10

ThevSphereCLInetworkingcommandsallowyoutomanagethevSpherenetworkservices.Youcanconnect virtualmachinestothephysicalnetworkandtoeachotherandconfigurevNetworkStandardSwitchesand vNetworkDistributedSwitches.YoucanalsosetupyourvSphereenvironmenttoworkwithexternal networkssuchasSNMPorNTP. Thischapterincludesthefollowingtopics:


IntroductiontovSphereNetworkingonpage 111 SettingUpvSphereNetworkingwithvNetworkStandardSwitchesonpage 113 SettingUpvSphereNetworkingwithvNetworkDistributedSwitchonpage 118 ManagingStandardNetworkingServicesinthevSphereEnvironmentonpage 119 UsingvicfgipsecforSecureNetworkingonpage 121

Introduction to vSphere Networking


AtthecoreofvSphereNetworkingarevirtualswitches.vSpheresupportsstandardswitches(vSS)and vNetworkDistributedSwitch(vDS).Eachvirtualswitchhasapresetnumberofportsandoneormoreport groups. Virtualswitchesallowyourvirtualmachinestoconnecttoeachotherandtoconnecttotheoutsideworld.

Whentwoormorevirtualmachinesareconnectedtothesamevirtualswitch,networktrafficbetween themisroutedlocally. Whenvirtualmachinesareconnectedtoavirtualswitchthatisconnectedtoanuplinkadapter,each virtualmachinecanaccesstheexternalnetworkthroughthatuplink.Theadaptercanbeanuplink connectedtoavSSoradvUplinkconnectedtoavDS.

VirtualswitchesallowyourESX/ESXihosttomigratevirtualmachineswithVMwareVMotionandtouseIP storagethroughVMkernelnetworkinterfaces.

UsingVMotion,youcanmigraterunningvirtualmachineswithnodowntime.YoucanenableVMotion withvicfg-vmknic --enable-vmotion. IPstoragereferstoanyformofstoragethatusesTCP/IPnetworkcommunicationasitsfoundation,which includesiSCSIandNFSforESX/ESXi.Becausethesestoragetypesarenetworkbased,theycanusethe sameVMkernelinterfaceandportgroup.

ThenetworkservicesthattheVMkernelprovides(iSCSI,NFS,andVMotion)useaTCP/IPstackinthe VMkernel.ThisTCP/IPstackiscompletelyseparatefromtheTCP/IPstackusedintheESXserviceconsole. TheVMkernelTCP/IPstackisalsoseparatefromtheguestoperatingsystemsnetworkstack.Eachofthese stacksaccessesvariousnetworksbyattachingtooneormoreportgroupsononeormorevirtualswitches.

VMware, Inc.

111

vSphere Command-Line Interface Installation and Scripting Guide

Networking Using vNetwork Standard Switches


vNetworkStandardSwitches(vSS)allowyoutoconnectvirtualmachinestotheoutsideworld. Figure 10-1. Networking with vNetwork Standard Switches
VM VM VM Network C VM VM

C vSwitch

port groups

C vSwitch

3
Host2 virtual

Host1 Host1 physical network adapters

Host2 physical

physical network

Figure 101showstherelationshipbetweenthephysicalandvirtualnetworkelements.Thenumbersmatch thoseinthefigure.

AssociatedwitheachESX/ESXihostareoneormoreuplinkadapters(1).Uplinkadaptersrepresentthe physicalswitchestheESX/ESXihostusestoconnecttothenetwork.Youcanmanageuplinkadapters usingthevicfg-nicsvCLIcommand.SeeManagingUplinkAdapterswithvicfgnicsonpage 116. EachuplinkadapterisconnectedtoavSS(2).YoucanmanageavSSandassociateitwithuplinkadapters byusingthevicfg-vswitchvCLIcommand.SeeSettingUpVirtualSwitchesandAssociatingaSwitch withaNetworkInterfaceonpage 114. AssociatedwiththevSSareportgroups(3).Portgroupisauniqueconceptinthevirtualenvironment. Youcanconfigureportgroupstoenforcepoliciesthatprovideenhancednetworkingsecurity,network segmentation,betterperformance,highavailability,andtrafficmanagement.Youcanusethe vicfg-vswitchcommandtoassociateavSSwithaportgroup,andthevicfg-vmkniccommandto associateaportgroupwithaVMkernelnetworkinterface. TheVMkernelTCP/IPnetworkingstacksupportsiSCSI,NFS,andVMotionandhasanassociated VMkernelnetworkinterface.YouconfigureVMkernelnetworkinterfaceswithvicfg-vmknic.See AddingandModifyingVMkernelNetworkInterfaceswithvicfgvmkniconpage 117.Separate VMkernelnetworkinterfacesareoftenusedforseparatetasks,forexample,youmightdevoteone VMkernelNetworkinterfacecardtoVMotiononly.VirtualmachinesruntheirownsystemsTCP/IP stacksandconnecttotheVMkernelattheEthernetlevelthroughvirtualswitches.

112

VMware, Inc.

Chapter 10 Managing vSphere Networking

Networking Using vNetwork Distributed Switches


Whenyouwanttoconnectavirtualmachinetotheoutsideworld,youcanuseavSSoravDS.WithavDS,the virtualmachinecanmaintainitsnetworksettingsevenifitismigratedtoadifferenthost. Figure 10-2. Networking with vNetwork Distributed Switches
VM VM VM Network C dvPort groups A B C D E F G H I J VM VM

vNetwork Distributed Switch Host1 Host1 dvUplinkA dvUplinkB dvUplinkA

3
dvUplinkB

Host2

virtual

Host2 physical

1
physical network adapters

physical network

Eachphysicaladapter(1)onthehostispairedwithadvUplinkadapter(2),whichrepresentstheuplink tothevirtualmachine.WithvDS,thevirtualmachinenolongerdependsonthehostsphysicaluplinkbut onthe(virtual)dvUplink.YoucanmanageadvUplinkusingthevSphereClientorvicfg-vswitch. ThevDSitself(3)functionsasasinglevirtualswitchacrossallassociatedhosts.Becausetheswitchisnot associatedwithasinglehost,virtualmachinescanmaintainconsistentnetworkconfigurationasthey migratefromonehosttoanother. LikeavSS,eachvDSisanetworkhubthatvirtualmachinescanuse.AvDScanroutetrafficinternally betweenvirtualmachinesorlinktoanexternalnetworkbyconnectingtophysicalnetworkadapters.You createavDSusingthevSphereClientUI,butcanmanagesomeaspectsofavDSusingvicfg-vswitch. SeeSettingUpVirtualSwitchesandAssociatingaSwitchwithaNetworkInterfaceonpage 114.

EachvDScanhaveoneormoredvPortgroups(4)assignedtoit.dvPortgroupsaggregatemultipleports underacommonconfigurationandprovideastableanchorpointforvirtualmachinesconnectingto labelednetworks. JustasavSS,vDSsupportsusingoneormoreVMkernelnetworkinterfaces.EachVMkernelnetwork interfacecanmanagepartofthetraffichandledbytheESX/ESXihost.SeeAddingandModifying VMkernelNetworkInterfaceswithvicfgvmkniconpage 117.

Setting Up vSphere Networking with vNetwork Standard Switches


Youcansetupyourvirtualnetworkbyperformingthesetasks,discussedinmoredetailinthischapter: 1 Createormanipulatevirtualswitchesusingvicfg-vswitch.Bydefault,eachESX/ESXihosthasone virtualswitch,vSwitch0.Youcancreateadditionalvirtualswitchesormanageexistingswitches.See SettingUpVirtualSwitchesandAssociatingaSwitchwithaNetworkInterfaceonpage 114. (Optional)Makechangestotheuplinkadapterusingvicfg-nics.SeeManagingUplinkAdapterswith vicfgnicsonpage 116. (Optional)Usevicfg-vswitchtoaddportgroupstothevirtualswitch.SeeChecking,Adding,and RemovingPortGroupsonpage 115. (Optional)Usevicfg-vswitchtoestablishVLANsbyassociatingportgroupswithVLANIDs.See SettingthePortGroupVLANIDonpage 116. Usevicfg-vmknictoconfiguretheVMkernelnetworkinterfaces.SeeAddingandModifyingVMkernel NetworkInterfaceswithvicfgvmkniconpage 117.
113

2 3 4 5

VMware, Inc.

vSphere Command-Line Interface Installation and Scripting Guide

Setting Up Virtual Switches and Associating a Switch with a Network Interface


AvirtualswitchmodelsaphysicalEthernetswitch.Youcanmanagevirtualswitchesandportgroupsusing thevSphereClient(seetheESXConfigurationGuideandtheESXiConfigurationGuide)orusingvSphereCLI commands. Youcancreateamaximumof127virtualswitchesonasingleESX/ESXihost.Bydefault,eachESX/ESXihost hasasinglevirtualswitchcalledvSwitch0.Avirtualswitchhas56logicalportsbydefault.Seethe ConfigurationMaximumsdocumentonthevSpheredocumentationmainpagefordetails.Portsconnecttothe virtualmachinesandtheESX/ESXiphysicaladapters.

YoucanconnectonevirtualmachinenetworkadaptertoeachportusingthevSphereClientUI. Youcanconnecttheuplinkadaptertothevirtualswitchesusingvicfg-vswitch.SeeLinkingand UnlinkingUplinkAdaptersonpage 116.

Whentwoormorevirtualmachinesareconnectedtothesamevirtualswitches,networktrafficbetweenthem isroutedlocally.Ifanuplinkadapterisattachedtothevirtualswitches,eachvirtualmachinecanaccessthe externalnetworkthattheadapterisconnectedto. ThissectiondiscussesworkinginastandardvSwitch(vSS)environment.SeeManagingvNetwork DistributedSwitchesonpage 119forinformationaboutvDSenvironments. Whenworkingwithvirtualswitchesandportgroups,performthefollowingtasks: 1 2 3 Findoutwhichvirtualswitchesareavailableand(optionally)whattheassociatedMTUandCDP(Cisco DiscoveryProtocol)settingsare.SeeRetrievingInformationaboutVirtualSwitchesonpage 114. Addavirtualswitch.SeeAddingandDeletingVirtualSwitchesonpage 115. Foranewlyaddedswitch,performthesetasks: a b c d Addaportgroup.SeeChecking,Adding,andRemovingPortGroupsonpage 115. (Optional)SettheportgroupVLANID.SeeSettingthePortGroupVLANIDonpage 116. Addanuplinkadapter.SeeLinkingandUnlinkingUplinkAdaptersonpage 116. (Optional)ChangetheMTUorCDPsettings.SeeSettingSwitchAttributesonpage 115.

Retrieving Information about Virtual Switches


Youcanretrieveinformationaboutvirtualswitchesbyusingthefollowingvcifg-vswitchoptions:

CheckwhethervSwitch1exists.
vicfg-vswitch <conn_options> -c vSwitch1

Thecommandreturns1iftheswitchexists,0iftheswitchdoesnotexist.

Listallvirtualswitchesandassociatedportgroups.
vicfg-vswitch <conn_options> -l

Thecommandprintsinformationaboutthevirtualswitch,whichmightincludeitsname,numberof ports,MTU,portgroups,andotherinformation.Thepreciseinformationdependsonthetargetsystem andonwhetheryoulistinformationforavSSoravDS. ForESXisystems,thedefaultportgroupsareManagement NetworkandVM Network.ForESXsystems, thedefaultportgroupsareService consoleandVM Network.

RetrievethecurrentCDP(CiscoDiscoveryProtocol)settingforthisvirtualswitch. IfCDPisenabledonavirtualswitch,ESX/ESXiadministratorscanfindoutwhichCiscoswitchportis connectedtowhichvirtualswitchuplink.CDPisalinklevelprotocolthatsupportsdiscoveryof CDPawarenetworkhardwareateitherendofadirectconnection.CDPisbitforwardedthrough switches.CDPisasimpleadvertisementprotocolwhichbeaconsinformationabouttheswitchorhostand someportinformation.


vicfg-vswitch <conn_options> --get-cdp vSwitch1

114

VMware, Inc.

Chapter 10 Managing vSphere Networking

Adding and Deleting Virtual Switches


Youcanaddanddeletevirtualswitchesusingthe--add|-aand--delete|-doptions.

Addavirtualswitch.
vicfg-vswitch <conn_options> --add vSwitch2

Afteryouhaveaddedavirtualswitch,youcansetswitchattributes(SettingSwitchAttributeson page 115)andaddoneormoreuplinkadapters(LinkingandUnlinkingUplinkAdaptersonpage 116).

Deleteavirtualswitch.
vicfg-vswitch <conn_options> --delete vSwitch1

YoucannotdeleteavirtualswitchifanyportsontheswitcharestillinusebyVMkernelnetworks,virtual machines,orvswifs.Runvicfg-vswitch --listtodeterminewhetheravirtualswitchisinuse.

Setting Switch Attributes


Youcansetthemaximumtransmissionunit(MTU)andCDPstatusforavirtualswitch.TheCDPstatusshows whichCiscoswitchportisconnectedtowhichuplink.

SettheMTUforavSwitch.
vicfg-vswitch <conn_options> -m 9000 vSwitch1

TheMTUisthesize(inbytes)ofthelargestprotocoldataunittheswitchcanprocess.Whenyousetthis option,itaffectsalluplinksassignedtothevirtualswitch.

SettheCDPvalueforavSwitch.Youcansetstatustodown,listen,advertise,orboth.
vicfg-vswitch <conn_options> --set-cdp listen

Checking, Adding, and Removing Port Groups


NetworkservicesconnecttovSwitchesthroughportgroups.Aportgroupallowsyoutogrouptrafficand specifyconfigurationoptionssuchasbandwidthlimitationsandVLANtaggingpoliciesforeachportinthe portgroup.Avirtualswitchmusthaveoneportgroupassignedtoit.Youcanassignadditionalportgroups. Youcanusevicfg-vswitchtocheck,add,andremoveportgroups.

CheckwhetherportgroupsarecurrentlyassociatedwithavSwitch.
vicfg-vswitch <conn_options> --check-pg <port_group> vSwitch1

Thecommandreturns0ifthespecifiedportgroupisassociatedwiththevSwitch,andreturns1otherwise. Usevicfg-vswitch --listtolistallportgroups.

Addaportgroup.
vicfg-vswitch <conn_options> --add-pg <port_group_name> vSwitch1

Deleteoneoftheexistingportgroups.
vicfg-vswitch <conn_options> --del-pg <port_group_name> vSwitch1

Connecting and Disconnecting Uplink Adapters and Port Groups


Ifyoursetupincludesoneormoreportgroups,youcanassociateeachportgroupwithoneormoreuplink adapters(andremovetheassociation).Thisfunctionalityallowsyoutofiltertrafficfromaportgrouptoa specificuplink,evenifthevirtualswitchisconnectedwithmultipleuplinks.

Connectaportgroupwithanuplinkadapter.
vicfg-vswitch --add-pg-uplink <adapter_name> --pg <port_group> <vswitch_name>

Thiscommandfailssilentlyiftheuplinkadapterdoesnotexist.

Removeaportgroupfromanuplinkadapter.
vicfg-vswitch --del-pg-uplink <adapter_name> --pg <port_group> <vswitch_name>

VMware, Inc.

115

vSphere Command-Line Interface Installation and Scripting Guide

Setting the Port Group VLAN ID


VLANsallowyoutofurthersegmentasinglephysicalLANsegmentsothatgroupsofportsareisolatedasif theywereonphysicallydifferentsegments.ThestandardisIEEE802.1Q. AVLANIDrestrictsportgrouptraffictoalogicalEthernetsegmentwithinthephysicalnetwork.

SettheVLANIDto4095toallowaportgrouptoreachportgroupslocatedonotherVLAN. SettheVLANIDto0todisabletheVLANforthisportgroup.

IfyouuseVLANIDs,youmustchangetheportgrouplabelsandVLANIDstogethersothatthelabels properlyrepresentconnectivity.VLANIDsareoptional. YoucanusethefollowingcommandsforVLANmanagement:

AllowallportgroupstoreachportgroupslocatedonotherVLANs.
vicfg-vswitch <conn_options> --vlan 4095 --pg ALL vSwitch2

DisableVLANforportgroupg42
vicfg-vswitch <conn_options> --vlan 0 --pg g42 vSwitch2

Runvicfg-vswitch -ltoretrieveinformationaboutVLANIDscurrentlyassociatedwiththevSwitchesin thenetwork.

Linking and Unlinking Uplink Adapters


WhenyoucreatevSwitchusingvicfg-vswitch--add,alltrafficonthatvSwitchisinitiallyconfinedtothat vSwitch.AllvirtualmachinesconnectedtothevSwitchcantalktoeachother,butthevirtualmachinescannot connecttothenetworkortovirtualmachinesonotherhosts.Avirtualmachinealsocannotconnecttovirtual machinesconnectedtoadifferentvSwitchonthesamehost. HavingavSwitchthatisnotconnectedtothenetworkmightmakesenseifyouwantagroupofvirtual machinestobeabletocommunicatewitheachother,butnotwithotherhostsorwithvirtualmachineson otherhosts.Inmostcases,yousetupthevSwitchtotransferdatatoexternalnetworksbyattachingoneor moreuplinkadapterstothevSwitch. Youcanusethefollowingcommandstoaddandremoveuplinkadapters:

Addanewuplinkadaptertoavirtualswitch.
vicfg-vswitch <conn_options> --link vmnic15 vSwitch0

Removeanuplinkadapterfromavirtualswitch.
vicfg-vswitch <conn_options> --unlink vmnic15 vSwitch0

Managing Uplink Adapters with vicfg-nics


Thevicfg-nicscommandmanagesuplinkadapters,whichrepresentthephysicalNICsthatconnectthe ESX/ESXihosttothenetwork. Youcanusevicfg-nicstolistinformationandtospecifyspeedandduplexsettingfortheuplink. Thefollowingexamplescenariolistsanuplinkadaptersproperties,changestheduplexandspeed,andsets theuplinktoautonegotiateitsspeedandduplexsettings. To manipulate uplink adapter setup 1 Listsettings.
vicfg-nics <conn_options> -l

Liststheuplinksinthesystem,theircurrentandconfiguredspeed,andtheirduplexsetting. 2 Setthesettingsforvmnic0tofullandthespeedto100.
vicfg-nics <conn_options> -d full -s 100 vmnic0

116

VMware, Inc.

Chapter 10 Managing vSphere Networking

Setvmnic2toautonegotiateitsspeedandduplexsettings.
vicfg-nics <conn_options> -a vmnic2

Adding and Modifying VMkernel Network Interfaces with vicfg-vmknic


VMkernelnetworkinterfacesareusedprimarilyformanagementtraffic,whichcanincludevMotion,IP Storage,andothermanagementtrafficontheESX/ESXisystem.YoucanalsobindanewlycreatedVMkernel networkinterfaceforusebysoftwareanddependenthardwareiSCSIusingtheesxcli swiscsi nic add command.SeeesxcliswiscsiNamespaceonpage 141. TheVMkernelnetworkinterfaceisseparatefromthevirtualmachinenetwork.Theguestoperatingsystem andapplicationprogramscommunicatewithaVMkernelnetworkinterfacethroughacommonlyavailable devicedriveroraVMwaredevicedriveroptimizedforthevirtualenvironment.Ineithercase,communication intheguestoperatingsystemoccursasitwouldwithaphysicaldevice.Virtualmachinescanalso communicatewithaVMkernelnetworkinterfaceifbothusethesamevSwitch. EachVMkernelnetworkinterfacehasitsownMACaddressandoneormoreIPaddresses,andrespondsto thestandardEthernetprotocolaswouldaphysicalNIC.TheVMkernelnetworkinterfaceiscreatedwithTCP SegmentationOffload(TSO)enabled. YoucanconfiguretheVMkernelnetworkinterfaceforIPv4(seeToaddandconfigureaVMkernelNetwork InterfacewithIPv4onpage 117)orforIPv6(seeToaddandconfigureaVMkernelNetworkInterfacewith IPv6onpage 118). To add and configure a VMkernel Network Interface with IPv4 1 Runvicfg-vmknic --addtoaddaVMkernelnetworkinterface.YoumustspecifytheIPaddressusing --ip,thenetmask,andthename.Forthefollowingexamples,assumethatVMSFVMK363isaport grouptowhichyouwanttoaddaVMkernelnetworkinterface.
vicfg-vmknic <conn_options> --add --ip <ip_address> -n 255.255.255.0 VMSF-VMK-363

YoucanspecifytheMTUsettingwhenaddingaVMkernelnetworkinterface.Youcannotchangethat settingatalatertime. Whenthecommandcompletessuccessfully,thenewlyaddedVMkernelnetworkinterfaceisenabled. 2 ChangetheIPaddressasneeded.


vicfg-vmknic <conn_options> --ip <address> VMSF-VMK-363

ForIPv4,chooseoneofthefollowingformats:

<X.X.X.X>StaticIPv4address. DHCPUseIPv4DHCP.

TheVMkernelsupportsDHCPonlyforESX/ESXi4.0andlater. 3 (Optional)EnableVMotion.Bydefault,VMotionisdisabled.
vicfg-vmknic <conn_options> --enable-vmotion VMSF-VMK-363

Youcanlateruse--disable-vmotiontodisableVMotionforthisVMkernelnetworkinterface. 4 ListinformationaboutallVMkernelnetworkinterfacesonthesystem.
vicfg-vmknic <conn_options> --list

Thecommanddisplaysthenetworkinformation,portgroup,MTU,andcurrentstateforeachvirtual networkadapterinthesystem.

VMware, Inc.

117

vSphere Command-Line Interface Installation and Scripting Guide

To add and configure a VMkernel Network Interface with IPv6 1 Runvicfg-vmknic --addtoaddaVMkernelnetworkinterface.YoumustspecifytheIPaddressusing --ip,thenetmask,andtheportgroupname.Forthefollowingexamples,assumethatVMSFVMK363 isaportgrouptowhichyouwanttoaddaVMkernelnetworkinterface. YoucanspecifytheMTUsettingwhenaddingaVMkernelnetworkinterface.Youcannotchangethat settingatalatertime. Whenthecommandcompletessuccessfully,thenewlyaddedVMkernelnetworkinterfaceisenabled. 2 EnableIPv6.
vicfg-vmknic <conn_options> --enable-ipv6 true VMSF-VMK-363

SupplyanIPv6address.
vicfg-vmknic <conn_options> --ip <ip_address> VMSF-VMK-363

ForIPv6,theIPaddresscanhaveoneofthefollowingformats:

<X:X:X::/X>StaticIPv6address DHCPV6UseDHCPIPv6address.TheVMkernelsupportsDHCPonlyforESX/ESXi4.0andlater. AUTOCONFUsetheIPv6addressadvertisedbytherouter.IfyoucreateaVMkernelnetwork interfacewithAUTOCONF,anaddressisassignedimmediately.IfyouaddAUTOCONFtoan existingvmknic,theaddressisaddedwhentheroutersendsthenextrouteradvert.

(Optional)EnableVMotion.Bydefault,VMotionisdisabled.
vicfg-vmknic <conn_options> --enable-vmotion VMSF-VMK-363

Youcanlateruse--disable-vmotiontodisableVMotionagain. 5 ListinformationaboutallVMkernelnetworkinterfacesonthesystem.
vicfg-vmknic <conn_options> --list

Thelistcontainsthenetworkinformation,portgroup,MTU,andcurrentstateforeachvirtualnetwork adapterinthesystem. 6 YoucanlaterremovetheIPv6addressanddisableIPv6.


vicfg-vmknic <conn_options> --unset-ip <X:X:X::/X> VMSF-VMK-363 vicfg-vmknic <conn_options> --enable-ipv6 false VMSF-VMK-363

Setting Up vSphere Networking with vNetwork Distributed Switch


AvDSfunctionsasasinglevirtualswitchacrossallassociatedhosts.AvDSallowsvirtualmachinesto maintainaconsistentnetworkconfigurationastheymigrateacrossmultiplehosts.SeeNetworkingUsing vNetworkDistributedSwitchesonpage 113. LikeavNetworkStandardSwitch,eachvDSisanetworkhubthatvirtualmachinescanuse.AvDScan forwardtrafficinternallybetweenvirtualmachinesorlinktoanexternalnetworkbyconnectingtouplink adapters. EachvDScanhaveoneormoredvPortgroupsassignedtoit.dvPortgroupsgroupmultipleportsundera commonconfigurationandprovideastableanchorpointforvirtualmachinesconnectingtolabelednetworks. EachdvPortgroupisidentifiedbyanetworklabel,whichisuniquetothecurrentdatacenter.AVLANID, whichrestrictsportgrouptraffictoalogicalEthernetsegmentwithinthephysicalnetwork,isoptional. YoucancreateavDSusingthevSphereClient.AfteryouhavecreatedavDS,youcanaddhostsusingthe vSphereClient.YoucanusethevSphereClienttocreatedvPortgroupsandeditvDSpropertiesandpolicies. AfterthevDShasbeensetup,youcanusethevSphereClientorthevicfg-vswitchcommandtoaddor removedvUplinkadapters.

118

VMware, Inc.

Chapter 10 Managing vSphere Networking

Managing vNetwork Distributed Switches


Certaintasks,suchascreatingavNetworkDistributesSwitch,creatingdvPortgroups,andeditingvDS propertiesandpolicies,canonlybeperformedusingthevSphereClientorthevSphereWebServicesSDK.See theESXConfigurationGuide,theESXiConfigurationGuide,andthewhitepaperavailablethroughtheResources linkatwww.vmware.com/go/networkingforinformationaboutvDSandhowtoconfigurevDSusingthe vSphereClient. AfterthevDShasbeensetup,youcanusevicfg-vswitchtoaddorremovedvUplinkadapters.

AddadvUplink.
vicfg-vswitch --add-dvp-uplink <adapter_name> --dvp <DVPort_id> <dvswitch_name>

RemoveadvUplink.
vicfg-vswitch --del-dvp-uplink <adapter> --dvp <DVPort_id> <dvswitch_name>

Managing Standard Networking Services in the vSphere Environment


YoucanusevCLIcommandstosetupDNS,NTP,SNMP,andthedefaultgatewayforyourvSphere environment.

Setting the DNS Configuration


Thevicfg-dnscommandlistsandspecifiestheDNSconfigurationofyourESX/ESXihost.Callthecommand withoutcommandspecificoptionstolisttheexistingDNSconfiguration. IMPORTANTIfyoutrytochangethehostordomainnameortheDNSserveronhoststhatuseDHCP (dynamichostprotocol),anerrorresults. InnetworkenvironmentswhereaDHCPserverandaDNSserverareavailable,ESX/ESXihostsare automaticallyassignedDNSnames. InnetworkenvironmentswhereautomaticDNSisnotavailableornotdesirable,youcanconfigurestaticDNS information,includingahostname,primarynameserver,secondarynameserver,andDNSsuffixes. To set up DNS 1 Runvicfg-dnswithoutcommandspecificoptionstodisplayDNSpropertiesforthespecifiedserver.
vicfg-dns <conn_options>

IfDNSisnotsetupforthetargetserver,thecommandreturnsanerror. 2 Tochangethesettings,usevicfg-dnswith--dns,--domain,or--hostname.

SpecifytheDNSserverusingthe--dnsoptionandacommaseparatedlistofhosts,inorderof preference.
vicfg-dns <conn_options --dns <dns1,dns2>

ConfiguretheDNShostnamefortheserverspecifiedby--server(or--vihost).
vicfg-dns <conn_options> -n dns_host_name

ConfiguretheDNSdomainnamefortheserverspecifiedby--server(or--vihost).
vicfg-dns <conn_options> -d mydomain.biz

ToturnonDHCP,usethe--DHCPoption.
vicfg-dns <conn_options> --dhcp yes

VMware, Inc.

119

vSphere Command-Line Interface Installation and Scripting Guide

To modify DNS setup for a preconfigured server 1 Runvicfg-dnswithoutcommandspecificoptionstodisplayDNSpropertiesforthespecifiedserver.


vicfg-dns <conn_options>

ThecommanddisplaysDNSpropertiesforthespecifiedserver.Theinformationincludesthehostname, domainname,DHCPsetting(trueorfalse),andDNSserversontheESX/ESXihost. 2 IftheDNSpropertiesareset,andyouwanttochangetheDHCPsettings,youmustspecifythevirtual networkadaptertousewhenoverridingthesystemDNS.


ForESXhosts,v_nicmustbeoneoftheserviceconsolenetworkadapters. ForESXihosts,v_nicmustbeoneoftheVMkernelnetworkadapter.

OverridetheexistingDHCPsettingasfollows:
vicfg-dns <conn_options> --dhcp yes --v_nic <vnic>

Adding and Starting an NTP Server


Someprotocols,suchasKerberos,musthaveaccurateinformationaboutthecurrenttime.Inthosecases,you canaddanNTP(NetworkTimeProtocol)servertoyourESX/ESXihost. To manage an NTP Server 1 Runvicfg-ntp--add toaddanNTPservertothehostspecifiedin<conn_options>.Youuseahostname orIPaddresstospecifyanalreadyrunningNTPserver.
vicfg-ntp <conn_options> -a 192.XXX.XXX.XX

Runvicfg-ntp --starttostarttheservice.
vicfg-ntp <conn_options> --start

Runtovicfg-ntp --listtolisttheservice.
vicfg-ntp <conn_options> --list

Runvicfg-ntp --stoptostoptheservice.
vicfg-ntp <conn_options> --stop

Runvicfg-ntp --deletetoremovethespecifiedNTPserverfromthehostspecifiedin<conn_options>.
vicfg-ntp <conn_options> --delete 192.XXX.XXX.XX

Managing the IP Gateway


IfyoumoveyourESX/ESXihosttoanewphysicallocation,youmighthavetochangethedefaultIPgateway. Youcanusethevicfg-routecommandtomanagethedefaultgatewayfortheVMkernelIPstack. vicfg-routesupportsasubsetoftheLinuxroutecommandsoptions. Ifyourunvicfg-routewithnooptions,thecommanddisplaysthedefaultgateway.Use--familytoprint thedefaultIPv4orthedefaultIPv6gateway.Bydefault,thecommanddisplaysthedefaultIPv4gateway. To add, view, and delete a route entry 1 AddarouteentrytotheVMkernelandmakeitthedefault.

ForIPv4networks,noadditionaloptionsarerequired.
vicfg-route <conn_options> --add <network_ip> <netmask_IP> <gateway_ip>

Forexample,toaddarouteto192.168.100.0through192.168.0.1:
vicfg-route -a 192.168.100.0/24 192.168.0.1

or
vicfg-route -a 192.168.100.0 255.255.255.0 192.168.0.1

120

VMware, Inc.

Chapter 10 Managing vSphere Networking

ForIPv6networks,use--family v6
vicfg-route -f V6 --add <network_ip_and_mask> <gateway_ip>

Forexample:
vicfg-route -f V6 --add 2001:10:20:253::/64 2001:10:20:253::1

Listrouteentriestocheckthatyourroutewasaddedbyrunningthecommandwithoutoptions.
vicfg-route <conn_options>

Theoutputlistsallnetworksandcorrespondingnetmasksandgateways. 3 Setthedefaultgateway.

ForIPv4,usethissyntax:
vicfg-route 192.168.0.1 or vicfg-route -a default 192.168.0.1

ForIPv6,usethissyntax:
vicfg-route -f V6 -a default 2001:10:20:253::1

Runvicfg-route --deletetodeletetheroute.Specifyfirstthegateway,andthenthenetwork.
vicfg-route <conn_options> -d 192.168.100.0/24 192.168.0.1

Using vicfg-ipsec for Secure Networking


Youcanusevicfg-ipsectosetupIPsec(InternetProtocolSecurity),whichsecuresIPcommunications comingfromandarrivingatESX/ESXihosts.AdministratorswhoperformIPsecsetupmusthaveasolid understandingofbothIPv6and IPsec. ESX/ESXihostssupportIPseconlyfortrafficusingIPv6.IPv4isnotsupported. IMPORTANTInESX/ESXi4.1,IPv6isbydefaultdisabled.YoucanturnonIPv6byrunningthisvCLI command:
vicfg-vmknic <conn_options> --enable-ipv6

Youcannotrunvicfg-ipsecwithavCenterServersystemasthetarget(usingthe--vihostoption). TheVMwareimplementationofIPsecadherestothefollowingIPv6RFCs:

4301SecurityArchitecturefortheInternetProtocol 4303IPEncapsulatingSecurityPayload(ESP) 4835CryptographicAlgorithmImplementationRequirementsforESP 2410TheNULLEncryptionAlgorithmandItsUseWithIPsec 2451TheESPCBCModeCipherAlgorithms 3602TheAESCBCCipherAlgorithmandItsUsewithIPsec 2404TheUseofHMACSHA196withinESPandAH 4868UsingHMACSHA256,HMACSHA384,andHMACSHA512

VMware, Inc.

121

vSphere Command-Line Interface Installation and Scripting Guide

Using IPsec with ESX/ESXi


WhenyousetupIPseconanESX/ESXihost,youenableprotectionofincomingoroutgoingdata.What happenspreciselydependsonhowyousetupthesystemsSecurityAssociations(SAs)andSecurity Policies (SPs).

AnSAdetermineshowthesystemprotectstraffic.WhenyoucreateanSA,youspecifythesourceand destination,authentication,andencryptionparameters,andanidentifierfortheSAinthefollowing optionstovicfg-ipsec.


sa-srcandsa-dst spi(securityparameterindex) sa-mode(tunnelortransport) ealgoandekey ialgoandikey

AnSPidentifiesandselectstrafficthatmustbeprotected.AnSPconsistsoftwologicalsections,aselector, andanaction. Theselectorisspecifiedbythefollowingoptionstovicfg-ipsec.


src-addrandsrc-port dst-addranddst-port ulproto direction(inorout)

Theactionisspecifiedbythefollowingoptionstovicfg-ipsec.

sa-name sp-name action(none,discard,ipsec)

BecauseIPsecallowsyoutotargetpreciselywhichtrafficshouldbeencrypted,itiswellsuitedforsecuring yourvSphereenvironment.Forexample,youcansetuptheenvironmentsoallVMotiontrafficisencrypted.

Managing Security Associations with vicfg-ipsec


YoucanspecifyanSAandrequestthattheVMkernelusethatSA.ThefollowingoptionsforSAsetupare supported.
Option sa-src <source_IP> sa-dst <destination_IP> spi Description SourceIPfortheSA. DestinationIPfortheSA. SecurityParameterIndex(SPI)fortheSA.Mustbeahexadecimalnumberwitha0xprefix. WhenIPsecisinuse,ESX/ESXiusestheESPprotocol(RFC43030),whichincludes authenticationandencryptioninformationandtheSPI.TheSPIidentifiestheSAtouseat thereceivinghost.EachSAyoucreatemusthaveauniquecombinationofsource, destination,protocol,andSPI. sa-mode [tunnel | transport] Eithertunnelortransport. Intunnelmode,theoriginalpacketisencapsulatedinanotherIPv6packet,wheresourceand destinationaddressesaretheSAendpointaddresses. Encryptionalgorithmtouse.Choose3des-cbcoraes128-cbc,ornullfornoencryption.

ealgo [null | 3des-cbc | aes128-cbc]

122

VMware, Inc.

Chapter 10 Managing vSphere Networking

Option ekey <key> ialgo [hmac-sha1 | hmac-sha2-256 ] ikey

Description Encryptionkeytobeusedbytheencryptionalgorithm.Aseriesofhexadecimaldigitswith a0xprefixoranASCIIstring. Authenticationalgorithmtobeused.Choosehmac-sha1orhmac-sha2-256. Authenticationkeytobeused.AseriesofhexadecimaldigitsoranASCIIstring.

YoucanperformthesemaintaskswithSAs:

CreateanSAwithvicfg-ipsec --add-sa.Youspecifythesourceanddestination,andthe authenticationmode.Youalsospecifytheauthenticationalgorithmandauthenticationkeytouse.You mustspecifyanencryptionalgorithmandkey,butyoucanspecifynullifyouwantnoencryption. Authenticationisrequiredandcannotbenull.Thefollowingexampleincludesextralinebreaksfor readability.Thelastoption(sa_2intheexample)isthenameoftheSA.


vicfg-ipsec --add-sa --sa-src 2001:DB8:1::121 --sa-dst 2001:DB8:1::122 --sa-mode transport --spi 0x1000 --ealgo 3des-cbc --ekey 0x6970763672656164796c6f676f336465736362636f757432 --ialgo hmac-sha1 --ikey 0x6970763672656164796c6f67736861316f757432 sa_2

ListanSAwithvicfg-ipsec --list-sa.ThiscommandreturnsSAscurrentlyavailableforusebyan SP.ThelistincludesSAsyoucreatedusingvicfg-ipsec. RemoveasingleSAwithvicfg-ipsec --remove-sa.IftheSAisinusewhenyourunthiscommand, thecommandcannotperformtheremoval. RemoveallSAswithvicfg-ipsec --flush-sa.ThisoptionremovesallSAsevenwhentheyareinuse. CAUTIONRunningvicfg-ipsec --flush-saremovesallSAsonyoursystemandmightleaveyour systeminaninconsistentstate.

Managing Security Policies with vicfg-ipsec


AfteryouhavecreatedoneormoreSAs,youcanaddsecuritypolicies(SPs)toyourESX/ESXihosts.Whilethe SAspecifiestheauthenticationandencryptionparameterstouse,theSPidentifiesandselectstraffic. ThefollowingoptionsforSPmanagementaresupported.
Option sp-src <ip>/<p_len> sp-dst <ip>/<p_len> src-port <port> dst-port <port> ulproto [any | tcp | udp | icmp6] dir [in | out] Description SourceIPaddressandprefixlength. DestinationIPaddressandprefixlength. Sourceport(065535).Specifyanyforanyports. Destinationport(065535).Specifyanyforanyports.Ifulprotoisicmp6,thisnumberrefers totheicmp6type.Otherwise,thisnumberreferstotheport. Upperlayerprotocol.UsethisoptiontorestricttheSPtoonlycertainprotocols,oruseanyto applytheSPtoallprotocols. Directioninwhichyouwanttomonitorthetraffic.Tomonitortrafficinbothdirections,create twopolicies.

VMware, Inc.

123

vSphere Command-Line Interface Installation and Scripting Guide

Option action [none | discard | ipsec]

Description Actiontotakewhentrafficwiththespecifiedparametersisencountered. noneTakenoaction,thatis,allowtrafficunmodified. discardDonotallowdatainorout. ipsecUsetheauthenticationandencryptioninformationspecifiedintheSAtodetermine whetherthedatacomefromatrustedsource.

sp-mode [tunnel | transport] sa-name

Mode,eithertunnelortransport. NameoftheSAtousebythisSP.

YoucanperformthesemaintaskswithSPs:

CreateanSPwithvicfg-ipsec --add-sp.Youidentifythedatatomonitorbyspecifyingtheselectors sourceanddestinationIPaddressandprefix,sourceportanddestinationport,upperlayerprotocol, directionoftraffic,actiontotake,andSPmode.ThelasttwooptionarethenameoftheSAtouseandthe nameoftheSPthatisbeingcreated.Thefollowingexampleincludesextralinebreaksforreadability.


vicfg-ipsec --add-sp --sp-src=2001:0DB8:0001:/48 --sp-dst=2001:0DB8:0002:/48 --src-port=23 --dst-port=25 --ulproto=tcp --dir=out --action=ipsec --sp-mode=transport --sp-name sp_2

ListanSPwithvicfg-ipsec --list-sp.ThiscommandreturnsSPscurrentlyavailable.AllSPsare createdbytheadministrator. RemoveanSPwithvicfg-ipsec --remove-sp.IftheSPisinusewhenyourunthiscommand,the commandcannotperformtheremoval.Youcanrunvicfg-ipsec --flush-spinsteadtoremovetheSP evenwhenitisinuse. CAUTIONRunningvicfg-ipsec --flush-spremovesallSPsonyoursystemandmightleaveyour systeminaninconsistentstate.

124

VMware, Inc.

11

Monitoring ESX/ESXi Hosts

11

StartingwiththevSphere4.0release,thevCenterServermakesperformancechartsforCPU,memory,diskI/O, networking,andstorageavailable.YoucanviewtheseperformancechartsbyusingthevSphereClientand readaboutthemintheDatacenterAdministrationGuide.Youcanalsoperformsomemonitoringofyour ESX/ESXihostsusingvCLIcommands. Thischapterincludesthesetopics:


UsingresxtopforPerformanceMonitoringonpage 125 ManagingDiagnosticPartitionswithvicfgdumppartonpage 125 ConfiguringSyslogonESXiHostsonpage 126 ManagingESX/ESXiSNMPAgentswithvicfgsnmponpage 127 ESX,ESXi,andVirtualMachineLogsonpage 129 EnablingandDisablingCIMProvidersonpage 129

Using resxtop for Performance Monitoring


TheresxtopvCLIcommandallowsyoutoexaminehowESX/ESXisystemsuseresources.Youcanusethe commandininteractivemode(default)orinbatchmode.TheResourceManagementGuideexplainshowtouse resxtopandprovidesinformationaboutavailablecommandsanddisplaystatistics. IMPORTANTresxtopissupportedonlyonLinux.

Managing Diagnostic Partitions with vicfg-dumppart


Yourhostmusthaveadiagnosticpartition(dumppartition)tostorecoredumpsfordebuggingandforuseby VMwaretechnicalsupport.TheVMwareknowledgebasearticleathttp://kb.vmware.com/kb/1004128 explainshowtocollecttheinformation. YoucanusethevSphereClienttocreatethediagnosticpartitiononalocaldiskoronaprivateorsharedSAN LUN.Youcannotusevicfg-dumpparttocreatethediagnosticpartition.TheSANLUNcanbesetupwith FibreChannelorhardwareiSCSI.SANLUNsaccessedthroughasoftwareiSCSIinitiatorarenotsupported. Eachhostmusthaveadiagnosticpartitionof100MB.IfmultiplehostsshareaSANLUN,configurea diagnosticpartitionwith100MBforeachhost. CAUTIONIftwohoststhatshareadiagnosticpartitionfailandsavecoredumpstothesameslot,thecore dumpsmightbelost.Tocollectcoredumpdata,rebootahostandextractlogfilesimmediatelyafterthehost fails.Ifanotherhostfailsbeforeyoucollectthediagnosticdataofthefirsthost,thesecondhostdoesnotsave thecoredump.

VMware, Inc.

125

vSphere Command-Line Interface Installation and Scripting Guide

Youcanusethevicfg-dumppartcommandtoquery,set,andscananESX/ESXihostsdiagnosticpartitions. TheESXConfigurationGuideandtheESXiConfigurationGuideexplainhowtosetupdiagnosticpartitionswith thevSphereClient.TheFibreChannelSANConfigurationGuideandtheiSCSISANConfigurationGuideexplain howtomanagediagnosticpartitionsonaFibreChannelorhardwareiSCSISAN. Diagnosticpartitionscaninclude,inorderofsuitability,paralleladapter,blockadapter,FibreChannel,or hardwareiSCSIpartitions. IMPORTANTWhenyoulistdiagnosticpartitions,softwareiSCSIpartitionsareincluded.However,VMware recommendsthatyounotusesoftwareiSCSIpartitionsasdiagnosticpartitions. Thefollowingexamplescenariochangesthediagnosticpartition. To manage a diagnostic partition 1 ShowthediagnosticpartitiontheVMkerneluses.
vicfg-dumppart <conn_options> -t

Displayinformationaboutallpartitionsthatcanbeusedasdiagnosticpartitions.Use-lforbasic information,-ffordetailedinformation.
vicfg-dumppart <conn_options> -f

Theoutputmightlookasfollows.
Partition name on vml.mpx.vmhba36:C0:T0:L0:7 -> mpx.vmhba36:C0:T0:L0:7

Deactivatethediagnosticpartition.
vicfg-dumppart <conn_options> -d

TheESX/ESXisystemisnowwithoutadiagnosticpartition,andyoumustimmediatelysetanewone. 4 Settheactivepartitiontonaa.<naa_ID>.
vicfg-dumppart <conn_options> -s naa.<naa_ID>

Runvicfg-dumppart -tagaintoverifythatadiagnosticpartitionisset.
vicfg-dumppart <conn_options> -t

Ifadiagnosticpartitionisset,thecommanddisplaysinformationaboutit.Otherwise,thecommand informsyouthatnopartitionisset.

Configuring Syslog on ESXi Hosts


AllESX/ESXihostsrunasyslogservice(syslogd),whichlogsmessagesfromtheVMkernelandothersystem componentstoafile. OnanESXihost,youcanusethevSphereClientorthevicfg-syslogvCLIcommandtoconfigurethe followingoptions:

Remotehost.Remotehosttowhichsyslogmessagesareforwarded.Theremotehostmusthaveasyslog serviceinstalledandcorrectlyconfiguredtoreceivetheforwardedsyslogmessages.Seethe documentationforthesyslogserviceinstalledonyourremotehostforinformationonconfiguration. Remoteport.Portonwhichtheremotehostreceivessyslogmessages.

IMPORTANTYoucannotusethevSphereClientorvicfg-syslogtoconfiguresyslogbehaviorforan ESX/ESXihost.Youmusteditthe/etc/syslog.conffiletoconfiguresyslogforanESXhost. Youdonothavetorestartthesyslogserviceafterconfiguringthesettings. Youcannotusevicfg-syslogtospecifyadatastorepathtoafileinwhichsyslogdlogsallmessages.Use thevSphereClienttospecifyadatastorepath.SeetheDatacenterAdministrationGuide.

126

VMware, Inc.

Chapter 11 Monitoring ESX/ESXi Hosts

To configure the syslog service 1 Runvicfg-syslog --showtodisplaythesyslogserverconfiguration.


vicfg-syslog <conn_options> -i

Runvicfg-syslog --setservertosetaremoteserverasthesyslogserver.
vicfg-syslog <conn_options> -s mysyslogserver

MakesmysyslogserverthesyslogserverfortheESX/ESXihostspecifiedin<conn_options>. 3 Runvicfg-syslog --setporttosettheportforthesyslogserver.


vicfg-syslog <conn_options> -p <port>

Managing ESX/ESXi SNMP Agents with vicfg-snmp


SimpleNetworkManagementProtocol(SNMP)allowsmanagementprogramstomonitorandcontrol networkeddevices.vCenterServerandESX/ESXisystemsincludedifferentSNMPagents:

TheSNMPagentincludedwithvCenterServercansendtrapswhenthevCenterServersystemisstarted orwhenanalarmistriggeredonvCenterServer.ThevCenterServerSNMPagentfunctionsonlyasatrap emitteranddoesnotsupportotherSNMPoperationssuchasGET. IMPORTANTYoucanmanagethevCenterServeragentwiththevSphereClient,butnotwiththevCLI command.

ESX/ESXi4.0andlaterincludesanSNMPagentembeddedinthehostdaemon(hostd)thatcansendtraps andreceivepollingrequestssuchasGETrequests.

VersionsofESXreleasedbeforeESX/ESXi4.0includedaNetSNMPbasedagent.Youcancontinuetousethis NetSNMPbasedagentinESX4.xwithMIBssuppliedbyyourhardwarevendorandotherthirdparty managementapplications.However,tousetheVMwareMIBfiles,youmustusetheembeddedSNMPagent. TousetheNETSNMPbasedagentandembeddedSNMPagentatthesametime,makeoneoftheagentslisten onanondefaultport.Bydefault,bothagentsusethesameport. TheembeddedSNMPagentisdisabledbydefault.Configuringandenablingtheagentrequiresthatyou performthefollowingtasks: 1 2 ConfigureSNMPCommunities.SeeConfiguringSNMPCommunitiesonpage 127. ConfiguretheSNMPAgent.Youhavethefollowingchoices:

ConfiguringtheSNMPAgenttoSendTrapsonpage 128 ConfiguringtheSNMPAgentforPollingonpage 128

Configuring SNMP Communities


BeforeyouenabletheESX/ESXiembeddedSNMPagent,youmustconfigureatleastonecommunityforthe agent. AnSNMPcommunitydefinesagroupofdevicesandmanagementsystems.Onlydevicesandmanagement systemsthataremembersofthesamecommunitycanexchangeSNMPmessages.Adeviceormanagement systemcanbeamemberofmultiplecommunities. ToconfigureSNMPcommunities,runvicfg-snmp -c,specifyingacommaseparatedlistofcommunities.For example:
vicfg-snmp <conn_options> -c public, internal

Eachtimeyouspecifyacommunitywiththiscommand,thesettingsthatyouspecifyoverwritetheprevious configuration.

VMware, Inc.

127

vSphere Command-Line Interface Installation and Scripting Guide

Configuring the SNMP Agent to Send Traps


YoucanusetheESX/ESXiembeddedSNMPagenttosendvirtualmachineandenvironmentaltrapsto managementsystems.Toconfiguretheagenttosendtraps,youmustspecifyatarget(receiver)address,the community,andanoptionalport.Ifyoudonotspecifyaport,theSNMPagentsendstrapstoUDPport162 onthetargetmanagementsystembydefault. To configure a trap destination 1 Makesureacommunityissetup.
vicfg-snmp <conn_options> --show Current SNMP agent settings: Enabled: 1 UDP port: 161 Communities: public Notification targets:

Runvicfg-snmp --targetwiththetargetaddress,portnumber,andcommunity. vicfg-snmp <conn_options -t target.example.com@163/public Eachtimeyouspecifyatargetwiththiscommand,thesettingsyouspecifyoverwriteallpreviously specifiedsettings.Tospecifymultipletargets,separatethemwithacomma. YoucanchangetheportthattheSNMPagentsendsdatatoonthetargetusingthe--targetsoption. ThatportisUDP162bydefault.

(Optional)EnabletheSNMPagentifitisnotyetrunning.
vicfg-snmp <conn_options> --enable

(Optional)Sendatesttraptoverifythattheagentisconfiguredcorrectly.
vicfg-snmp <conn_options> --test

TheagentsendsawarmStarttraptotheconfiguredtarget.

Configuring the SNMP Agent for Polling


IfyouconfiguretheESX/ESXiembeddedSNMPagentforpolling,itcanlistenforandrespondtorequestssuch asGETrequestsfromSNMPmanagementclientsystems. Bydefault,theembeddedSNMPagentlistensonUDPport161forpollingrequestsfrommanagement systems.Youcanusethevicfg-snmpcommandtoconfigureanalternativeport.Toavoidconflictswithother services,useaUDPportthatisnotdefinedin/etc/services. IMPORTANTBoththeembeddedSNMPagentandtheNetSNMPbasedagentavailableintheESXservice consolelistenonUDPport161bydefault.Changetheportforoneagenttoenablebothagentsforpolling. To configure the SNMP agent for polling 1 (Optional)Specifyaportforlisteningforpollingrequests.
vicfg-snmp <conn_options> -p <port>

(Optional)IftheSNMPagentisnotenabled,enableit.
vicfg-snmp <conn_options> --enable

Runvicfg-snmp --testtovalidatetheconfiguration.

Thefollowingexampleshowshowthecommandsareruninsequence:
vicfg-snmp c public t example.com@162/private --enable # next validate your config by doing these things: vicfg-snmp test walk v1 c public esx-host

128

VMware, Inc.

Chapter 11 Monitoring ESX/ESXi Hosts

ESX, ESXi, and Virtual Machine Logs


Logscanhelpyoufindoutwhathappenedifcommandsdonothavethedesiredresults.Youcanfindthe followinglogsonyourESX/ESXisystem.
Component ESXServer2.xservicelog ESXServer3.xorESXservicelog vSphereclientagentlog Virtualmachinekernelcorefile Sysloglog Serviceconsoleavailabilityreport VMkernelmessages,alerts,and availabilityreport VMkernelwarning Virtualmachinelogfile Virtualmachineconfigurationfile Location /var/log/vmware/vmware-serverd.log /var/log/vmware/hostd.log /var/log/vmware/vpx/vpxa.log Afteryourebootyourmachine,files/root/vmkernel-log.<date>and /root/vmkernel-core.<date>arepresent. /var/log/messages /var/log/vmkernel /var/log/vmkernel /var/log/vmkwarning vmware.loginthesamedirectoryastheVMXfileforthevirtualmachine <virtual_machine_name>/<virtual_machine_name>.vmxlocatedona datastoreassociatedwiththemanagedhost.Usethevirtualmachinesummary pageinthevSphereClienttodeterminethedatastoreonwhichthisfileislocated.

Enabling and Disabling CIM Providers


Thevicfg-advcfgcommandoffersanumberoflowleveladvancedoptions.Mostoptionsarenotintended forcustomeruse.YoumightusethiscommandwhenVMwareTechnicalSupportoraVMwareKnowledge Basearticleinstructyoutodoso. Anexceptionisthevicfg-advcfg-soption,whichyoucanusetoenableanddisableOEMorCustom(IHV) CIMprovidersandVMWgroups.WiththeVMwareCIMAPIs,developerscanbuildstandardsbased CIMcompliantmanagementapplicationstomanageESX/ESXihosts.SeetheVMwareCIMAPI documentation.

EnableCIMprovidersasfollows: OEMCIMproviders IHVCIMproviders AllCIMproviders


vicfg-advcfg <conn_options> -s 1 CIMOEMProvidersEnabled vicfg-advcfg <conn_options> -s 1 CIMCustomProvidersEnabled vicfg-advcfg <conn_options> -s 1 UserVars.CIMEnabled

EnableordisableVMWgroups.Bydefault,allgroupsareenabled.Ifyourunvicfg-advcfg -sto disableagroup,thechangetakeseffectafterSFCBDservicerestartorESX/ESXihostreboot.Forexample, youcandisableallCIMprovidersasfollows:


vicfg-advcfg <conn_options> -s 0 UserVars.CIMEnabled

Thefollowingprovidergroupsareavailable:

UserVars.CIMEnabled UserVars.CIMemulexProviderEnabled UserVars.CIMlsiProviderEnabled UserVars.CIMqlogicProviderEnabled UserVars.CIMvmw_hdrProviderEnabled UserVars.CIMvmw_kmoduleEnabled UserVars.CIMvmw_lsiProviderEnabled UserVars.CIMvmw_swmgtProviderEnabled

VMware, Inc.

129

vSphere Command-Line Interface Installation and Scripting Guide

130

VMware, Inc.

12

vSphere CLI Command Overviews

12

ThevSphereCLIReference,availableonthevSphereCLIdocumentationpage,isacompletereferencetoallvCLI commandsexceptresxtopandesxcli.Thischaptergivesanoverviewofallcommandsandpointstorelated documentation. Thischapterincludesthefollowingtopics:


ListofAvailableCommandsonpage 131 SupportedPlatformsforCommandsonpage 133 CommandswithanesxcfgPrefixonpage 135 esxcliCommandOverviewonpage 136

List of Available Commands


Table 121listsallvCLIcommandsinalphabeticalorderandpointstothevCLIdiscussioninthisdocument andrelateddocumentation. Table 12-1. vCLI Commands Supported by ESX/ESXi
Command esxcli Description Supportsavarietyofnamespacesand commandslistedinesxcliCommand Overviewonpage 136. See ManagingPathPolicieswithesxclion page 55. SettingUpPortsforiSCSIMultipathingon page 80. ManagingThirdPartyStorageArrayswith esxclionpage 97. ForciblyStoppingVirtualMachineson page 95. esxclisupportsothercommandsforworking withstorage,networking,andvirtual machines. resxtop MonitorsinrealtimehowESX/ESXihostsuse resources.Runsininteractiveorbatchmode. ThiscommandissupportedonlyonLinux. svmotion Movesavirtualmachinesconfigurationfile andoptionallyitsdiskswhilethevirtual machineisrunning. MustrunagainstavCenterServersystem. vicfg-advcfg Performsadvancedconfigurationincluding enablinganddisablingCIMproviders. UsethiscommandasinstructedbyVMware. vicfg-authconfig AllowsyoutoremotelyconfigureActive DirectorysettingsforanESX/ESXihost. UsingvicfgauthconfigforActiveDirectory Configurationonpage 32. EnablingandDisablingCIMProviderson page 129. UsingresxtopforPerformanceMonitoring onpage 125. SeetheResourceManagementGuidefora detailedreference. MigratingVirtualMachineswithsvmotion onpage 59.

VMware, Inc.

131

vSphere Command-Line Interface Installation and Scripting Guide

Table 12-1. vCLI Commands Supported by ESX/ESXi (Continued)


Command vicfg-cfgbackup Description BacksuptheconfigurationdataofanESXi systemandrestorespreviouslysaved configurationdata. See BackingUpConfigurationInformationwith vicfgcfgbackuponpage 28. SeetheESXi EmbeddedandvCenterServerSetup Guideforanindepthdiscussionthatincludes stepbystepinstructions. SettingtheDNSConfigurationonpage 119. ManagingDiagnosticPartitionswith vicfgdumppartonpage 125. Stopping,RebootingandExaminingHosts withvicfghostopsonpage 27. EnteringandExitingMaintenanceModewith vicfghostopsonpage 28. vicfg-ipsec SetsupIPsec(InternetProtocolSecurity), whichsecuresIPcommunicationscoming fromandarrivingatESX/ESXihosts.ESX/ESXi hostssupportIPsecusingIPv6. ManagesiSCSIstorage. EnablesVMkerneloptions.Usethiscommand withtheoptionslistedinthisdocument,oras instructedbyVMware. Configuresstoragearrays. Usevicfg-mpath35forESX/ESXi3.5hosts. ManagesNASfilesystems. ManagestheESX/ESXihostsphysicalNICs. SpecifiestheNTP(NetworkTimeProtocol) server. Rescansthestorageconfiguration. ManipulatestheESX/ESXihostsrouteentry. FindsavailableLUNs. ManagestheSimpleNetworkManagement Protocol(SNMP)agent. UsingvicfgipsecforSecureNetworkingon page 121.

vicfg-dns vicfg-dumppart vicfg-hostops

SpecifiesanESX/ESXihostsDNS(Domain NameServer)configuration. Managesdiagnosticpartitions. Manageshosts.

vicfg-iscsi vicfg-module

ManagingiSCSIStorageonpage 65. ManagingVMkernelModuleswith vicfgmoduleonpage 32. ManagingPathswithvicfgmpathon page 53. ManagingNFS/NASDatastoreswith vicfgnasonpage 58. ManagingUplinkAdapterswithvicfgnics onpage 116. AddingandStartinganNTPServeron page 120. RescanningStorageAdapterswith vicfgrescanonpage 63. ManagingtheIPGatewayonpage 120. ExaminingLUNswithvicfgscsidevson page 52. ManagingESX/ESXiSNMPAgentswith vicfgsnmponpage 127. UsingSNMPinavSphereenvironmentis discussedindetailintheDatacenter AdministrationGuide.

vicfg-mpath vicfg-mpath35 vicfg-nas vicfg-nics vicfg-ntp vicfg-rescan vicfg-route vicfg-scsidevs vicfg-snmp

vicfg-syslog

Specifiesthesyslogserverandtheportto connecttothatserverforESXihosts.

ConfiguringSyslogonESXiHostson page 126 TheDatacenterAdministrationGuideexplains howtosetupsystemlogsusingthevSphere Client.

vicfg-user

Creates,modifies,deletes,andlistslocaldirect accessusersandgroupsofusers.

ManagingUsersonpage 83 SeetheDatacenterAdministrationGuidefor discussionsofcustomrolesandofsecurity implicationsofusermanagement. AddingandModifyingVMkernelNetwork Interfaceswithvicfgvmkniconpage 117 ManagingDuplicateVMFSDatastoreswith vicfgvolumeonpage 61.

vicfg-vmknic vicfg-volume

Adds,deletes,andmodifiesVMkernel networkinterfaces. SupportsresignaturingathecopyofaVMFS volumeandmountingandunmountingthe copy.

132

VMware, Inc.

Chapter 12 vSphere CLI Command Overviews

Table 12-1. vCLI Commands Supported by ESX/ESXi (Continued)


Command vicfg-vswitch vifs Description Addsorremovesvirtualswitchesormodifies virtualswitchsettings. Performsfilesystemoperationssuchas retrievinganduploadingfilesontheESXi system. ManagesupdatesofESX/ESXihosts.Use vihostupdate35forESXi3.5hosts. See SettingUpVirtualSwitchesandAssociatinga SwitchwithaNetworkInterfaceonpage 114. ManagingtheVirtualMachineFileSystem withvmkfstoolsonpage 36 ManagingHostUpdateswithvihostupdate onpage 29. SeealsotheESXiUpgradeGuide. vmkfstools Createsandmanipulatesvirtualdisks,file systems,logicalvolumes,andphysicalstorage devicesonanESX/ESXihost. Performsvirtualmachineoperationsremotely. Thisincludes,forexample,creatinga snapshot,poweringthevirtualmachineonor off,andgettinginformationaboutthevirtual machine. ManagingtheVirtualMachineFileSystem withvmkfstoolsonpage 36. ManagingVirtualMachinesonpage 89.

vihostupdate vihostupdate35

vmware-cmd

Supported Platforms for Commands


vCLI4.0andlatersupportsmorefunctionalitythanvSphereCLI3.5.Differentcommandssupportadifferent rangeoftargetservers. MostcommandscanrunagainstanESX/ESXisystemandhavevCenterServersupport.vCenterServer supportmeansthatyoucanconnecttoavCenterServersystemanduse--vihosttospecifytheESX/ESXi hosttorunthecommandagainst.Theonlyexceptionissvmotion,whichyoucanrunagainstvCenterServer systems,butnotagainstESX/ESXisystems. ThefollowingcommandsmusthaveanESX/ESXisystem,notavCenterServersystemtarget:

vicfg-snmp vifs vicfg-user vicfg-cfgbackup vihostupdate vmkfstools esxcli vicfg-ipsec

Youcannotrunthevihostupdateandvicfg-mpathcommandsthatareinavCLI4.xinstallationagainst ESX/ESXi3.5orvCenter2.5systems.Instead,runvihostupdate35andvicfg-mpath35,includedinthevCLI 4.xinstallation,againstthosesystems.vihostupdate35issupportedforESXibutnotESX. IMPORTANTIfyourunvCLI4.xcommandsagainstESX/ESXi3.5systems,youcanuseonlytheoptions supportedbythosesystems. SeetheVMwareInfrastructureRemoteCommandLineInterfaceInstallationandReferenceGuideforESX/ESXi Update2foralistofsupportedoptions.Toaccessthatdocument,selectResources,thenDocumentationfrom theVMwarewebsite.FindthevSpheredocumentationsetandopenthearchive.AsmallnumberofvCLI4.x optionsaresupportedagainsthostsrunningESX/ESXi3.5Update2orlatereventhoughtheywerenot supportedinRCLIversion3.5. RunavCLI4.xcommandwith--helpforinformationonoptionsupportwithESX/ESXi3.5Update 2,orsee theVMwareknowledgebasearticleathttp://kb.vmware.com/kb/1008940formoredetail.

VMware, Inc.

133

vSphere Command-Line Interface Installation and Scripting Guide

Table 122listsplatformsupportforthedifferentvCLI4.xcommands.Thesecommandshavenotbeentested againstVirtualCenter2.5Update2systems.Youcan,however,connecttoavCenterServer4.xsystemand targetESX/ESXi3.5Update2hosts. Table 12-2. Platform Support for vCLI 4.x Commands
Command esxcli resxtop svmotion vicfg-advcfg vicfg-authconfig vicfg-cfgbackup vicfg-dns vicfg-dumppart vicfg-hostops 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-vmhbadevs vicfg-vmknic vicfg-volume vicfg-vswitch vifs vihostupdate vmkfstools vmware-cmd vicfg-mpath35 vihostupdate35 ESXi 4.x Yes Yes No Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes ESX 4.x Yes Yes No Yes Yes No Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes No Yes VC 4.x No Yes Yes Yes Yes No Yes Yes Yes No Yes Yes Yes Yes Yes Yes Yes Yes Yes No Yes No ESXi 3.5 U2+ No Yes No Yes No Yes Yes Yes No No No Yes ESX 3.5 U2+ No Yes No Yes No No Yes Yes No No No Yes

Usevicfg-mpath35instead. Yes Yes Yes Yes Yes No Yes Yes Yes Yes Yes No Yes Yes Usevihostupdate35 instead Yes Yes Yes Yes Yes Yes Yes Yes Yes No Yes No Yes Yes Yes No Yes Yes No Yes Yes Yes No

NotincludedinvCLI4.x.Usevicfg-scsidevs instead. Yes Yes Yes Yes Yes Yes Yes No No Yes Yes Yes Yes Yes Yes Yes No No Yes Yes Yes No No No Yes No No

Table 123listsplatformsupportforthedifferentvCLI3.5commands.Thesecommandsarenotsupported againstvSphere4.xsystems.

134

VMware, Inc.

Chapter 12 vSphere CLI Command Overviews

Table 12-3. Platform Support for vCLI 3.5 Commands


Command esxcli resxtop svmotion vicfg-advcfg vicfg-cfgbackup vicfg-dns vicfg-dumppart 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-vmhbadevs vicfg-vmknic vicfg-volume vicfg-vswitch vifs vihostupdate vmkfstools vmware-cmd ESXi 3.5 U2+ No Yes N.A. Yes Yes Yes Yes No Yes Yes Yes Yes Yes Yes Yes No Yes Yes Yes Yes Yes No Yes Yes Yes Yes Yes ESX 3.5 U2+ No Yes N.A. Yes No Yes Yes No Yes Yes Yes Yes Yes Yes Yes No Yes No Yes Yes Yes No Yes Yes No Yes Yes VC 2.5 U2+ No No Yes Yes No Yes Yes No Yes Yes Yes Yes Yes Yes Yes No No Yes No Yes Yes No Yes No No No Yes

Commands with an esxcfg Prefix


FormanyofthevCLIcommands,youmighthaveusedscriptswithcorrespondingserviceconsolecommands startingwithanesxcfgprefixtomanageESX3.xhosts.TofacilitateeasymigrationfromESX3.xtoESX/ESXi, thecommandswiththeesxcfgprefixareavailableasvCLIcommands. IMPORTANTVMwarerecommendsthatyouusethevCLIcommandswiththevicfgprefix.Commandswith theesxcfgprefixareavailablemainlyforcompatibilityreasonsandmightbecomeobsolete. Table 124listsallvCLIcommandsforwhichacommandwithanesxcfgprefixisavailable. Table 12-4. Commands with an esxcfg Prefix
Command with vicfg prefix vicfg-advcfg vicfg-cfgbackup vicfg-dns Command with esxcfg prefix esxcfg-advcfg esxcfg-cfgbackup esxcfg-dns

VMware, Inc.

135

vSphere Command-Line Interface Installation and Scripting Guide

Table 12-4. Commands with an esxcfg Prefix (Continued)


Command with vicfg prefix vicfg-dumppart vicfg-module vicfg-mpath vicfg-nas vicfg-nics vicfg-ntp vicfg-rescan vicfg-route vicfg-scsidevs vicfg-snmp vicfg-syslog vicfg-vmknic vicfg-volume vicfg-vswitch Command with esxcfg prefix esxcfg-dumppart esxcfg-module esxcfg-mpath esxcfg-nas esxcfg-nics esxcfg-ntp esxcfg-rescan esxcfg-route esxcfg-scsidevs esxcfg-snmp esxcfg-syslog esxcfg-vmknic esxcfg-volume esxcfg-vswitch

esxcli Command Overview


TheesxclivCLIcommanddiffersfromothervCLIcommands.ThecommandisnotaPerlscriptandyou cannotinvokeitwitha.plextension.Onlythecommandoptionssupportcorrespondingshortoptions;there arenoshortoptionsforotherelements(namespace,app,orcommand). IMPORTANTYoucanrunesxcliwith--serverpointingtoanESX/ESXihost,butnotwith--server pointingtoavCenterServersystem. esxclidoesnotsupportcredentialstoreauthenticationorthe--credstoreoption. ThecommandisinstalledinthesamelocationasothervCLIcommandsandyouinvokeitwiththesame connectionoptionsasothervCLIcommands.SeeRunningvCLICommandsonpage 19. Thecommandhasthefollowingsyntax:
esxcli <conn_options> <namespace> <app> <cmd> [cmd options] Option <conn_options> Description ConnectionparametersforthevCLImustprecedeallotherparameters,oryoumustperform authenticationinotherways.Forexample,youcanperformauthenticationusingvifastpasson vMA,orusingenvironmentvariables.SeevCLIConnectionOptionsonpage 23.ESXCLIdoes notsupportthecredentialstore. Namespace.Oneofthefollowing: nmpVMwarenativemultipathingcommands. swiscsiCommandsinthesoftwareiSCSIanddependenthardwareiSCSInamespace. corestorageVMwarecorestoragecommands. <app> <cmd> <cmd options> Areawithinthenamespacetowhichthecommandapplies. Commandtobecalled. Commandoptions.

<namespace>

136

VMware, Inc.

Chapter 12 vSphere CLI Command Overviews

Help for esxcli


CommandlinehelpfortheesxclivCLIisavailableonaperlevelbasis. IMPORTANTWhenusingtheesxclivCLI,youmustsupplyconnectioninformationincludingausername andpassword,evenifyoucallthecommandwith--help.esxclidisplaystheinformationaboutavailable commandsandoptionsontheserveryouspecify. Thisbehaviordiffersfrom--helpforothervCLIcommandsbecauseothercommandsdonotchange dependingonthetargetserver. Howyoucallhelpdependsonwhatyoucallhelpfor.
Command esxcli esxcli --help esxcli -? esxcli <conn_options> --help esxcli <conn_options> -? esxcli <conn_parms> <namespace> --help esxcli <conn_parms> <namespace> -? esxcli <conn_options> <namespace> <app> --help esxcli <conn_options> <namespace> <app> -? esxcli <conn_options> <namespace> <app> <command> --help esxcli <conn_options> <namespace> <app> <command> -? Example esxcli <Enter> esxcli --help esxcli -? esxcli --server S1 --help esxcli --server S1 -? esxcli --server S1 nmp --help esxcli --server S1 nmp -? Output Listsallsupportednamespaceson thissystem. Displayshelpforsupported connectionoptions. Displayshelpforsupportedname spaces. Displayshelpforsupportedapps forthisnamespace.

esxcli --server S1 nmp device --help esxcli --server S1 nmp device -? esxcli --server S1 nmp device setpolicy --help esxcli --server S1 nmp device setpolicy -?

Displayshelpforsupported commandsforthisapp.

Displayshelpforsupportedoptions forthiscommand.

Thissectionisareferencetoesxclicommands,organizedonapernamespacebasis.Thereferencepointsto placesinthismanualthatdiscussusingthecommand.

esxcli corestorage Namespace


Theesxcli corestorageclaimingcommandsincludepluggablestoragedirectpathclaimingcommands andclaimrulecommands.ThesecommandsoperateontherulesthatdeterminewhichPSApluginisusedto claimstoragepaths.

claiming Commands
Theesxcli corestorage claimingcommandsapplytothepluggablestoragedirectpathclaimingsystem. Theseoperationsallowausertodirectlycontroltheclaimingandunclaimingprocess.Theresultsofthese operationsaretemporary.Claimingoperationsthatneedtopersistafterarebootshoulduseclaimrules instead(seeclaimruleCommandsonpage 138). Youcanspecifythefollowingclaimingcommands.
Command autoclaim reclaim Description DonotusethiscommandunlessinstructedtodosobyVMwaresupportstaff. Attemptstounclaimallpathstoadeviceandrunstheloadedclaimrulesoneachofthe unclaimedpathstoreclaimthem.Supportsthefollowingoptions:

-d|--deviceNameofadeviceonwhichallpathswillbeunclaimedandthenreclaimed. -h|--helpShowthehelpmessage.

VMware, Inc.

137

vSphere Command-Line Interface Installation and Scripting Guide

Command unclaim

Description Unclaimsapathorsetofpaths,disassociatingitfromaPSAplugin.Itisnormalforpath claimingtofailespeciallywhenunclaimingbypluginoradapter.Onlyinactivepathswithno I/Ocanbeunclaimed.TypicallytheESXiUSBpartitionanddeviceswithVMFSvolumeson themarenotunclaimable. Unclaimingdoesnotpersistandperiodicpathclaimingreclaimsunclaimedpathsashorttime aftertheunclaimoperationsunlessclaimrulesareconfiguredtomaskthepath.SeeMasking Pathswithesxclicorestorageclaimruleonpage 57. Seeesxclicorestorageclaimingunclaimonpage 105foralistofoptions.

claimrule Commands
Theesxcli corestorage claimrulecommandsoperateontherulesusedtodeterminewhichPSAplugin isusedtoclaimstoragepaths.Youcanalsousethesecommandstomaskpaths,seeMaskingPathswithesxcli corestorageclaimruleonpage 57. Thefollowingcommandsaresupported.
Command add convert Description Addsaclaimruletothesetofclaimrulesonthesystem.SupportsoptionslistedinAdding ClaimRuleswithesxclicorestorageclaimruleaddonpage 106. ConvertsESX3.xstyle/adv/Disk/MaskLUNsLUNmaskstoclaimruleformat. ThisconversiondoesnotworkforallinputMaskLUNsvariations.Aftertheconvertoperation hasgeneratedalistofclaimrules,inspectthoserulesfirst.IfthesuggestedLUNmaskclaim rulesarecorrect,usethe--commitoptiontowritethelisttotheconfigurationfile. SeeConvertingESX3.5LUNMaskstoClaimRuleFormatonpage 107. delete list load move run Deletesaclaimrule.SeeDeletingClaimRuleswithesxclicorestorageclaimruledeleteon page 108. Listsallclaimrulesonthesystem. LoadspathclaimingrulesfromtheconfigurationfileintotheVMkernel.SeeLoadingClaim Ruleswithesxclicorestorageclaimruleloadonpage 108. Movesaclaimrulefromoneruleidtoanother.SeeMovingClaimRuleswithesxclicorestorage claimrulemoveonpage 109. Runspathclaimingrules.Seeesxclicorestorageclaimrulerunonpage 109.

device Commands
Theesxcli corestorage device list commandappliestothepluggablestoragearchitectureslogical devicesonthesystem.Thecommandisusedinconjunctionwithhardwareacceleration,discussedintheFibre ChannelSANConfigurationGuideandtheiSCSISANConfigurationGuide.
Command list Description FordevicescurrentlyregisteredwiththePSA,liststheattachedfilters.Supportsthefollowing options:

-d|--deviceFilterstheoutputofthiscommandtoonlyshowasingledevice. -h|--helpShowsthehelpmessage.

138

VMware, Inc.

Chapter 12 vSphere CLI Command Overviews

plugin commands
Theesxcli corestorage plugin listcommandworksonPSAplugins.Thecommandisusedin conjunctionwithhardwareacceleration,discussedintheFibreChannelSANConfigurationGuideandtheiSCSI SANConfigurationGuide.
Command list Description ListsPSApluginsavailableonthespecifiedsystem.Supportsthefollowingoptions:

-N|--plugin-class=<str> Indicatestheclassofplugintolimitthelistto.Thefollowing valuesaresupported:


Filter:Filterplugins MP:Multipathingplugins VAAI:VAAIplugins all:AllPSAPlugins(default)

Forexample,youcanlistallPSApluginsthataremultipathingpluginsbyrunningthefollowing command: esxcli corestorage plugin list --plugin-class=MP

esxcli network Namespace


Theesxcli networknamespaceallowsyoutolistinformationaboutthecurrentnetworkstatus.The namespacesupportstheconnectionsandneighborsapps.

connections list Command


Theesxcli network connectionslistcommandlistsactiveTCP/IPconnections.
Command list Description ListsactiveTCP/IPconnections.Supportsthefollowingoptions:

-h|--helpShowsthehelpmessage. -t | --type Specifiestheconnectiontypeforwhichyouwanttolistactiveconnections. Supportedtypesareip,tcp,udp,andall.

neighbors show Command


Theesxcli network neighborsshowcommandlistsactiveARPtableentries.
Command show Description ListsactiveARPtableentries.Supportsthefollowingoptions:

h|helpShowsthehelpmessage. v|version IPversiontolistentriesfor.Supportedtypesare4,6,andall.

esxcli nmp Namespace


Theesxcli nmpnamespaceallowsyoutoviewandmanipulatetheNativeMultipathingPlugin.SeetheESX ConfigurationGuideforbackgroundinformationaboutthePluggableStorageArrayarchitectureandthe NativeMultipathingPlugin.

boot restore Command


Theesxcli nmp boot restorecommandcanbeusedtorestoreconfigurationstateoftheNMPpluginat boottime. esxcli nmp boot restore Thecommandsupportsa--helpoptionbutnootheroptions.

VMware, Inc.

139

vSphere Command-Line Interface Installation and Scripting Guide

device Commands
Theesxcli nmp devicecommandscanbeusedforinspectingandmanagingthedevicesthatarecurrently claimedbytheVMwareNMP.Thefollowingcommandsaresupported.
Command Description ListsthedevicescurrentlycontrolledbyVMwareNMPandshowstheSATPandPSP informationassociatedwiththosedevices.

list

-d|--deviceFilterstheoutputofthiscommandtoonlyshowasingledevice. -h|--helpShowsthehelpmessage.

setpolicy

AllowssettingofthePSPforthegivendevicetooneofthepoliciesloadedonthesystem.

-E|--default SetsthePSPfortheassignedSATPforthisdevicebacktothedefault. -d|--device DeviceyouwishtosetthePSPfor. -h|--help Showsthehelpmessage. -P|--psp PSPyouwishtoassigntothedevicespecifiedby--device.

fixed Commands
The esxcli nmp fixedcommandsapplytotheFixedPSP.Thefollowingcommandsaresupported.
Command getpreferred Description RetrievesfixedPSPsettingsforthespecifieddevice.

-d|--deviceDeviceyouwishtogetthepreferredpathfor. -h|--helpShowsthehelpmessage.

setpreferred

Setsthepreferredpathonaspecifieddevicecontrolledbythefixedpathselectionpolicy.

-E|--default Clearsthepreferredpathselectionforthegivendevice. -d|--device Deviceyouwishtosetthepreferredpathfor.Thisdevicemustbecontrolled bythefixedPSP. -h|--help Showsthehelpmessage. -p|--path Pathyouwishtosetasthepreferredpathforthegivendevice.

path Commands
Theesxcli nmp pathlistcommandliststhepathsthatarecurrentlyclaimedbyVMwareNMP.
Command Description ListthepathscurrentlyclaimedbyVMwareNMPandshowtheSATPandPSPinformation associatedwiththatpath.

list

-d|--device Filterstheoutputofthiscommandtoonlyshowpathstoasingledevice. -h|--help Showsthehelpmessage. -p|--path Filterstheoutputofthiscommandtoonlyshowasinglepath

psp Commands
Theesxcli nmp pspcommandsapplytothePSPfortheNMP.Thefollowingcommandsaresupported.
Command getconfig Description RetrievesperpathorperdevicePSPconfigurationparameters.

-d|--deviceDeviceyouwishtogetPSPconfigurationfor.Ifyouspecify--device,youcannot specify --path. -h|--help Showthehelpmessage. -p|--path PathyouwishtogetPSPconfigurationfor.Ifyouspecify--path,youcannot specify --device.

list

ListsthePSPthatarecurrentlyloadedintotheNMPsystemanddisplayinformationaboutthosePSPs.

140

VMware, Inc.

Chapter 12 vSphere CLI Command Overviews

Command setconfig

Description AllowssettingofperpathorperdevicePSPconfigurationparameters.Setstheconfigurationforthe givendeviceorpathwiththePSPitiscurrentlyconfiguredwith.


-c|--config Configurationstringyouwishtosetforthegivenpathordevice. -d|--device DeviceyouwishtosetPSPconfigurationfor.Ifyouspecify--device,youcannot specify --path. -h|--help Showthehelpmessage. -p|--path PathyouwishtosetPSPconfigurationfor.Ifyouspecify--path,youcannotspecify --device.

roundrobin Commands
esxcli nmp roundrobincommandsapplytotheroundrobinPSP.Thefollowingcommandsaresupported:
Command getconfig Description AllowsretrievalofroundrobinPSPsettingsforagivendevice.

-d|--deviceDeviceyouwishtogetthesettingsfor. -h|--helpShowsthehelpmessage.

setconfig

AllowssettingoftheroundrobinpathoptionsonagivendevicecontrolledbytheRoundRobin PSP.SeeCustomizingRoundRobinSetupwithesxclinmproundrobinonpage 101.

satp Commands
esxcli nmp satp commandsapplytotheSATPsfortheVMwareNMP.Thefollowingcommandsare supported:
Command addrule deleterule getconfig list listrules setconfig setdefaultpsp Description AddsaruletothelistofclaimrulesforthegivenSATP.SeeAddingSATPRulesonpage 102 DeletesarulefromthelistofclaimrulesforthegivenSATP.SeeDeletingSATPRulesonpage 103 AllowsretrievalofperpathorperdeviceSATPconfigurationparameters. ListstheSATPsthatarecurrentlyloadedintotheNMPsystemanddisplayinformationaboutthose SATPs.SeeRetrievingInformationAboutSATPsonpage 102. ListstheclaimingrulesforSATPs. AllowssettingofperpathorperdeviceSATPconfigurationparameters.Seeesxclinmp roundrobinsetconfigonpage 101. SetsthedefaultPSPforagivenSATP.SeeSettingtheDefaultPSPonpage 104.

esxcli swiscsi Namespace


ThecommandsintheswiscsinamespacesupportsoftwareiSCSImanagement.

nic Commands
esxcli swiscsi niccommandsallowyoutoperformoperationsoniSCSInetworkinterfaces.Youcanbind anexistingVMkernelnetworkinterfaceforusebyiSCSI,removeaVMkernelnetworkinterfacefromthe currentiSCSIconfiguration,andlistnetworkportbindings.Thefollowingcommandsaresupported.
Command add Description BindsanexistingVMkernelnetworkinterfacethatisnotusedforotherpurposestothecurrent softwareiSCSIconfiguration.Supportsthefollowingoptions:

-d | --adapter NameofthesoftwareiSCSIadaptertobindtotheVMkernelnetworkinterface. -h | --help Showsthehelpmessage. -n | --nic NameoftheVMkernelnetworkinterfacetobindasaniSCSInetworkinterface.

SeeAddingandModifyingVMkernelNetworkInterfaceswithvicfgvmkniconpage 117for informationoncreatinganewVMkernelnetworkinterfaceforiSCSI.

VMware, Inc.

141

vSphere Command-Line Interface Installation and Scripting Guide

Command list

Description ListsnetworkportbindingsfortheVMkernelnetworkinterface.Supportsthefollowingoptions:

-d | --adapter NameoftheiSCSIadapterforwhichyouwanttolistnetworkportbindings. -h | --help Showsthehelpmessage.

remove

RemovesaVMkernelnetworkinterfacefromthecurrentsoftwareiSCSIconfiguration.Supportsthe followingoptions:

-d | --adapter NameofthesoftwareiSCSIadapterfromwhichyouwanttoremovethe networkinterface. -h | --help Showsthehelpmessage. -n | --nic NameoftheVMkernelnetworkinterfacetoremovethebindingfrom.

session Commands
esxcli swiscsi sessioncommandsallowyoutoadd,list,andremoveiSCSIloginsessions.SeeManaging iSCSISessionsonpage 80.Thefollowingcommandsaresupported.
Command add Description AddsaloginsessiontothecurrentiSCSIconfiguration.Supportsthefollowingoptions:

-d | --adapter NameofthesoftwareiSCSIadapteryouwanttoaddasessionto. -h | --help Showsthehelpmessage. -s | --isid iSCSIIDofthesessionyouwanttoduplicateforlogin.Runesxcli swiscsi session listforthatdevicetoseethesessioniSCSIID(session_isid). -t | --target Nameofthetargettologinto.

list

Listsinformationaboutsessionsforaspecifiedadapterortarget.Youneedthisinformationwhenyou wanttoremoveasessionfromanadapter.Supportsthefollowingoptions:

-d | --adapter Nameoftheadapteryouwanttolistinformationfor. -h | --help Showsthehelpmessage. -t | --target Nameofthetargettolistinformationfor.

remove

RemovesthespecifiediSCSIsessionorsessionsfromtheiSCSIconfiguration.Supportsthefollowing options:

-d | --adapter NameofthesoftwareiSCSIadapteryouwanttoremoveasessionfrom. -h | --help Showsthehelpmessage. -s | --isid TheiSCSIIDofthesessionyouwanttoremove.Runesxcli swiscsi session listforthatdevicetoseethetargetiSCSIID(session_isid) -t | --target Nameofthetargettoremove.Runesxcli swiscsi session listforthat devicetoseethetarget.

vmknic Commands
Theesxcli swiscsi vmkniclistcommandallowsyoutolistVMkernelnetworkinterfacesavailablefor bindingtoaparticulariSCSIadapter.
Command list Description ListsallVMkernelnetworkinterfaces.Supportsthefollowingoptions: -d|--adapter TheiSCSIadaptername(vmhba#)forwhichyouwanttolistVMkernel networkinterface. -h|--help Showthehelpmessage.

vmnic Commands
Theesxcli swiscsi vmnic listcommandallowsyoutolistavailableuplinkadaptersforusewitha specifiediSCSIadapter.
Command list Description -d|--adapter TheiSCSIadaptername(vmhba#). -h|--help Showsthehelpmessage.

142

VMware, Inc.

Chapter 12 vSphere CLI Command Overviews

esxcli vaai Namespace


Thevaai(vStorageAPIsforArrayIntegration)namespaceincludescommandsthatallowstorage managementonapervirtualmachineorperVMDKfilebasis. IfyouaddathirdpartyVAAIplugintoyourenvironment,arebootisrequiredinmostcases.Seeyourstorage vendorsdocumentationformoreinformation.

device list Command


Theesxcli vaai device listcommandcanrunondevicesthathavetheVMwareVAAIfilterattached.
Command list Description ListsthedevicesclaimedbytheVMwareVAAIFilterPluginandshowstheVAAIFilterplugin informationassociatedwiththatdevice.Supportsthefollowingoptions:

-d|--device Filterstheoutputofthiscommandtoonlyshowasingledevice. -h|--help Showsthehelpmessage.

esxcli vms Namespace


Thevms(virtualmachines)namespacesupportsvirtualmachineoperations.Itcurrentlyallowsyoutoforcibly stopavirtualmachine,asdiscussedinForciblyStoppingVirtualMachinesonpage 95.

vm Commands
Command kill Description Allowsyoutoforciblystopvirtualmachinesthatdonotrespondtonormalstopoperations. Supportsthefollowingoptions:

t|type Typeofkilloperation,Usethetypessequentially(softbeforehard,hardbefore force).Thefollowingtypesaresupportedthroughthetypeoption:


softGivestheVMXprocessachancetoshutdowncleanly(likekill S--SIGTERM) hardStopstheVMXprocessimmediately(likekill -9orkill -SIGKILL) forceStopstheVMXprocesswhenotheroptionsdonotwork.

Ifallthreeoptionsdonotstopthevirtualmachine,reboottheESX/ESXisystem.

-w|--world-id WorldIDofthevirtualmachinetokill.Runesxcli vms vm listtofind theWorldID.

list

Listsinformationaboutallrunningvirtualmachines,includingtheWorldIDofthevirtual machine,neededbythekillcommand.

VMware, Inc.

143

vSphere Command-Line Interface Installation and Scripting Guide

144

VMware, Inc.

Index

Index

Numerics
2gbsparse disk format 40 3.5 LUN masks 107

A
Active Directory 32, 33 active path 55 ARP redirect 72 authentication algorithm (IPsec) 123 default inheritance 69 information 20 key (IPsec) 123 returning to default inheritance 69 AUTOCONF 118

B
backing up configuration data 29 bulletins uninstall 32 vihostupdate 30 bundles 30, 31

commands with esxcfg prefix 131 configuration data backing up 29 restoring 29 configuration files for authentication 21 path 61 usage 21 connection options 20, 23 copying files 47 cp936 encoding 24 creating directories 47 creating session files 21 creating VMFS 39 credential store esxcli 98, 136 precedence 20

D
datastores mounting 62 overview 51 default inheritance 69, 79 default port groups 114 deleting virtual disks 42 dependent hardware iSCSI 65, 70 deploying vMA 17 depots 31 device management 53, 99 device mappings 53 device naming 51 device target 38 Device UID 51 DHCP 119, 120 DHCPV6 118 diagnostic partitions example 126 managing 53 vicfg-dumppart 53 directory management 48 discovery sessions 66 discovery targets 67 disk file path 61 disk formats supported by vmkfstools 40 disk partition target 38 disks, cloning 42

C
CDP 114, 115 Challenge Handshake Authentication Protocol 68 changing IP gateway 120 CHAP 68 chapDiscouraged 68 chapPreferred 68 chapProhibited 68 chapRequired 68 CIM providers 129 Cisco Discovery Protocol 114 claim rules adding 106 converting 107 deleting 108 from 3.5 systems 107 from LUN mask 107 listing 108 loading 108 moving 109 running 109 cloning virtual disks 42 command-line connection parameters 22

VMware, Inc.

145

vSphere Command-Line Interface Installation and Scripting Guide

displaying virtual disks 43 distributed virtual switch 111 DNS 119, 120 downloading files 47 dump partitions, vicfg-dumppart 53 duplicate datastores 61 dynamic discovery 66

E
eagerzeroedthick disk format 40 encoding cp936 24 ISO-8859-1 24 Shift_JIS 24 encryption algorithm (IPsec) 122 encryption key (IPsec) 123 ESX/ESXi logs 129 esxcfg prefix 131 esxcfg-nics 116 esxcfg-snmp 127 esxcli command syntax 98 credential store authentication 98, 136 help 137 esxcli corestorage claiming reclaim command 104 unclaim command 105 esxcli corestorage claimrule add command 106 convert command 107 delete command 108 list command 108 load command 108 move command 109 run command 109 esxcli network connections list command 139 neighbors show command 139 esxcli nmp boot restore command 139 esxcli nmp device list command 99 setpolicy command 99 esxcli nmp fixed getpreferred command 100 setpreferred command 101 esxcli nmp psp 100 setconfig command 100 esxcli nmp roundrobin 56, 101 getconfig command 101 setconfig command 101 esxcli nmp satp 102

esxcli swiscsi session commands 142 vmknic commands 142 esxcli swiscsi nic 104 esxcli swiscsi session 80 esxcli vaai 143 device list Command 143 esxcli vms 143 EUI name 54, 67 examples iSCSI storage setup 69, 70 VMFS file system 39 execution options 23 extending file system partition, vmkfstools 39 extending virtual disks 43 external HBA properties 77

F
failover 53 FC LUNs 51 Fibre Channel LUNs 51 file management introduction 35 vifs 36, 48 file path, configuration file 61 file system targets 38 file systems NAS 59 VMFS 39 fixed path selection policy 100

G
gateway, IP 120 getting help for esxcli 137 groups 83, 86, 87 GSX Server 43

H
hard power operations 93 hardware iSCSI setup tasks 72 HBA mappings 53 HBA properties 77 help for esxcli 137 host updates 29 hosts managing 27 shutdown or reboot 27 updates 29

I
independent hardware iSCSI definition 65 setup tasks 72

146

VMware, Inc.

Index

inflating thin virtual disks 41 inheritance 79 initializing virtual disks 41 installing vCLI Linux 11, 20 Windows 15 installing vMA 17 IP gateway 120 IP storage 111 IPsec 121, 122 IPv4 117 IPv6 118 IQN name 67 iSCSI authentication 69, 79 default inheritance 79 dependent hardware iSCSI 70 discovery target names 67 independent hardware iSCSI 72 LUNs 51 mutual authentication 79 options 77 overview 65 parameters 77 parameters, returning to default inheritance 79 path masking 57 port binding 70 ports for multipathing 80 remove sessions 81 securing ports 68 security 67 sessions 80, 81 setup examples 69, 70 ISO-8859-1 encoding 24

LUNs listing available 52 names 54 vicfg-scsidevs 52

M
maintenance mode 28 managing diagnostic partitions 53 managing NMP 99 managing physical network interfaces 116 MASK_PATH plugin 57 masking a path 57 Microsoft Windows Security Support Provider Interface 22 migrating virtual machines GSX Server 43 svmotion 59 vmkfstools 43 VMware Workstation 43 mount datastores 62 MTU 115 multipathing 53 mutual authentication 79 mutual CHAP 70, 71, 79

N
naa.xxx device name 54 NAS file systems 59 NetQueue VMkernel modules 32 network adapters duplex value 116 managing 116 speed 116 vicfg-nics 116 vicfg-vmknic 117 network interfaces 114, 116 networking IPsec 121 list connections 139 vDS 118 vSS 113 NFS, capabilities 58 NIC binding 104 NMP 53, 99 NTP server 120

K
Kerberos 120 kill command 143

L
LibXML2 14 license 60 Linux installing vCLI 11, 20 running vCLI commands 15, 22 vCLI 11 listing available LUNs 52 listing IP gateway 120 listing VMFS volume attributes 39 loading claim rules 108 lockdown mode 23 logs 129 LUN masks, convert to claim rule 107
VMware, Inc.

O
offload iSCSI 65 OpenSSL 14 options 23 order of precedence 20 orphaned virtual machine 90

147

vSphere Command-Line Interface Installation and Scripting Guide

P
parameters command line 22 default inheritance (iSCSI) 79 partitions, diagnostic 126 path operations 99 path policies 55, 100, 101 path state, changing 55 paths active 55 disabling 55 identifier 51 information 54 masking 57 preferred 56, 100 unmasking 58 vicfg-mpath 53 performance monitoring 125 Perl 11 physical compatibility mode RDM 40, 45 physical network adapters 116 physical network interfaces 116 platform support 133 port binding 70, 80 port groups 116 adding 115 and uplink adapter 115 default 114 removing 115 ports, iSCSI multipathing 80 power operations 93 powerop_mode 93 precedence 20 preferred path 56, 100, 101 prerequisites Red Hat Enterprise Linux 5.2 13 SLES 10 and SLES 11 13 Ubuntu Desktop 9.04 13 PSA acronym 97 managing claim rules 106 PSP acronym 97 information 100 operations 100

RDM format 40 RDMs disk format 40 physical compatibility mode 45 virtual compatibility mode 45 rebooting hosts 27 Red Hat Enterprise Linux 5.2 13 register virtual machines 90 removing snapshots 93 renaming virtual disks 42 required parameters 20 rescanning storage 51, 63 resignature VMFS copy 62 restoring configuration data 29 resxtop 125, 131 reverting snapshots 93 RFCs (vicfg-ipsec) 121 roles 83 round robin operations 56, 101 round robin path policy 101 route entry 120 rule IDs 57 rules 103 claim rules 106 SATP rules 103 running commands from vMA 17 Linux 11, 20 Windows 15

S
SATP commands 141 configuration parameters 103 deleting rules 103 retrieve settings 102 rules, adding 102 scripts with vCLI commands 25 secure networking 121 securing iSCSI ports 68 security associations (IPsec) 122 security policies (IPsec) 123 session files 20, 21 sessions, iSCSI 81 setting preferred path 101 Shift_JIS encoding 24 Simple Network Management Protocol 127 SLES 10 13 SLES 11 13 snapshots 43, 92, 93 SNMP communities 127 management 127
VMware, Inc.

R
raw device mapping physical compatibility mode 45 virtual compatibility mode 45 raw disks cloning 42

148

Index

polling 128 traps 128 soft power operations 93 software iSCSI setup tasks 69, 70 spanning partitions, vmkfstools 39 special characters, vicfg-iscsi 79 SSPI protocol 22 standard networking services 119 starting NTP server 120 state of path, changing 55 static discovery 66 stop virtual machine 95 stopping virtual machines 143 storage creating directories with vifs 47 overview 49 rescanning 51, 63 virtual machines 50 storage array target 52 storage device naming 51 supported disk formats 40 supported platforms 133 svmotion 59 interactive Mode 60 license 60 limitations 60 noninteractive mode 60 requirements 60 special characters 60 switch attributes 115 syslog server specification 126 syslog service 127

unmasking paths 58 unregister virtual machines 90 update using bundles 30 using depots 31 updating hosts 29 uplink adapter and port groups 115 setup 116 uplink adapters vicfg-nics 116 useANO (round robin) 57 user input 95 users adding to groups 87 creating 85 in vSphere environment 83 modifying 85 removing from groups 87 using session files 21

V
vaai namespace (esxcli) 143 vCLI command-line 22 configuration files 21 environment variables 21 execution options 23 installing on Linux 11, 20 installing on Windows 15 vicfg-iscsi 49, 65 vCLI package installing on Linux 11 installing on Windows 16 uninstalling 15 unpacking 14 vDS 111, 113 vicfg-advcfg 129 vicfg-authconfig 32 vicfg-cfgbackup 28, 29 vicfg-dumppart 53 vicfg-hostops 27, 28 vicfg-ipsec 121, 122, 123 vicfg-iscsi command syntax 73 default inheritance for authentication 69 default inheritance for parameters 79 iscsi parameter options 78 vicfg-module 32 vicfg-mpath 53 vicfg-nas 58 vicfg-nics 116 vicfg-ntp 120
149

T
target, for vmkfstools 38 TCP/IP 72, 111 TCP/IP stack 111 thin virtual disks format 40 inflating 41 vmkfstools 41 third-party bundle 31 third-party bundles 31 transport mode 122 tunnel mode 122

U
Ubuntu Desktop 9.04 13 uninstalling bulletin (vihostupdate) 32 Linux 15 on Linux 15 on Windows 16
VMware, Inc.

vSphere Command-Line Interface Installation and Scripting Guide

vicfg-rescan 63, 70, 71 vicfg-scsidevs 52, 58 3.5 support 52 vicfg-snmp 127 vicfg-syslog 126 vicfg-user 83, 84, 86 vicfg-vmhbadevs 52 vicfg-vmknic 117 vicfg-volume 61 vicfg-vswitch 114 vifs 36, 46 vihostupdate bulletins 30 bundles 30 depots 31 protocols 30 third-party bundles 31 uninstall bulletin 32 virtual compatibility mode RDM 45 virtual devices 94 virtual disks cloning 42 creating 41 deleting 42 extending 43 geometry 43 inflating 41 initializing 41 options 40 renaming 42 thin 41 virtual machine configuration file path 61 virtual machines attributes 91 file management 35 listing 90 logs 129 managing 91 migration with svmotion 59 network settings 113 orphaned 90 path 90 registering 90 starting 93 stopping 95, 143 storage VMotion 59 vmware-cmd 91 virtual switches 114 MTU 115 vicfg-vswitch 114 VLAN ID 116

vMA 17 environment variables 21 installing 17 multiple configuration files 22 VMFS creating with vmkfstools 38, 39 duplicate datastores 61 listing attributes 39 resignature 62 resignature copy 62 volume attributes 39 VMkernel modules 32 VMkernel NIC 117 enable VMotion 117 IPv4 117 IPv6 118 VMkernel NICs 117 vmkfstools 36 command syntax 36 command-specific options 37 creating virtual disk 41 creating VMFS 38 creating VMFS example 39 deleting virtual disk 42 device target 38 disk formats 40 disk partition target 38 display disk geometry 43 extending virtual disk 43 file system options 38 file system targets 38 inflating thin virtual disk 41 initializing virtual disk 41 options 38 renaming virtual disk 42 snapshots 43 supported targets 38 syntax 36 target 38 virtual disk options 40 VMFS volume attributes 39 VML LUN names 54 VMotion 112, 117 VMW_PSP_FIXED 55 VMW_PSP_FIXED_AP 55 VMW_PSP_MRU 55 VMW_PSP_RR 55 VMware DRS and vicfg-hostops 28 VMware Workstation 43 vmware-cmd connection options 89 general options 90

150

VMware, Inc.

Index

server options 90 snapshots 92 virtual machine options 91 VMware Tools 94 vNetwork distributed switches 111, 113, 118, 119 vNetwork standard switches 112, 113 vSphere Management Assistant 17 vSphere SDK for Perl 11 vSS 111 vStorage APIs for Array Integration 143

W
Windows Active Directory 33 executing commands 22 installing vCLI 15 running vCLI commands 16 using vCLI 15 Workstation virtual machines, migrating 43

Z
zeroedthick disk format 40

VMware, Inc.

151

vSphere Command-Line Interface Installation and Scripting Guide

152

VMware, Inc.

You might also like