When your mind goes blank

For anyone who doesn’t subscribe to Duncan Epping’s great blog, he reminded me of this great command line snippet:

Enter maintenance mode from the ESX command line:
vimsh -n -e /hostsvc/maintenance_mode_enter

I have used this command several times in anger.  It is particularly useful if you can’t get to your VirtualCenter server for whatever reason.

There are some commands which are definitely worth learning.  Fortunately you can get by with just a small handful.

Sometimes people ask me why they would want to learn CLI commands, when the VI Client provides a nice GUI.  This topic is worthy of a long post of its own, but to cover some of the obvious ones:

  • Some people find it easier/quicker than the VI Client
  • Some functionality is still not available from VI Clien
  • CLI allows for scripting
  • Sometimes the VirtualCenter is not available (particularly if it is a VM itself)
  • If the VirtualCenter database server is offline, VirtualCenter itself can become unworkable
  • If the ESX hosts console networking gets screwed
  • You have physical access to ESX consoles but no way to get to a windows GUI

When things need fixed quickly, usually at some ungodly hour of the night, those CLI commands can be difficult to remember.  However, as long as you know a bit about the CLI, if you remember these simple things then you can do just about anything:

ls /usr/sbin
This lists out most commands that you would use.  Some of the command names aren’t that obvious e.g. vmkfstools.  This listing will often help you remember what you are looking for, or spark an idea when your mind has gone blank.

-h
Once you’ve figured out which command it was that you were looking for, then run it with the –h option.  For all VMware commands this will show a short listing of all the command’s options, switches and syntax; very similar to the /? from DOS.  You can use man command if you need a more detailed explanation, but –h usually does enough to spark some synapse.

-l (l for lima)
Often worth remembering, as this switch will usually list the current configuration set.

ls /var/log
These days, just about all the important log files are here (and its sub-directory).  With this command you can see which log files you might want to look at and run them with a simple tail command (or even grep).

/sbin/service –status-all
This command will produce a fair amount of information so you can pipe it to grep to look for running or stopped, or query the status of a single service.  However it can also provide some useful extras – for example it tells you what registered services have the local firewall ports opened for them.

history
Most commands I run, I have usually run before.  This is the ultimate reminder.

You see, very simple commands, but great starting points.  Unfortunately, now the basic VMware Install and Configure course doesn’t cover much (if any?) CLI stuff, it is often though of as a real black art.

It is always worth reminding people that even if the VirtualCenter server is unavailable, that you do have a couple of other options in an emergency:

  • You can connect the VI Client directly to host ESX servers.  A lot of less experienced people think of the VI Client as VirtualCenter.  However if VirtualCenter is unavailable then the VI Client can connect to hosts.
  • The VI web access.  You can connect to each host server via its web access on https://hostname/ui.  From Web Access you can do basic VM management.  Even VirtualCenter itself hosts its own Web Access portal https://VC_hostname/ui.

These two methods are often forgotten in a panic, but they have helped me countless times.

You don’t always need to remember how to do everything, just how to help yourself remember.

4 thoughts on “When your mind goes blank

  1. It seems the /hostsvc/maintenance_mode_enter command does not always work. I’ve found it does not work when there are active VMs on the particular ESX host. Lame.

    Have you seen different?

  2. Incredible you hit it on the spot I are going to bookmark on Twitter in addition to Facebook well done When your mind goes blank | vReference love it And also my prayers go out to anyone at atomic plant hopefully your are well along with secure 🙂 Peace Rob Rasner Comic

Leave a Reply to Josh Cancel reply