ESX Useful commands

If you’ve enabled SSH, there are a series of useful commands you can run against the VMs on the host

I’ll keep this post updated with those I’ve found most useful


Gets a list of the VM ids for use in subsequent commands

vim-cmd vmsvc/getallvms

Get the snapshot info for a given VM ID (which you can obtain with the previous command)
vim-cmd vmsvc/snapshot.get <VM ID>

Remove all snapshots for a given VM ID.
vim-cmd vmsvc/snapshot.removeall <VM ID>

Create a snapshot for a given VM ID and information provided
vim-cmd vmsvc/snapshot.create [VmId] [snapshotName] 
[snapshotDescription] [includeMemory] [quiesced]

Edit cron file
vi /var/spool/cron/crontabs/root

Kill and Restart Cron
kill $(cat /var/run/crond.pid)
crond

ESX 6 (Free) VM Backup

If you have the need to backup VMs in ESX free edition, you’ll need to use a script of some sort on the server.

Fortunately (and no surprise) someone has already gone through the pain of implementing a fantastic and extremely thorough implementation which can be found here:

https://github.com/lamw/ghettoVCB/downloads

Once downloaded, you’ll need to copy/edit the conf file to configure (in particular the backup location!) then run as follows

ghettoVCB.sh -m <VMNAME> -g <PATH TO CONFIG>

This will then run an individual VM backup.  A list of VMs to backup is also an option.

Once you’ve got this running, you’ll want to schedule this in.  CRON runs on ESX free, but there’s no crontab command so you simply have to edit the cron file once you locate it – which is here:

/var/spool/cron/crontabs/root

After that, you’re all backed up 🙂

ESX Web UI

The following information is about how to add in the web ui to ESX server, in one of two ways, either installing it over the internet or downloading the VIB and installing on box.

This enables the webui in ESX which can be used in place of the vsphere client

Installing it over the Internet

  1. SSH into your ESXi host
  2. Run the command
    esxcli software vib install -v http://download3.vmware.com/software/vmw-tools/esxui/esxui_signed.vib

Installing it from a local file

  1. Download the VIB file
  2. SSH into your ESXi host
  3. Copy the VIB file to /tmp/
  4. Run the command
    esxcli software vib install -v /tmp/esxui_signed.vib

    Making sure you include the full path name to the file or else installation will fail
  5. If the VIB installation completes successfully, you should now be able to navigate a web browser to https:///ui and the login page should be displayed.

Intel NUC & VMware ESXi 6.0

So, recently I’ve decided to rationalise a lot of my computing equipment at home to reduce the footprint of what I use and the power consumption associated with all the equipment.

I’ve got a series of USB Hard Drives, Raspberry Pis (x2) and ACER Revo (Atom based) and a Core2Duo DELL machine all having their own use.  The raspberry pis, were a web/intranet server as well as an SSH access gateway, download device for large file downloads and a jenkins build server.  The revo was a windows 7, then 8, then 10 remote desktop client when being access remotely.  The core2duo machine is my development box where I build all the things I work on.  I reckon I have 5 x USB hard drives which I’ve also yet to detangle/clean up.

My Revo finally died, which prompted me to do something about all the equipment as I needed to replace it.

After lots of deliberation, I decided to go all out, on a reasonably low powered, but highly performant intel i7 NUC.

My shopping list was as follows:

  • Intel NUC5i7RYH Amazon Link
  • HyperX 16GB Low Voltage (1.35V) Ram (1600 MHz DDR3L CL9 SODIMM) Amazon Link
  • HyperX Predator 240GB M.2 SSD Amazon Link
  • I’d also got a 160GB SATA 2.5″ Drive going spare from the Revo

On arrival, it’s pretty painless to get into the barebones NUC to install the RAM/SSD, basically unscrew the four screws on the feet and pull off the panel.  Adding the RAM is easy.  The M.2 drive slightly more painful just as you have to screw it down and it’s a bit fiddly, but still painless.

And that was it – all ready to go.

OS of choice VMWare ESXi6 Open Source edition.
After downloading and registering/getting the key from vmware, it was put onto a USB drive to boot, which I used Rufus (https://rufus.akeo.ie/) to create.  Of course, this fails as VMWare is missing the Sata-xahci drivers/etc.

I followed the instructions here, replicated for posterity.

  1. Download and install vSphere PowerCLI 6.0 (Link) to use the Image Builder.
    This requires an account at vmware.com.
    If you are not entitled to download PowerCLI, register for an evaluation.
  2. Download required packages (Place both files in C:\esx)
    ESXi 6.0 Offline Bundle (VMware-ESXi-6.0.0-2494585-depot.zip) Link
    Sata-xahci Offline Bundle (Provided by v-front.de) Link
  3. Open VMware vSphere PowerCLI
  4. Enter the following commands:
    cd c:\esx\
    Add-EsxSoftwareDepot c:\esx\VMware-ESXi-6.0.0-2494585-depot.zip
    Add-EsxSoftwareDepot c:\esx\sata-xahci-1.28-1-offline_bundle.zip
    New-EsxImageProfile -CloneProfile "ESXi-6.0.0-2494585-standard" -name "ESXi-6.0.0-2494585-NUC" -Vendor "pembo.co.uk" -AcceptanceLevel "CommunitySupported"
    Add-EsxSoftwarePackage -ImageProfile "ESXi-6.0.0-2494585-NUC" -SoftwarePackage "sata-xahci"
    Export-ESXImageProfile -ImageProfile "ESXi-6.0.0-2494585-NUC" -ExportToISO -filepath ESXi-6.0.0-2494585-NUC.iso
    Export-ESXImageProfile -ImageProfile "ESXi-6.0.0-2494585-NUC" -ExportToBundle -filepath ESXi-6.0.0-2494585-NUC.zip
  5. Use the ISO/Zip created to install VMWare on the NUC, using rufus to create a bootable USB Drive.
  6. Install VMWare onto either the USB Drive you booted from, or in my case the 160GB SATA Drive
  7. At this point the M.2 drive does not show.  Of course, someone has had the issue before here, replicated again
  8. Adding the M.2 NVMe card.  No problem, we can fix that. First step is to determine the PCI ID:
    ~ # lspci -v | grep storage -A 1

    0000:00:1f.2 SATA controller Mass storage controller: Intel Corporation Wildcat Point-LP SATA Controller [AHCI Mode]
         Class 0106: <strong>8086:9c83</strong>
  9. The numbers we are looking for are where the example shows 8086:9c83. We have to add the value returned to the AHCI driver map (/etc/vmware/driver.map.d/ahci.map). Unfortunately we can’t edit this file while ESXi is running. The changes have to be made to the file that is loaded during ESXi startup (/bootbank/sata_ahc.v00). Convert the file with vmtar, extract it, change the driver map and rebuild it to /bootbank/. To do that…
  10. Enable SSH from the ESXi host screen
  11. SSH to the ESXi host
  12. Run the following commands:
    cd /tmp 
    mkdir ahci
    cd ahci
    vmtar -x /bootbank/sata_ahc.v00 -o sata_ahc.tar
    tar xvf sata_ahc.tar
    rm sata_ahc.tar
    echo "regtype=linux,bus=pci,id=8086:9c83 0000:0000,driver=ahci,class=storage" &gt;&gt; etc/vmware/driver.map.d/ahci.map
    tar cvf sata_ahc.tar etc usr
    vmtar -c sata_ahc.tar -o sata_ahc.vgz
    mv sata_ahc.vgz /bootbank/sata_ahc.v00

    Obviously substituting the 8086:9c83 with the value the previous command returned
  13. Reboot ESXi, and add the SSD storage

Next post in this series will be on my experiences/vms/usage/etc!

Thanks to virten.net and its contributors/authors for significant help in getting this going quickly!