ESXi ホストで仮想マシンをパワーオフできない
search cancel

ESXi ホストで仮想マシンをパワーオフできない

book

Article ID: 327281

calendar_today

Updated On:

Products

VMware vSphere ESXi

Issue/Introduction

This article explains how to stop a virtual machine in an ESXi environment.

Note : When attempting to troubleshoot the cause of an unresponsive virtual machine, it is usually a good idea to collect performance metrics and then suspend or crash the virtual machine to gather additional troubleshooting information.

For more information, see:



Environment

VMware vSphere ESXi 6.5
VMware vSphere ESXi 7.0
VMware vSphere ESXi 6.7

Resolution

Solutions when unable to power off virtual machines on ESXi host:

Caution : Follow the sections and steps in this article in order. Do not skip a section or step as each step may impact your virtual machine.
  1. Powering off a virtual machine using the vSphere Client/vSphere Web Client
  2. Power off the virtual machine using the ESXi esxcli command
  3. Killing a Virtual Machine Using esxtop
  4. Powering off a virtual machine using the ESXi command line utility vim-cmd
Powering off a virtual machine using the vSphere Client/vSphere Web Client
Attempt to power off the virtual machine gracefully using the client.
  1. Connect the vSphere Client or vSphere Web Client to the VMware vCenter Server.
  2. Right-click the virtual machine and click Power Off . If the power operation fails with "Another task is already in progress" , wait until the task is 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 is still running, perform the same operation directly from the ESXi host.
  4. Connect the vSphere Client or VMware Host Client directly to the ESXi host on which the virtual machine is running.
  5. Right-click the virtual machine and select Power Off .
Note : Starting with vSphere 6.5, you can enable Virtual Machine Encryption to protect your virtual machine and its files.
If encryption is enabled on a virtual machine, a set of encryption privileges is required, otherwise the virtual machine cannot be powered off.
 
For more information about permissions, see the Prerequisites and Required Privileges for Encryption Tasks section in the ESXi and vCenter Server 6.5 Documentation .
 
If you are unable to successfully power off the virtual machine using the client, use one of the command line options:

The Power off virtual machine using ESXi esxcli command
esxcli can be used to locally or remotely power off virtual machines running on ESXi 5.x and later.
  1. Run the following command .vmxto get a list of running virtual machines, identified by their World ID, UUID, display name, and path to their configuration file:

    esxcli vm process list
  2. Power off the virtual machine from the list by running the following command: Note :

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

    • There are three power off methods: Soft is the safest power off method; Hard performs an immediate shutdown; Force should be used as a last resort.
  3. Repeat step 2 to ensure that the virtual machine is not running.
You can use the command Kill a Virtual Machine using esxtop to
esxtop sendk
  1. Enter ESXi console and log in as root. For more information, see https://knowledge.broadcom.com/external/article/311213
  2. esxtopRun the utility by executing the following command :

    esxtop
  3. Press C to switch to the CPU resource utilization screen.
  4. Press Shift+V to limit the view to the virtual machine, which makes 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 a column for Leader World ID.
  7. LWIDIdentify the target virtual machine by its name and leader world ID ( ).
  8. Press k.
  9. World to killAt the prompt, enter the Leader World ID from step 7 and press Enter.
  10. Wait 30 seconds and verify that the process is no longer listed.
Powering off a virtual machine using the ESXi command line utility vim-cmd
  1. Enter ESXi console and log in as root. For more information, see https://knowledge.broadcom.com/external/article/311213
  2. Run the following command .vmxto get a list of all registered virtual machines, identified by their VMID, display name, and path to their configuration file:

    vim-cmd vmsvc/getallvms
  3. Run the following command to get the current state of the virtual machine:

    vim-cmd vmsvc/power.getstate VMID
  4. Shutdown the virtual machine using the VMID obtained in step 2 and run the following command: Note : If the virtual machine fails to shut down, run the following command:

    vim-cmd vmsvc/power.shutdown VMID



    vim-cmd vmsvc/power.off VMID

Note : If the above steps do not resolve the issue and the ESXi host is responsive, it may be necessary to reboot and power off the virtual machines. You can avoid downtime by migrating all virtual machines using vMotion to another ESXi.

Additional Information

Send a signal to ESXi to power off the virtual machine

A virtual machine can be stopped from the command line by sending a signal to the process.

WARNING: This procedure can be dangerous for your ESXi host. Not identifying the correct process ID (PID) and killing the wrong process can lead to unexpected results. If the issue persists after performing these steps, file a support request with VMware Technical Support and note this Knowledge Base article ID (1014165) in the problem description. For more information, see https://knowledge.broadcom.com/external/article/142884


killYou can use a command to send a signal to a running virtual machine process to stop it.
  1. Enter Tech Support Mode on the ESXi console and log in as root. For more information, see https://knowledge.broadcom.com/external/article/311213
  2. Run the following command to determine if any virtual machine processes are running on the ESXi host:

    ps | grep vmx

    The output will look similar to the following: Several rows will be returned, one for each process. Identify the parent process of the target virtual machine. The first column contains the PID and the second column contains the parent PID. Make sure you end only the parent process. The parent process ID (PID) of each process is listed in the second column and is shown in bold in this example. Make a note of this number for the next step. Note : Make sure you identify the rows specific to only the virtual machine you are attempting to remediate. Continuing this process on virtual machines other than the one in question will cause downtime for the other virtual machines.

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


    vmxvmx

  3. vmxIf the process is listed, end it by running the following command:

    kill ProcessID
  4. Wait 30 seconds and repeat step 2 to check the process again.
  5. If the process is not terminated, run the following command:

    kill -9 ProcessID
  6. Wait 30 seconds and check the process again.

If you are unable to power off the virtual machine using any of these methods, there is typically an issue with the underlying infrastructure, such as the ESXi host or backing hardware.

If you suspect that an issue with the ESXi host is preventing the virtual machines from shutting down, vMotion all unaffected virtual machines off the host and kill the host with a purple diagnostic screen. For more information, see Using hardware NMI facilities to troubleshoot unresponsive hosts (1014767)

. For more information, see: