Why do we need these command-line? I found the vSphere client, esp. when you connect your vCenter, sometimes cannot reflect the real state of your virtual machines i.e. you see virtual machine is powered-on in vSphere client but the virtual machine is actually turned-off. When you try to shutdown it in vSphere client, error come out. In this case, command-line can save you from hell.
OK. Before you take any operation on a VM, you have to know its VM id (a uniqued ID generated when it is added or created in ESXi).
Logon your ESXi by SSH or at server console,
Type:
You will get the VM id in column of "vmid" (32 in this example). This id will not be changed unles you remove it from ESXi. Please rememeber this as all operation is based on this VM id.
Now, you would like to know the power status of VM, type the following to get the power status:
You will know this VM is powered-off
If you want to power on this VM, type the following:
To confirm it is running, you can use esxtop command. You will see something like:
"Ubuntu" is the VM we tried to power it on. "esxtop" command shows ESXi running processes. Press "q" to quit esxtop
Suppose you find your guest OS like Windows hangs, you want to reset the VM, type the following:
vim-cmd vmsvc/power.reset will reset your VM (like press Reset button on your PC)
If you would like to shutdown your VM normally, type following:
If you have not installed VMware tools in your guest OS, you get error like following:
Install VMware tools before you can shutdown VM normally (i.e. like press "shutdown" in Windows start menu)
Finally, if you would like to cold shutdown (like press power button and hold 4 -5sec), type the following:
your VM will disappear in esxtop command result.
OK, in summary, you know how to power on/Off, reset, shutdown a VM by command-line. I hope these will make your daily life easier.
No comments:
Post a Comment