Skip to content

VMware - Primer

Why This Matters

VMware is the dominant enterprise virtualization platform. Most datacenters with more than a handful of servers run ESXi, managed through vCenter. If you work in ops, you will encounter VMware — whether you're provisioning VMs, troubleshooting performance, managing storage, or planning migrations. Understanding vSphere components and how they interact is essential for anyone operating production infrastructure.

Even as Kubernetes and cloud-native stacks grow, VMware remains the backbone of on-premise compute. Broadcom's acquisition shifted licensing to subscription-only, making cost optimization and migration planning critical skills.

Core Concepts

1. ESXi — The Hypervisor

ESXi is VMware's bare-metal (Type 1) hypervisor. It installs directly on server hardware and provides the compute virtualization layer.

Key facts: - Minimal footprint (~150MB on disk), runs from USB/SD or local disk - Custom Linux-derived kernel (VMkernel), not a full Linux OS - Direct Console User Interface (DCUI) for emergency host configuration - SSH disabled by default — enable only for troubleshooting

Essential CLI tools on the ESXi shell:

# List running VMs
esxcli vm process list

# Check host hardware
esxcli hardware platform get

# Network info
esxcli network nic list
esxcli network vswitch standard list

# Storage adapters and devices
esxcli storage core adapter list
esxcli storage core device list

# Manage services
esxcli system hostname get
/etc/init.d/hostd restart    # restart host agent
/etc/init.d/vpxa restart     # restart vCenter agent

The vim-cmd tool manages VMs directly:

# List all registered VMs
vim-cmd vmsvc/getallvms

# Power operations
vim-cmd vmsvc/power.on <vmid>
vim-cmd vmsvc/power.off <vmid>
vim-cmd vmsvc/power.shutdown <vmid>   # graceful via VMware Tools

# Snapshot operations
vim-cmd vmsvc/snapshot.create <vmid> "snap-name" "description"
vim-cmd vmsvc/snapshot.removeall <vmid>

2. vCenter Server — Centralized Management

vCenter is the management plane for ESXi hosts. It provides: - Inventory management: organize hosts into clusters, datacenters, folders - vMotion: live-migrate VMs between hosts - DRS (Distributed Resource Scheduler): automatic VM placement and balancing - HA (High Availability): restart VMs on surviving hosts after a failure - Permissions/roles: granular RBAC across the inventory - Templates and clones: standardized VM provisioning

vCenter runs as the vCenter Server Appliance (VCSA) — a Photon OS-based VM. Manage it via: - vSphere Client: web UI (HTML5) at https://<vcenter>/ui - PowerCLI: PowerShell module for automation - govc: open-source CLI alternative (Go-based) - REST API: /api/ endpoints for programmatic access

# PowerCLI: connect and list VMs
Connect-VIServer -Server vcenter.lab.local
Get-VM | Select-Object Name, PowerState, NumCpu, MemoryGB
Get-VMHost | Select-Object Name, ConnectionState, Version
# govc: list VMs
export GOVC_URL=https://vcenter.lab.local/sdk
export GOVC_USERNAME=administrator@vsphere.local
export GOVC_INSECURE=1
govc ls /datacenter/vm/
govc vm.info my-vm

3. vMotion — Live Migration

vMotion moves a running VM from one ESXi host to another with zero downtime.

How it works: 1. Pre-copy: memory pages streamed to destination host 2. Iterative copy: dirty pages re-sent until convergence 3. Stun: VM briefly paused (typically <1 second) 4. Switch: VM resumes on destination, ARP updated

Requirements: - Shared storage (or Storage vMotion for moving disk too) - Dedicated vMotion VMkernel port (separate VLAN recommended) - Compatible CPUs (EVC mode normalizes CPU feature sets across cluster) - vMotion network ≥ 10 Gbps recommended

# Check EVC mode on cluster
govc cluster.info /datacenter/host/cluster-01

# Migrate a VM
govc vm.migrate -host esx02.lab.local -pool /datacenter/host/cluster-01/Resources my-vm

4. Storage — VMFS, vSAN, and NFS

VMware supports multiple storage backends:

Storage Type Use Case
VMFS Block (FC/iSCSI) Traditional SAN, mature, well-understood
vSAN HCI (local disks) Hyper-converged, no external SAN needed
NFS File (NAS) Simple setup, good for templates/ISOs
vVols Policy-based Storage policy automation with array integration

VMFS is the default filesystem for VM disks on shared block storage: - VMFS 6 supports 64TB volumes - On-disk locking (ATS) prevents corruption with shared access - Thin provisioning at the datastore level

vSAN aggregates local disks across ESXi hosts into a distributed datastore: - Disk groups: 1 cache tier (SSD) + 1-7 capacity tier devices - Storage policies define redundancy (FTT=1 means tolerate 1 host failure) - Minimum 3 hosts for RAID-1, minimum 4 for RAID-5/6 (erasure coding)

# List datastores
esxcli storage filesystem list

# VMFS operations
esxcli storage vmfs extent list

# vSAN health check
esxcli vsan health cluster list

5. Networking — vSwitches and Distributed Switches

ESXi networking uses virtual switches:

Standard vSwitch (vSS): - Per-host configuration - Port groups define VLAN tagging and policies - Simple but doesn't scale (manual config per host)

Distributed vSwitch (vDS): - Centrally managed from vCenter - Consistent network policy across all hosts in the cluster - Supports NetFlow, port mirroring, LACP, Network I/O Control - Required for NSX

# List vSwitches on a host
esxcli network vswitch standard list
esxcli network vswitch dvs vmware list

# Check physical NIC status
esxcli network nic list
esxcli network nic stats get -n vmnic0

Key networking concepts: - VMkernel ports: management, vMotion, vSAN, NFS traffic (each on own VLAN) - VLAN trunking: physical NIC carries tagged traffic, port groups strip tags - NIC teaming: active/standby or LACP for redundancy - Jumbo frames: MTU 9000 for vSAN and NFS (must be end-to-end consistent)

6. HA and DRS — Availability and Load Balancing

vSphere HA: - Monitors host heartbeats via network and datastore - If a host fails, restarts its VMs on surviving hosts - Admission control reserves capacity (e.g., tolerate 1 host failure) - VM monitoring restarts VMs whose VMware Tools heartbeat stops

DRS (Distributed Resource Scheduler): - Recommends or automatically migrates VMs to balance CPU/memory load - Automation levels: Manual (recommendations only), Partially Automated, Fully Automated - Affinity/anti-affinity rules control VM placement (e.g., keep DB replicas on separate hosts)

# Check DRS recommendations
Get-DrsRecommendation -Cluster "Production"

# Set DRS rule — keep VMs apart
New-DrsRule -Cluster "Production" -Name "separate-db-replicas" `
  -KeepTogether $false -VM (Get-VM db-primary, db-replica)

7. VMware Tools and Guest Customization

VMware Tools is an agent installed inside the guest OS. It provides: - Graceful shutdown/restart from vCenter - Time synchronization with host - Memory ballooning (hypervisor reclaims guest memory) - Quiesced snapshots (application-consistent via VSS on Windows) - Copy/paste and drag/drop (desktop VMs)

open-vm-tools is the open-source version, packaged by most Linux distros:

# Install on Ubuntu/Debian
apt install open-vm-tools

# Install on RHEL/CentOS
yum install open-vm-tools

# Check status
vmware-toolbox-cmd stat speed
vmtoolsd --version

8. Templates, Clones, and Content Libraries

Standardize VM provisioning:

  • Template: VM converted to read-only image, deployed via "Deploy from Template"
  • Clone: full or linked copy of an existing VM
  • Content Library: centralized repository for templates, ISOs, OVAs across vCenters (published/subscribed model)
  • Guest Customization Spec: automate hostname, IP, domain join on first boot
# Deploy from template with customization
New-VM -Name "web-prod-03" -Template "ubuntu-22.04-base" `
  -VMHost "esx01" -Datastore "prod-ds01" `
  -OSCustomizationSpec "linux-static-ip"

9. Licensing and the Broadcom Shift

Post-Broadcom acquisition (2023): - Perpetual licenses eliminated — subscription-only - Free ESXi discontinued - Product SKUs consolidated into VMware Cloud Foundation (VCF) and vSphere Foundation (VSF) - Many customers evaluating alternatives (Proxmox, KVM/oVirt, Nutanix, cloud)

Understanding the licensing model matters for capacity planning and budgeting.

10. Automation and IaC

VMware infrastructure can be managed as code:

  • Terraform (vsphere provider): provision VMs, networks, storage
  • Ansible (community.vmware collection): configuration management
  • Packer (vsphere-iso builder): build VM templates from ISO
  • PowerCLI: PowerShell automation
  • govc: lightweight CLI for scripting
# Terraform: create a VM from template
resource "vsphere_virtual_machine" "web" {
  name             = "web-prod-01"
  resource_pool_id = data.vsphere_compute_cluster.cluster.resource_pool_id
  datastore_id     = data.vsphere_datastore.ds.id
  num_cpus         = 4
  memory           = 8192
  guest_id         = "ubuntu64Guest"

  clone {
    template_uuid = data.vsphere_virtual_machine.template.id
    customize {
      linux_options {
        host_name = "web-prod-01"
        domain    = "prod.example.com"
      }
      network_interface {
        ipv4_address = "10.0.1.10"
        ipv4_netmask = 24
      }
      ipv4_gateway = "10.0.1.1"
    }
  }
}

Quick Reference

Component Purpose CLI/Tool
ESXi Hypervisor esxcli, vim-cmd
vCenter Management plane vSphere Client, PowerCLI, govc
vMotion Live migration vCenter UI, govc, PowerCLI
VMFS Block storage filesystem esxcli storage
vSAN HCI storage esxcli vsan
vDS Distributed networking vCenter UI
HA Auto-restart on failure Cluster settings
DRS Auto-balance workloads Cluster settings
VMware Tools Guest agent open-vm-tools, vmtoolsd
Content Library Template distribution vCenter UI

Wiki Navigation

Prerequisites

  • VMware Flashcards (CLI) (flashcard_deck, L1) — VMware
  • Virtualization (Topic Pack, L2) — Virtualization
  • Virtualization Flashcards (CLI) (flashcard_deck, L1) — Virtualization