Change IP Address for VMware ESXI Host from Command Line

We can use the the built in esxcli command to change the IP address for a server

First we need to get the interface name. We can get the info with the following command.

esxcli network ip interface ipv4 get
Name  IPv4 Address   IPv4 Netmas   IPv4 Broadcast  Address Type  DHCP DNS 
----  ------------  -------------  --------------  ------------  -------- 
vmk0  192.168.0.4   255.255.255.0  192.168.0.0     STATIC           false

The text in bold is our interface name.

Set the interface to pull DHCP

The following command will set the interface to use DHCP. If your interface name is different, then you will want to change that.

esxcli network ip interface ipv4 set -i vmk0 -t dhcp

Set a static IP

We can set a static IP address with the following command. Change the IP and Subnet for the appropriate IP address and Subnet.

esxcli network ip interface ipv4 set -i -I IP -N Subnet vmk0 -t static

Changes take affect immediately so you’ll need to re ssh into the server.

http://virtuallystable.com/2019/08/14/how-to-change-the-ip-address-of-an-esxi-host-via-esx-cli/

VMware ESXI “Disk capacity is greater then the amount available in the datastore”

The following error appears to be some sort of bug in the Web Interface for VMware. Work around is to download the vSphere client and make the changes through there.
vsphereclient.vmware.com/vsphereclient/VMware-viclient-all-6.0.0.exe

“The disk capacity specified is greater than the amount available in the datastore. Disk space overcommitment can consume all space in the virtual disk and block the virtual machine. Increase the datastore capacity before proceeding or enter a smaller disk size.”

VMware esxtop, looking for CPU performance issues

http://www.yellow-bricks.com/esxtop/#esxtop-thresholds has some guidance on thresholds for different metrics.

Run esxtop, hit the “c” key to view CPU info and compare the usage with the thresholds.

Here are few from the above link.

Metric Threshold
%RDY 10
%CSTP 3
%MLMTD 0

Note: if your in esxtop you can hit the “f” key and it’ll give you a menu to specify more fields to display.

esxtop not displaying properly and is not interactive

Ran into an issue where esxtop was basically displaying a bunch of CSV data that was hard to make sense of in a terminal.

From reading here https://kb.vmware.com/s/article/2001448

It appears that the issue is that the environment TERM variable is not specified.

echo $TERM

returns nothing.

To fix, specify the terminal to use

TERM=xterm

To get a list of terminals available, run the following

find /usr/share/terminfo -type f

Install VMware tools on Ubuntu VM

In Ubuntu the simplest way to install the VMware tools is through apt.

sudo apt-get install open-vmware-tools

Shouldn’t have to do anything else.

You can also install the tools by hitting Install VMware tools from either the web UI, or vShpere.  This will mount a virtual CD on the OS, you can then copy the contents to a local directory in the vm.  You can then proceed to install them by extracting the tar file with

tar -xzf VMware*

cd into the new directory

cd vmware*

and run

sudo ./vmware-install.pl

Increase Disk Size of Linux VM in VMware

This is for extending a regular Ubuntu Linux partition, if you need to resize, expand a LVM partition refer to this guide.  I am using Gparted as I ran into some issues using parted for moving the partitions around.

Shut the VM down,

sudo shutdown -h now

It is a good idea to take a snapshot of the VM before resizing the disk, so if you run into an issue you have something to revert back to.  In the vSphere Client, right click on the VM -> Snapshot -> Take Snapshot.

Change VM Disk size by right clicking on the VM and going to Edit Settings

You can now boot up the VM.  Fire up GParted and it should show some unallocated space at the end of your drive.

Now in the next two images we are moving the Extended partition, which contains the Swap Partition to the end of the drive, so the unallocated space is adjacent to our root partition.

  1. Turn off the swap space by right clicking on the swap partition and hit Swapoff.
  2. Right click on the extended partition and extend to the the end of the Drive
  3. Right click on linux-swap and move to the end of drive.
  4. You should now have something similar to this

Hit Apply and write the changes to the disk then

  1. Right click on the extended partition and shrink to the end
  2. Right click on /dev/sda1 “Root partition” and extend to extended partition.

It should now look like this

Hit apply, then right click on the linux-swap and turn Swapon.

Enjoy the extra space.

Setup SNMPv3 on ESXI VMware server

SSH into the VMware server

ssh root@vmwareserver

Set the auth and priv types

esxcli system snmp set -a MD5 -x AES128

Generate hashes

The hashes are needed to create the user.  Replace authpass and privhash to the password you want.

esxcli system snmp hash --auth-hash authpass --priv-hash privhash --raw-secret

Create user 

Replace authhash and privhash with the auth and priv hashes returned from the above command.

esxcli system snmp set -e yes -C contact@incredigeek.com -u snmpuser/authhash/privhash/priv

 

Single line Command

Change authpassword and privpassword to your authentication and private passwords.

authpass="authpassword" && privpass="privpassword" && esxcli system snmp set -a MD5 -x AES128 && esxcli system snmp hash --auth-hash ${authpass} --priv-hash ${privpass} --raw-secret && esxcli system snmp set -e yes -C ${contact} -u snmpuser/${authhash}/${privhash}/priv

 

View SNMP Configuration

esxcli system snmp get