How to list network adapters:
[root@mini:~] esxcli network nic list Name PCI Device Driver Admin Status Link Status Speed Duplex MAC Address MTU Description ------ ------------ ------ ------------ ----------- ----- ------ ----------------- ---- ----------- vmnic0 0000:01:00.0 ntg3 Up Up 1000 Full 68:5b:35:7f:07:8d 9000 Broadcom Corporation NetXtreme BCM57766 Gigabit Ethernet vmnic1 0000:09:00.0 ntg3 Up Up 1000 Full a8:20:66:06:e0:fa 1500 Broadcom Corporation NetXtreme BCM57762 Gigabit Ethernet
How to list routing table:
[root@mini:~] esxcli network ip route ipv4 list Network Netmask Gateway Interface Source ------------ --------------- ------------ --------- ------ default 0.0.0.0 192.168.10.1 vmk0 MANUAL 10.9.10.8 255.255.255.248 0.0.0.0 vmk1 MANUAL 192.168.10.0 255.255.254.0 0.0.0.0 vmk0 MANUAL 192.168.66.0 255.255.255.0 0.0.0.0 vmk2 MANUAL
How to list ip addresses:
[root@mini:~] esxcli network ip interface ipv4 get Name IPv4 Address IPv4 Netmask IPv4 Broadcast Address Type Gateway DHCP DNS ---- ------------- --------------- -------------- ------------ ------------ -------- vmk0 192.168.10.40 255.255.254.0 192.168.11.255 STATIC 192.168.10.1 false vmk1 10.9.10.9 255.255.255.248 10.9.10.15 STATIC 0.0.0.0 false vmk2 192.168.66.2 255.255.255.0 192.168.66.255 STATIC 0.0.0.0 false
How to list USB adapters (this way you can see also which one can be attached directly to a VM):
[root@mini:~] esxcli hardware usb passthrough device list Bus Dev VendorId ProductId Enabled Can Connect to VM Name --- --- -------- --------- ------- ------------------------- ---- 1 2 174c 1153 false no (passthrough disabled) ASMedia Technology Inc. ASM1153 SATA 3Gb/s bridge 1 3 bc2 331a false no (passthrough disabled) Seagate RSS LLC 1 4 b95 1790 false no (passthrough disabled) ASIX Electronics Corp. AX88179 Gigabit Ethernet 1 5 152d 578 false no (passthrough disabled) JMicron Technology Corp. / JMicron USA Technology Corp. JMS567 S 3 7 5ac 828a true yes Apple, Inc.
What to do if esxtop command is not shown properly:
This is because the default $TERM is xterm-color:
[root@mini:~] echo $TERM xterm-color
So, before running esxtop command, you need to change it to xterm:
[root@mini:~] TERM=xterm [root@mini:~] echo $TERM xterm
How to backup ESXi configuration
1. Execute the following command on ESXi host via ssh: vim-cmd hostsvc/firmware/backup_config
[root@mini:~] vim-cmd hostsvc/firmware/backup_config Bundle can be downloaded at : http://*/downloads/522994e1-a1b7-d1e4-e644-87eedbc5568e/configBundle-mini.local.tgz
2. Download the generated archive by accessing the url mentioned in the command output (replace * with the ip address of your ESXi host).
How to repair a vmdk disk
vmkfstools -x check /vmfs/volumes/my_datastore/my_disk.vmdk
How to check disk(s) statistics
This is not smart monitoring. The values shown on this command are since last boot. They will reset (start back from zero) after the next reboot.
[root@mini:~] esxcli storage core device stats get mpx.vmhba38:C0:T0:L0 Device: mpx.vmhba38:C0:T0:L0 Successful Commands: 8385853 Blocks Read: 231524531 Blocks Written: 889215864 Read Operations: 2133028 Write Operations: 6243300 Reserve Operations: 1879 Reservation Conflicts: 0 Failed Commands: 1626 Failed Blocks Read: 0 Failed Blocks Written: 0 Failed Read Operations: 0 Failed Write Operations: 0 Failed Reserve Operations: 0
How to check disks smart information
[root@mini:~] esxcli storage core device smart get -d mpx.vmhba38:C0:T0:L0 Parameter Value Threshold Worst Raw --------------------------------- ------- --------- ----- --- Health Status UNKNOWN N/A N/A N/A Read Error Count 100 62 100 0 Power-on Hours 47 0 47 243 Power Cycle Count 93 0 93 35 Reallocated Sector Count 100 5 100 30 Drive Temperature 166 0 166 33 Sector Reallocation Event Count 100 0 100 81 Pending Sector Reallocation Count 100 0 100 0 Uncorrectable Sector Count 100 0 100 0
Virtual disk conversion command
For example, converting Thick Disk to Thin Provisioned Disk is done as follows: vmkfstools -i thick.vmdk -d thin thin.vmdk
More conversion options are shown by running vmkfstools --help
How to present a real disk to VM with help of vmkfstools
To achieve this, you will use vmkfstools command to create a vmdk file that points to the real disk.
1. List the target real disk
[root@mini:/vmfs/volumes] ls -la /vmfs/devices/disks/ | grep mpx.vmhba33:C0:T0:L0 -rw------- 1 root root 4000787029504 Jan 21 17:11 mpx.vmhba33:C0:T0:L0 lrwxrwxrwx 1 root root 20 Jan 21 17:11 vml.01000000004e41414231534a4a457870616e73 -> mpx.vmhba33:C0:T0:L0
2. Run the command to link a vmdk file to the real disk:
[root@mini:/vmfs/volumes] vmkfstools -z "/vmfs/devices/disks/vml.01000000004e41414231534a4a457870616e73" /vmfs/volumes/main/REAL_DISKS/disk_1.vmdk [root@mini:/vmfs/volumes]
3. Two files will be created on your designated path, as with a virtual vmdk file, as shown below:
[root@mini:/vmfs/volumes] ls -la /vmfs/volumes/main/REAL_DISKS/ total 1152 drwxr-xr-x 1 root root 73728 Jan 21 17:11 . drwxr-xr-t 1 root root 73728 Jan 21 17:11 .. -rw------- 1 root root 4000787029504 Jan 21 17:11 disk_1-rdmp.vmdk -rw------- 1 root root 476 Jan 21 17:11 disk_1.vmdk
How to get ESXi version from command line with esxcli command:
[root@mini:~] esxcli system version get Product: VMware ESXi Version: 7.0.0 Build: Releasebuild-16324942 Update: 0 Patch: 25
How to suppress ssh shell enabled warning:
[root@mini:~] esxcli system settings advanced set -o /UserVars/SuppressShellWarning -i 1