VMware vSphere ESXi Commands for everyday use
In this post, I tried listing down all commands that I use everyday for ESXi Troubleshooting. I have categorized the commands for easy accessibility.
I find these commands are very useful when the ESXi host disconnected from vCenter and when not able to connect to vSphere Client.
[toggle type=”first” title=”Virtual Machine Operations”]
To get All registered VMs on the Host:
[code]vim-cmd vmsvc/getallvms[/code]
Example:
~ # vim-cmd vmsvc/getallvms Vmid Name File Guest OS Version Annotation 1 DeskTop [datastore1 (3)] DeskTop/DeskTop.vmx windows8_64Guest vmx-08 2 Domain [datastore1 (3)] Domain/Domain.vmx windows7Server64Guest vmx-08 3 VCD55 [datastore1 (3)] VCD55/VCD55.vmx centos64Guest vmx-08
Power ON a VM:
[code]vim-cmd vmsvc/power.on <VMID> [/code]
Example:
~ # vim-cmd vmsvc/power.on 3 Powering on VM:
Power OFF a VM:
[code]vim-cmd vmsvc/power.off <VMID> [/code]
Example:
~ # vim-cmd vmsvc/power.off 3 Powering off VM:
Gracefully shutdown a VM’s Guest OS:
[code]vim-cmd vmsvc/power.shutdown <VMID> [/code]
Example:
~ # vim-cmd vmsvc/power.shutdown 3 ~ #
Register a VM
[code]vim-cmd solo/registervm <vmxpath> [/code]
Example:
~ # vim-cmd solo/registervm "/vmfs/volumes/datastore1 (3)/VCD55/VCD55.vmx" 4
UnRegister a VM:
[code]vim-cmd vmsvc/unregister <VMID> [/code]
Example:
~ # vim-cmd vmsvc/unregister 4 ~ #
[/toggle]
[toggle title=”Host Operations”]
Enter Host into Maintenance mode:
[code] vim-cmd hostsvc/maintenance_mode_enter [/code]
Exit Host into Maintenance mode:
[code] vim-cmd hostsvc/maintenance_mode_exit [/code]
[/toggle]
[toggle title=”Storage”]
Storage Commands
LUNs
To get All disks attached to ESXi host.
[code] esxcfg-scsidevs -l [/code]
or
[code] esxcli core storage device list [/code]
Sample Output.
naa.600508b1001c0f0e831036c264b4203e Display Name: HP Serial Attached SCSI Disk (naa.600508b1001c0f0e831036c264b4203e) Has Settable Display Name: true Size: 429215 Device Type: Direct-Access Multipath Plugin: NMP Devfs Path: /vmfs/devices/disks/naa.600508b1001c0f0e831036c264b4203e Vendor: HP Model: LOGICAL VOLUME Revision: 3.54 SCSI Level: 5 Is Pseudo: false Status: degraded Is RDM Capable: true Is Local: false Is Removable: false Is SSD: false Is Offline: false Is Perennially Reserved: false Queue Full Sample Size: 0 Queue Full Threshold: 0 Thin Provisioning Status: unknown Attached Filters: VAAI Status: unknown Other UIDs: vml.0200010000600508b1001c0f0e831036c264b4203e4c4f47494341 Is Local SAS Device: false Is Boot USB Device: false No of outstanding IOs with competing worlds: 32
To get All disks attached to ESXi host(Compact List)
~ # esxcfg-scsidevs -c Device UID Device Type Console Device Size Multipath PluginDisplay Name naa.600508b1001c0f0e831036c264b4203e Direct-Access /vmfs/devices/disks/naa.600508b1001c0f0e831036c264b4203e 429215MB NMP HP Serial Attached SCSI Disk (naa.600508b1001c0f0e831036c264b4203e)
LUN to Datastore Mapping
~ # esxcfg-scsidevs -m naa.600508b1001c0f0e831036c264b4203e:3 /vmfs/devices/disks/naa.600508b1001c0f0e831036c264b4203e:3 5131890d-0c77f39a-0382-e4115b9b7270 0 datastore1 (3)
LUN Paths:
~ # esxcfg-mpath -L vmhba0:C0:T0:L1 state:active naa.600508b1001c0f0e831036c264b4203e vmhba0 0 0 1 NMP active san sas.5001438027641890 sas.1438027641890 ~ # esxcfg-mpath -m vmhba0:C0:T0:L1 vmhba0 sas.5001438027641890 sas.1438027641890 naa.600508b1001c0f0e831036c264b4203e ~ # esxcfg-mpath -b naa.600508b1001c0f0e831036c264b4203e : HP Serial Attached SCSI Disk (naa.600508b1001c0f0e831036c264b4203e) vmhba0:C0:T0:L1 LUN:1 state:active sas Adapter: 5001438027641890 Target: 1438027641890
HBA Commands
To List all HBAs available on the ESXi Host.
~ # esxcfg-scsidevs -a vmhba0 hpsa link-n/a sas.5001438027641890 (0:3:0.0) Hewlett-Packard Company Smart Array P220i vmhba1 qlnativefc link-up fc.50060b0000c26205:50060b0000c26204 (0:5:0.0) QLogic Corp ISP2532-based 8Gb Fibre Channel to PCI Express HBA vmhba2 qlnativefc link-n/a fc.50060b0000c26207:50060b0000c26206 (0:5:0.1) QLogic Corp ISP2532-based 8Gb Fibre Channel to PCI Express HBA vmhba32 iscsi_vmk online iscsi.vmhba32 iSCSI Software Adapter
HBA and LUN Mapping.
~ # esxcfg-scsidevs -A vmhba0 naa.600508b1001c0f0e831036c264b4203e
To Rescan a HBA
[code]esxcfg-rescan <HBANAME>[/code]
example
~ # esxcfg-rescan vmhba32 ~ #
iSCSI Commands
Discovery Stats for a iSCSI adapter
[code]~ # vmkiscsi-tool -D <HBANAME>[/code]
Example
~ # vmkiscsi-tool -D vmhba32 =========Discovery Properties for Adapter vmhba32=========
iSnsDiscoverySettable : 0 iSnsDiscoveryEnabled : 0 iSnsDiscoveryMethod : 0 iSnsHost.ipAddress : :: staticDiscoverySettable : 0 staticDiscoveryEnabled : 1 sendTargetsDiscoverySettable : 0 sendTargetsDiscoveryEnabled : 1 slpDiscoverySettable : 0 No Discovery Addresses Found No Static Discovery Targets Found
[code]~ # vmkiscsi-tool -E <HBANME>[/code]
Example
~ # vmkiscsi-tool -E vmhba32 No active targets.
ISCSI – IQN Name
[code]~ # vmkiscsi-tool -I HBANAME[/code]
Example
~ # vmkiscsi-tool -I vmhba32
iSCSI Node Name: iqn.1998-01.com.vmware:is-tse-h44-56726a3c
MTU Value
[code]~ # vmkiscsi-tool -M vmhba32[/code]
Example.
~ # vmkiscsi-tool -M vmhba32 MTU SETTABLE : Not Valid MTU Size : Not Valid
NFS Commands
To list all the mounted NFS datastores.
~ # esxcli storage nfs list
or
~ # esxcfg-nas -l
Add a NFS Datastore
~ # esxcli storage nfs add -H NFS_IP|NFS_HOSTNAME -s Share_mount_point_on_the_NFS -vDatastoreName
or
~ # esxcfg-nas -a -o NFS_IP -s Share_mount_point_on_the_NFSDatastoreName
Delete a NFS Datastore
esxcli storage nfs remove -v NFS_Datastore_Name
or
esxcfg-nas -d NFS_Datastore_Name
[/toggle]
[toggle title=”Networking”]Still Working on [/toggle]
[toggle title=”vSphere Replication”]
[code]vim-cmd hbrsvc/[/code]
[/toggle]
[toggle title=”Advanced & Misc “]Working on[/toggle]
Good knowledge.. Keep sharing it.
Good knowledge.. Keep sharing it.
Nice. It’s so help full. If it passble please send me the mail