Manage Learn to apply best practices and optimize your operations.

ESXi Shell brings hidden vSphere management capabilities to light

Not all management tasks in a vSphere environment are handled from the vSphere client. Some require commands executed from ESXi Shell.

While most management tasks in a vSphere environment are easily performed from the vSphere client, some situations require direct access to your ESXi host. With the ESXi Shell, an administrator has access to a special set of commands for advanced troubleshooting and maintenance procedures.

Using the ESXi Shell

Administrators should not use the ESXi Shell as the default vSphere management tool in a production environment. Access to the shell is disabled by default.

To turn on access to the ESXi command-line interface (CLI), open the console of your ESXi host and select Troubleshooting Options>Enable ESXi Shell. You can also select Enable SSH from the Troubleshooting Options menu to make remote access over SSH possible. After selecting either one of these methods, you will see an interface similar to a Linux shell, where you can type in commands to manage parts of your ESXi environment.

Once in the ESXi Shell CLI, you can use two different kinds of commands -- VMware commands and Linux commands. One of the most important VMware commands is esxcli which works directly on the ESXi layer and allows you to perform maintenance tasks like storage, network, system and software management and more. The Linux commands work on the Linux layer of the hypervisor. These commands are good for scripting or interacting with the Linux portions of the ESXi kernel. Most of these commands are common utilities such as more, cp and cat, which are useful if you are used to working with them in a Linux environment.

Monitor log files

One useful task you can execute from ESXi Shell is monitoring log files directly. To do this, keep an eye on the files in the /var/log directory. Standard Linux utilities, like tail, can trace log information while it's being processed and where more can read the contents of a log file. If, for instance, you want to see a trace of messages being written to the hostd.log or the syslog.log files in the /var/log directory, you can do that from ESXi Shell using tail -f /var/log/hostd.log.

Close the trace with Ctrl-C.

Manage storage devices

There are many tasks that you can accomplish using esxcli. You could attach and detach storage devices from the vCenter Server with the vSphere client, but if that doesn't work out well, the ESXi Shell has commands that work directly on the attached storage devices. Some commands have handy uses, such as detaching a storage device permanently without the device being automatically connected again. This is useful if you're performing maintenance on the device.

By detaching a storage device you will make the device unavailable. Before doing this, unmount any data stores that are using the device. You can do this with

esxcli storage filesystem volume unmount

followed by

either --volume-label=<label>



Use esxcli storage filesystem list to display a list of all file systems that are currently mounted.

The command esxcli storage core device list gives a list of storage devices attached to this host. Look for the name of the storage device you want to detach, then use esxcli storage core device set -da --state=off as in the following command that detaches the optical drive: esxcli storage core device set -d mpx.vmhba32:C0:T0:L0 --state=off.

Once you've completed the maintenance, you can attach the device again using the same command as before, but with the option --state=on. Don't forget to bring the file system back in a mounted state also, using esxcli storage filesystem mount.

Dig Deeper on VMware and networking

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.