Managing ESXi 5 VM from the command line

I only have one physical machine and my vSphere client is installed on a Windows XP virtual machine. If, for some reason, that VM is not usable, I need a way to manage my VM from the ESXi. Here’s a few reminders on commands to use to manage VM from the VMware ESXi v5 command line.

Every command is used from the ESXi itself, via a remote SSH connexion. Those could also be run from a distant machine where the vSphere Command-Line Interface (vCLI) has been installed.

List the actual running machines:

# esxcli vm process list | grep "^[^ ]"

List the registered virtual machines:

# vim-cmd vmsvc/getallvms Vmid Name File Guest OS Version Annotation (...) 11 vCenter (win2k8) [SATA_local] Win2K8/Win2K8.vmx windows7Server64Guest vmx-08 31 OpenBSD [SATA_local] OpenBSD/OpenBSD.vmx otherGuest vmx-08 (...)

Get the state of a particular machine, using its VMid:

# vim-cmd vmsvc/power.getstate ## Retrieved runtime info Powered on

Shutdown the virtual machine “nicely”, using its VMid:

# vim-cmd vmsvc/power.shutdown ##

Power the machine off, using its VMid:

# vim-cmd vmsvc/ ##

Start the virtual machine, using its VMid:

# vim-cmd vmsvc/power.on ##

If the CLI commands don’t work, one can stop a VM using the default system tools:

# ps | grep vmx-mks 3542 3538 vmx-mks:WinXP /bin/vmx 3959 3953 vmx-mks:Windows 7 x64 /bin/vmx 3969 3964 vmx-mks:Ubuntu /bin/vmx 3978 3973 vmx-mks:vCenter (win2k8) /bin/vmx 3986 3981 vmx-mks:OpenBSD /bin/vmx # kill ## (use the second column from the `ps` command)

Source: Powering off a virtual machine on an ESXi host

Author: Joel Carnat

@work Technical Architect and SysAdmin ; @home OpenBSD and FOSS, Karate, Kobudō, Jōdō, Bodyweight workout, Photography & Music

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.