Knowledge Base

The VMware Knowledge Base provides support solutions, error messages and troubleshooting guides
 
Search the VMware Knowledge Base (KB)   View by Article ID
 

Powering off a virtual machine on an ESXi host (1014165)

Symptoms

You are experiencing these issues:
  • You cannot power off an ESXi hosted virtual machine.
  • A virtual machine is not responsive and cannot be stopped or killed.

Purpose

This article describes how to correctly stop virtual machines in an ESXi environment.

Note: This article applies to ESXi only and does not apply to ESX. For ESX hosts, see Powering off an unresponsive virtual machine on an ESX host (1004340).

Note: If you are attempting to troubleshoot the cause of an unresponsive virtual machine, it is usually preferable to collect performance metrics and then either suspend or crash the virtual machine to collect additional troubleshooting information. For more information, see Troubleshooting a virtual machine that has stopped responding: VMM and Guest CPU usage comparison (1017926) or Troubleshooting a virtual machine that has stopped responding (1007819).

Resolution

Warning: Follow the sections and steps in this article in order. Do not skip a section or step, as each step may have an impact on the virtual machine.

Powering off the virtual machine using the vSphere Client

Attempt to power off the virtual machine gracefully using the client:

  1. Connect the vSphere Client or VI Client to VMware vCenter Server or VirtualCenter Server.
  2. Right-click the virtual machine and click Power off. If the power operation fails with "Another task is already in progress", wait for the task to complete or see Powering off a virtual machine fails with the error: Cannot power Off: Another task is already in progress (1027040) or vCenter operation times out with the error: Operation failed since another task is in progress (1004790).
  3. If the virtual machine remains running, attempt the same operation from the host directly.
  4. Connect the vSphere Client or VI Client directly to the ESXi host running the virtual machine.
  5. Right-click on the virtual machine and select Power off.

If the virtual machine cannot be powered off gracefully using the client, use one of the command-line options.

Installing the vSphere Command-Line Interface tool

The vSphere Command-Line Interface (vCLI) is used for some of the procedures in this article. Ensure that it is installed before you proceed.

Note: The Remote Command-Line Interface can be accessed from the vSphere Management Assistant (vMA) for ESXi 4.x and ESX 5.x. If it is your preference to use this tool, see Installing vMA and Running Commands from vMA in the vSphere Command-Line Interface Installation and Reference Guide.

Determining the virtual machine's location

Determine the host on which the virtual machine is running. This information is available in the virtual machine's Summary tab in VI Client. Subsequent commands will be performed on, or remotely reference, the ESXi host where the virtual machine is running.

Using the ESXi 5.x esxcli command to power off a virtual machine

The esxcli command can be used locally or remotely to power off a virtual machine running on ESXi 5.x. For more information, see the esxcli vm Commands section of the vSphere Command-Line Interface Reference.

  1. Open a console session where the esxcli tool is available, either in the ESXi Shell, the vSphere Management Assistant (vMA), or the location where the vSphere Command-Line Interface (vCLI) is installed.

  2. Get a list of running virtual machines, identified by World ID, UUID, Display Name, and path to the .vmx configuration file, using this command:

    esxcli vm process list

  3. Power off one of the virtual machines from the list using this command:

    esxcli vm process kill --type=[soft,hard,force] --world-id=WorldNumber

    Notes:
    Three power-off methods are available. Soft is the most graceful, hard performs an immediate shutdown, and force should be used as a last resort.
    Alternate power off command syntax is: esxcli vm process kill -t [soft,hard,force] -w WorldNumber

  4. Repeat Step 2 and validate that the virtual machine is no longer running.

For ESXi 4.1:

  1. Get a list of running virtual machines, identified by World ID, UUID, Display Name, and path to the .vmx configuration file, using this command:

    esxcli vms vm list

  2. Power off one of the virtual machines from the list using this command:

    esxcli vms vm kill --type=[soft,hard,force] --world-id=WorldNumber

Using the ESXi command-line utility vim-cmd to power off the virtual machine

  1. On the ESXi console, enter Tech Support mode and log in as root. For more information, see Tech Support Mode for Emergency Support (1003677).
  2. Get a list of all registered virtual machines, identified by their VMID, Display Name, and path to the .vmx configuration file, using this command:

    vim-cmd vmsvc/getallvms

  3. To get the current state of a virtual machine:

    vim-cmd vmsvc/power.getstate VMID

  4. Shutdown the virtual machine using the VMID found in Step 2 and run:

    vim-cmd vmsvc/power.shutdown VMID

    Note: If the virtual machine fails to shut down, use this command:

    vim-cmd vmsvc/power.off VMID

Sending signals on ESXi to power off the virtual machine

A virtual machine can be halted from the command line by sending signals to the process.

Warning: This procedure is potentially hazardous to the ESXi host. If you do not identify the appropriate process ID (PID) and kill the wrong process, it may have unexpected results. If you are not comfortable with the following procedure, file a support request with VMware Technical Support and note this Knowledge Base article ID (1014165) in the problem description. For more information, see How to Submit a Support Request.

In ESXi 3.5-5.x, you can use the kill command to send a signal to, and terminate, a running virtual machine process.

  1. On the ESXi console, enter Tech Support mode and log in as root. For more information, see Tech Support Mode for Emergency Support (1003677).
  2. To determine if the virtual machine process is running on the ESXi host, run this command:

    ps | grep vmx

    The output appears similar to:

    7662 7662 vmx /bin/vmx
    7667 7662 vmx /bin/vmx
    7668 7662 mks:VirtualMachineName /bin/vmx
    7669 7662 vcpu-0:VirtualMachineName /bin/vmx


    Several rows are returned, one for each vmx process. Identify the parent vmx process for the target virtual machine. The first column contains the PID, and the second contains the parent's PID. Ensure you terminate only the parent process. The parent Process ID (PID) for each process is listed in the second column, identified in this example in bold. Take note of this number for use in the following steps.

    Caution: Ensure that you identify the line specific only to the virtual machine you are attempting to repair. If you continue this process for a virtual machine other than the one in question, you can cause downtime for the other virtual machine.

  3. If the vmx process is listed, terminate the process using this command:

    kill ProcessID

  4. Wait 30 seconds and repeat step 2 to check for the process again.
  5. If it is not terminated, run this command:

    kill -9 ProcessID

  6. Wait 30 seconds and check for the process again.

In ESXi 4.x/ESXi 5.x, you can use the k command in esxtop to send a signal to, and kill, a running virtual machine process.

  1. On the ESXi console, enter Tech Support mode and log in as root. For more information, see Tech Support Mode for Emergency Support (1003677).
  2. Run the esxtop utility using this command:

    esxtop

  3. Press c to switch to the CPU resource utilization screen.
  4. Press Shift+v to limit the view to virtual machines. This may make it easier to find the Leader World ID in step 7.
  5. Press f to display the list of fields.
  6. Press c to add the column for the Leader World ID.
  7. Identify the target virtual machine by its Name and Leader World ID (LWID).
  8. Press k.
  9. At the World to kill prompt, type in the Leader World ID from step 6 and press Enter.
  10. Wait 30 seconds and validate that the process is not longer listed.

Additional Information

If a virtual machine cannot be powered off using any of these methods, it usually indicates a problem with the underlying infrastructure, such as the ESXi host or its backing hardware.

If a problem is suspected with the ESXi host that is preventing the shutdown of virtual machines, vMotion all unaffected virtual machines off the host, and force the host to halt with a purple diagnostic screen. For more information, see Using hardware NMI facilities to troubleshoot unresponsive hosts (1014767).

Tags

power-off-vm

See Also

Update History

03/29/2012 - Added, If the virtual machine fails to power off, use the following command: 10/30/2012 - Added steps for ESXi 4.1 using esxcli 11/29/2012 - Added ESXi 5.1.x to Product Versions

Request a Product Feature

To request a new product feature or to provide feedback on a VMware product, please visit the Request a Product Feature page.

Feedback

  • 112 Ratings

Did this article help you?
This article resolved my issue.
This article did not resolve my issue.
This article helped but additional information was required to resolve my issue.
What can we do to improve this information? (4000 or fewer characters)
  • 112 Ratings
Actions
KB: