In this two part series I will summarize some useful Esxi commands that we use time to time. We can run any of these commands from local
or remote console.
To list the software and drivers currently installed on the ESXi host:
#esxcli software vib list
To run any of these cmd, first connect to host over ssh using putty (I believe ssh is already enabled on host), once connected to host then, you can run the given command to complete the respective task:
#/etc/init.d/hostd restart
#/etc/init.d/vpxa restart
or
To restart all agents at once
#Services.sh
Note: this cmd restart all agents so could take a long time
to complete that is why its preferable to restart individual agent
To Power off / Reboot an unresponsive VM:
Now, to see the power state of VM,
#vim-cmd vmsvc/power.getstate VMID
To shutdown the VM,
#vim-cmd vmsvc/shutdown VMID
If the above doesn't work then, use fowwing command to power off the VM,
#vim-cmd vmsvc/poweroff VMID
#esxcli vm process list
To power off a VM : There are three power-off methods available with esxcli. Soft is the most graceful, hard performs an immediate shutdown, and force should be used as a last resort.
#esxcli vm process kill -t [ soft,hard,force] -w WorldNumber
To Power off / Reboot an unresponsive VM:
Now, to see the power state of VM,
#vim-cmd vmsvc/power.getstate VMID
To shutdown the VM,
#vim-cmd vmsvc/shutdown VMID
If the above doesn't work then, use fowwing command to power off the VM,
#vim-cmd vmsvc/poweroff VMID
#esxcli vm process list
To power off a VM : There are three power-off methods available with esxcli. Soft is the most graceful, hard performs an immediate shutdown, and force should be used as a last resort.
#esxcli vm process kill -t [ soft,hard,force] -w WorldNumber
Reload a vmx file without removing the virtual machine from inventory: First get to VMID as described above, then
#vim-cmd vmsvc/reload VMID
To get a list of running tasks on the host,
#vim-cmd vmsvc/task_list
To get a list of tasks associated with a specific VM,
To get a list of tasks associated with a specific VM,
#vim-cmd vmsvc/get.tasklist VMID
To get information about the status of a particular task, run the command
#vim-cmd vimsvc/task_info task_identifier
We can also use ps command to find VM related running processes.
#ps |grep VM_name this command will give you process id and if you want to kill the process, then
#kill process_id wait for some time, if process is still there then use
#kill -9 process_id
To ping Any host/VM etc:
#vmkping ip_or_hostname
To get information about the status of a particular task, run the command
#vim-cmd vimsvc/task_info task_identifier
We can also use ps command to find VM related running processes.
#ps |grep VM_name this command will give you process id and if you want to kill the process, then
#kill process_id wait for some time, if process is still there then use
#kill -9 process_id
To ping Any host/VM etc:
#vmkping ip_or_hostname
To enter maintenance mode using the command line interface
vimsh -n -e /hostsvc/maintenance_mode_enter or
vim-cmd /hostsvc/maintenance_mode_enter or esxcli system maintenanceMode
set --enable true
To check if host is in maintenance mode
#vim-cmd /hostsvc/hostsummary | grep inMaintenanceMode or
vimsh -n -e /hostsvc/hostsummary | grep inMaintenanceMode or
esxcli system maintenanceMode get
vimsh -n -e /hostsvc/hostsummary | grep inMaintenanceMode or
esxcli system maintenanceMode get
To exit maintenance mode
#vimsh -n -e /hostsvc/maintenance_mode_exit or
vim-cmd /hostsvc/maintenance_mode_exit or
esxcli system maintenanceMode set --enable false
To install an update or any third party vib file stored in any datastore:
#esxcli software vib install -d /vmfs/volumes/..../downloaded.vib or downloaded_vib_bundle.zip
vim-cmd /hostsvc/maintenance_mode_exit or
esxcli system maintenanceMode set --enable false
To install an update or any third party vib file stored in any datastore:
#esxcli software vib install -d /vmfs/volumes/..../downloaded.vib or downloaded_vib_bundle.zip
To list the software and drivers currently installed on the ESXi host:
#esxcli software vib list
To avoid slow host boot,
#esxcli storage core device setconfig -d naa.id
--perennially-reserved=true
#To verify that the device is perennially reserved, run this
command:
#esxcli storage core device list -d naa.id
To check the status of the USB arbitrator, run the following
command:
#chkconfig --list | grep -i usb
And if you want to start the usbarbitrator service, replace
the Off with on
#chkconfig usbarbitrator off
Note: For ESXi 5.1 and 5.5, a restart is not required.
Restarting the management agents on the system will allow for accessing the
devices
To check the status of physical NIC connectivity, run this
command:
# esxcfg-nics –l
To check installed Esxi version :
#esxcli system version get
or
#vmware -vl
I will add more command to this list in future
That's it... :)
To check installed Esxi version :
#esxcli system version get
or
#vmware -vl
I will add more command to this list in future
That's it... :)
Another good work by Noor, I will be waiting for your next commands post.
ReplyDeleteAre these 5.5 or 6.0 specific.or both.
ReplyDeletethese commands will work on both...
DeleteGreat share Noor, keep sharing.
ReplyDeletegood and looking ahead for other commands..
ReplyDeleteThanks buddy
ReplyDeleteThanks Man
ReplyDeletewonder full explanation.i ever seen this kind of simple understanding.thanks a lot..keep posted scenario based questions...have a bright future
ReplyDeleteThanks....
Delete