ESXi Mastery

ESXi is the way of the future… it feels kind of funny dedicating a section on my blog to something that, in a few years time, will be kind of redundant because there will be nothing but ESXi.

But as it stands today, ESXi 4.0 is the current version of VMware’s next generation special forces hypervisor and is still playing second fiddle to it’s bigger, fatter brother – ESX 4.0.

This page is designed to be a resource dedicated to proving that you don’t need fat ESX nearly as much as you think you do. I plan on covering stuff that isn’t necessarily documented by VMware but can be figured out easily enough with a little digging under the hood – I’m not planning on putting anything here that would render ESXi “unsupportable”, because that wouldn’t have any value. In fact, it would actually lend support to fat ESX.

So without further ado, let’s jump in!

1. vim-cmd – your new best friend for edge scenarios
In fat ESX you have the vimsh command and vmware-cmd provides some similar functionality. In ESXi, we have vim-cmd. Using vim-cmd directly in the ESXi console in techsupport mode, you can do pretty much anything.

The best resource for vim-cmd is my buddy Wil Van Antwerpen‘s site, specifically his section on vimsh. Read up over there for anything that i don’t cover here.

List all VM’s registered on the host
Lets say you had a strange situation whereby the HA agent became dysfunctional and the host either crashed or was forcefully restarted. Because of the HA agent problem, the VM’s may not automatically restart when the host comes back up. If that host was running vCenter or the vCenter database, and you had root lockdown mode enabled like you should, then you will need to jump into techsupport mode in the ESXi console to figure out the VM Id’s that are registered on the host, so that you can power them on.

You could do this using vim-cmd “vmsvc/getallvms”, but if you’re looking at that through an out of band management interface, like HP’s iLO, the output will wrap and look kinda ugly. So you can pipe the output to awk to make it look a little easier:

[shell]vim-cmd "vmsvc/getallvms" | awk ‘/[0-9]/ {print $1" "$2" "$3"/"$4}'[/shell]

The return format of that is [VM Id] [VM Name] [Path to .vmx]. Shout outs to the resident *nix guru where I work for providing the awk touch – thx Tim :).

Check the power state of a VM
Following on from the example above, say you want to check the power state of a VM before attempting a power operation on it. That is easily done via:

[shell]vim-cmd "vmsvc/power.getstate" <VM Id>[/shell]

Where <VM Id> is the the number output in the first field from the vim-cmd “vmsvc/getallvms” command.

Power on a VM
So having determined a VM is in a powered off state, you can power it back on with:

[shell]vim-cmd "vmsvc/power.on" <VM Id>[/shell]

2. Killing VM’s
You’ll be happy to know that killing unresponsive VM’s is pretty much the same as fat ESX ala the vm-support command.

[shell]vm-support -X <World ID> –w <VM directory>[/shell]
Read VMware KB article 1014165 for more info on this and several other ways to do the necessary!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: