Shutting down ESX guest from command-line/ssh


vmware_logo_square

This can be done through the Service console or through SSH.

The path to the configuration file will referred as . This get be obtained by using the command ” vmware-cmd -s listvms”

1) log into the esx server that the guest is located. (I use SSH personally)

2)Run the following command to get a list of the register guests config files on the esx server
vmware-cmd -s listvms

Output would look like:

[root@ESXHOST ~]# vmware-cmd -s listvms
/vmfs/volumes/4ba33211-381fb8d0-bc97-0010186458a2/GUSET1/GUEST1.vmx
/vmfs/volumes/4ba33211-381fb8d0-bc97-0010186458a2/GUSET2/GUSET2.vmx
/vmfs/volumes/4ba33211-381fb8d0-bc97-0010186458a2/GUSET3/GUSET3.vmx
/vmfs/volumes/4ba33211-381fb8d0-bc97-0010186458a2/GUSET4/GUSET4.vmx
/vmfs/volumes/4ba33211-381fb8d0-bc97-0010186458a2/GUSET5/GUSET5.vmx

3) Verify the state of the guest before attempting to shutdown.
vmware-cmd getstate

Output would look something like “getstate() = on” if the guest was on.

4) To perform a “soft” shutdown use the following:
vmware-cmd stop
To perform a “hard” shut down use:
vmware-cmd stop hard

If the virtual machine does not power off, it has likely lost control of its process. You need to manually kill the process.

Caution: The following is to be used only as a last resort option. This could cause issues with either the guest or even the host.

To determine if the virtual machine process is running on the ESX host, run the command:

# ps auxwww | grep -i .vmx

The output of this command appears similar to the following if the .vmx process is running:

[root@ESXHOST ~]# ps auxwww | grep -i GUEST1.vmx
root 16035 0.0 0.1 58648 728 pts/0 R+ 14:52 0:00 grep -i GUEST1.vmx
root 24502 0.0 0.2 3152 1228 ? S s May03 0:18 /usr/lib/vmware/bin/vmkload_app –sched.group=host/user /usr/lib/vmware/bin/vmware-vmx -ssched.group=host/user -# name=VMware ESX;version=4.0.0;buildnumber=208167;licensename=VMware ESX Server;licenseversion=4.0 build-208167; -@ pipe=/tmp/vmhsdaemon-0/vmx363998c9947311ce; /vmfs/volumes/4ba38321-381fb7d0-bc97-1010186458a2/GUEST1/GUEST1.vmx

The first output line can be ignored because this is the process info from the actual command ran.
The process ID (PID) that we are looking for in this example is 24502 (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 another virtual machine the one in question, you can cause downtime for the other virtual machine.

If the .vmx process is listed, it is possible that the virtual machine has lost control of the process and that it must be stopped manually.
1. To kill the process, run the command:
# kill
2. Wait 30 seconds and check for the process again.
3. If it is not terminated, run the command:
# kill -9
4. Wait 30 seconds and check for the process again.
5. If it is not terminated, the ESX host may need to be rebooted to clear the process.




You can leave a response, or trackback from your own site.


Further Reading
    None Found




Leave a Reply

Anti-Spam Quiz:

Twitter Delicious Facebook Digg Stumbleupon Favorites More
336 queries in 2.765 seconds.