We have several customers on sketchy hardware and on occasion the VM crash due to a SCSI card issue with the mother board used, that aside we have from time to time a need to force a hard reboot of the server running in a VM. Some times it works great and sometimes we have a lockup at 95% and have to force a kill of process that runs the VM to get it to restart.
So here is the process we take to get this to free up and reboot the VM on ESXi 5.0 and later VMware hosts.
- Make sure if you do not already have it turned on, to turn on SSH on the ESXi Host. This can be done via the [Configuration -> [Security Profile] using the VMware client.
- Using your favorite SSH Client (Putty), connect to your VMWare ESXi 5 Host.
- We now need to get and kill the process group for the VM that has failed. To do this we will look for the process group ID using this command.
execute -> ps -g|grep “VMName”You should get a return that looks similar to this.3372 vmm0:MyVMSystem
3374 3368 vmx-vthread-4:MyVMSystem 3368 3368 /bin/vmx
3375 3368 vmx-mks:MyVMSystem 3368 3368 /bin/vmx
3376 3368 vmx-vcpu-0:MyVMSystem 3368 3368 /bin/vmxWe are looking for the common number across all processes and in this case that would be “3368” as seen near the end of each line.
- Now will need to kill the process. To do this we need to execute -> kill -9 3368 Replace “3368” with the ID number of your system.
- Now we need to do some clean up, We need to delete the swap file in the directory where the VM is stored. To get to where we store the swap file you will need to do the following.execute ->cd /vmfs/volumes/<YourDataStore>/<VMName>
Next we need to make sure what our swap file name is so execute -> ls
This will give you a directory listing find your swap file by looking for the file extension “.vswp”. Now we will remove it with this command.
execute -> rm –r <YourSwapFile.vswp>
- Now lets restart our VM services, This will not affect any running VM and is safe to run while VMs are active on host.execute -> /sbin/services.sh restart
- Reconnect your VMware client to the host and complete the process to power on the VM by first removing the VM from the inventory (Do not Delete from Disk) and re-adding it back in. This will reset the VM fully and allow you to restart it. After you remove your VM from inventory you can re-add it by browsing the datastore in your VMWare client finding your VM directory and right clicking on the “.vmx” file. A menu will pop up and you can click “Add to Inventory” which will place VM back into the available VMs list. Now select the VM and click the Boot up arrow button to get started again.
Enjoy,
Cubert 😎