In system administration, there are certainly times when you need an identical copy of a server for testing, development, or simply to revert to a safe state before making major changes. When I was new to the field, I used to spend hours reinstalling the operating system and configuring software identically to an existing server just to create a dev or test environment. This was both time-consuming and prone to errors.
I remember one time, my boss tasked me with upgrading a critical application on a production server. I was quite worried because a single wrong operation could impact all users. At that moment, I wished there was a way to “freeze” the server’s state, so if anything went wrong, I could instantly revert. Or, when needing to deploy dozens of virtual machines with similar configurations for a new project, manually setting up each one felt like torture.
In my experience managing a VMware cluster with 8 ESXi hosts at my company, such situations were frequent. Fortunately, VMware provides two extremely powerful tools to thoroughly address these issues: Snapshot and Clone VM. These insights are drawn from real-world operations of my company’s 8-host ESXi cluster. I believe they will be very helpful to you, especially those new to virtualization.
Real-World Problem: Why is VM Creation and Management Complex?
Virtual machines (VMs) are now the backbone of most modern IT infrastructures. However, creating a new VM from scratch or manually duplicating it always carries many potential problems. If you simply copy the VMDK file (the VM’s disk file) and power it on, configuration conflicts can easily occur.
This is especially true for operating systems like Windows, where SIDs (Security Identifiers) can be duplicated. Furthermore, this process is time-consuming, involving reinstalling the operating system, patches, drivers, and basic applications. Imagine having to do this 5, 10, or even 50 times – that’s truly a nightmare.
Similarly, when needing to test a software update, a firewall configuration change, or a security patch, you always face the risk of damaging a running server. How do you revert to the old state? Manual backup and restoration can take half a day, or even a full day, and is not always 100% successful.
Root Cause Analysis: The Nature of Complexity
The main reason is that a virtual machine is not just a collection of files on a hard drive. It also encompasses memory state, virtual hardware configuration, and active network connections. When you manually copy files, you are only copying a part of the complete “picture.”
The operating system and applications within a VM are deeply “embedded” with identifiers (IDs) and hardware configurations they recognize. Simple copying will result in two VMs having the same identifier. This causes conflicts when they operate together within a network, especially with services dependent on SIDs like Active Directory.
For reverting to a previous state, simply backing up the VMDK file is insufficient. It doesn’t capture the state of RAM memory, CPU, or running processes. Therefore, if an issue occurs, restoring from a file backup only brings you back to a specific point on the disk. It does not restore the complete “live” state of the virtual machine at the time of backup.
Effective Solutions in VMware
To address the above issues, VMware provides two core features: Snapshot and Clone. I will delve into each feature to show you their power.
1. Snapshot (Capturing VM State)
Imagine a Snapshot as “capturing” the entire state of a virtual machine at a specific point in time. It not only saves data on the disk but also the memory (RAM) state, the state of connected virtual devices, and the VM’s configuration settings. When needed, you can revert to that exact captured moment in just a few seconds.
When to Use Snapshots?
- Before significant system changes: Installing patches, upgrading software, changing network configurations, modifying the registry… If errors occur, you can revert immediately.
- Testing software or applications: Create a “clean” test environment, install new applications, check compatibility. After testing, you can delete the snapshot or revert.
- Creating temporary development environments: Developers need an environment to code and test independently.
- Training or demos: Revert a VM to its initial state after each session or demo to prepare for the next.
How to Create and Manage Snapshots
I typically use vSphere Client (Web client) to manage ESXi hosts. The steps to create a snapshot are very simple:
- Select the virtual machine for which you want to create a snapshot.
- Right-click on the VM, choose
Snapshots>Take Snapshot...(or from theActionsmenu >Snapshots>Take Snapshot). - Enter a name for the snapshot (e.g., “Before_App_Upgrade_20240326”), a detailed description, and select the options:
Snapshot the virtual machine's memory: Very important! Select this to save the RAM state, allowing the VM to revert to its exact running state. If not selected, the VM will need to restart when reverted.Quiesce guest file system (requires VMware Tools installed): Ensures data on the disk is synchronized and consistent before the snapshot is taken. Highly recommended for VMs running databases or applications with continuous data read/write. Requires VMware Tools to be installed.- Click
OK. This process usually completes very quickly.
To revert to a snapshot:
- Right-click on the VM, select
Snapshots>Revert to Latest Snapshot. - Or go to
Snapshot Manager(orManage Snapshots) to select a specific snapshot to revert.
Important Notes:
- Do Not Use Snapshots as Backups: A snapshot is not a complete backup. It is merely a “delta” file storing changes relative to the original disk. If the original disk is corrupted, the snapshots will also be meaningless. Therefore, always have a separate backup solution.
- Performance: Multiple snapshots or leaving snapshots for too long will significantly impact VM performance. Every time data is written to the VM, VMware must write to the latest delta file of the snapshot, increasing I/O latency.
- Storage Capacity: Snapshot files can quickly consume disk space. The more changes made to the VM, the larger the snapshot file becomes.
To manage snapshots on ESXi using commands, you can use vim-cmd via SSH:
# List all VMs on the host
vim-cmd vmsvc/getallvms
# Find your VMID, for example: 123
# Then, list snapshots for VMID 123
vim-cmd vmsvc/snapshot.get 123
# Create a snapshot for VMID 123 with the name "MySnapshot" and description "Before upgrade"
# 1 is snapshot memory, 1 is quiesce guest file system
vim-cmd vmsvc/snapshot.create 123 "MySnapshot" "Before upgrade" 1 1
# Revert to a snapshot (will ask for snapshot ID, obtained from get)
# Example: snapshot ID is 456
vim-cmd vmsvc/snapshot.revert 123 456
# Delete a specific snapshot
vim-cmd vmsvc/snapshot.remove 123 456
# Delete all snapshots for a VM
vim-cmd vmsvc/snapshot.removeall 123
2. Clone (Duplicating Virtual Machines)
Cloning is the process of creating a complete, independent copy of an existing virtual machine. After cloning, you will have two separate virtual machines that are no longer dependent on each other. Each VM will have its own configuration files and disks.
When to Use Clone?
- Rapid deployment of multiple VMs: You have a “golden image” (a virtual machine with basic applications pre-installed and configured), then clone it repeatedly to create web servers, databases, or client machines for users.
- Creating independent development/testing environments: When an exact copy of production is needed but completely separate for testing major changes, or for different teams to work on independent copies.
- Creating VM templates: After configuring a standard virtual machine, clone it and convert it into a template for easy deployment of new VMs later on.
- VM migration: Cloning can be used to move VMs between different datastores or hosts (in cases where vMotion or svMotion are not available).
How to Create and Manage Clones
Similar to Snapshots, I often perform Clones via vSphere Client (Web client):
- Right-click on the source VM, select
Clone>Clone to Virtual Machine.... - Follow the instructions:
- Select a name and folder: Give the new VM a name (it’s important that it’s different from the original VM’s name) and choose a storage folder in vCenter.
- Select a compute resource: Choose the ESXi Host or cluster where you want the new VM to run.
- Select storage: Choose the datastore to store the new VM’s files.
- Select clone options:
Customize the operating system: Extremely important for Windows VMs! Helps you change the hostname and create a new SID to avoid conflicts. For Linux, you can use cloud-init or a script for customization afterward.Customize this virtual machine's hardware: If you want to change the number of CPU, RAM, or disks of the new VM compared to the original VM.Power on virtual machine after creation: Option to power on the VM immediately after creation.- Click
Finish. This process will take some time, depending on the VM’s size and the storage system’s performance.
Things to do after Cloning:
- Change IP Address: If the original VM has a static IP, the new VM will have a duplicate IP. It needs to be changed immediately after cloning.
- Change Hostname: Assign a new name to the VM for easier management.
- Generate a New SID (for Windows only): If you don’t select
Customize the operating system, run Windows’ Sysprep tool to generate a new SID, avoiding issues with Active Directory or applications dependent on computer identity. - Remove old agents (if any): Some monitoring or backup agents may need to be reconfigured or reinstalled on the new VM.
For cloning using commands, on ESXi directly, it will be a bit more complex as it usually requires PowerCLI (on Windows) or vCenter API. However, if you only have an ESXi host, you can perform it manually by creating copies of the VMDK and .vmx files, then registering the new VM. This method is not recommended for beginners due to its error-prone nature. In a vCenter environment, PowerCLI is a powerful tool for automating this:
# Connect to vCenter Server or ESXi Host
Connect-VIServer -Server your_vcenter_or_esxi_ip
# Get original VM information
$vmSource = Get-VM -Name "OriginalVMName"
# Create a new clone
New-VM -Name "NewClonedVM" -VM $vmSource -VMHost (Get-VMHost "your_esxi_host_name") -Datastore (Get-Datastore "your_datastore_name") -OSCustomizationSpec (Get-OSCustomizationSpec "Your_Customization_Spec_Name")
# The above PowerCLI command will require a Customization Specification to change hostname, SID.
# You need to create the Customization Spec in vCenter beforehand.
Note that PowerCLI requires installation on a Windows machine with access to vCenter/ESXi. With vim-cmd on ESXi, basic cloning is merely a manual file copying operation, without the automated customization process offered by vCenter.
Best Practice: When to Use Snapshot, When to Use Clone?
By now, you have a clear understanding of the differences and uses of Snapshot and Clone. Choosing the right tool will help you save time, reduce risks, and manage your infrastructure more effectively:
- Use Snapshots for SHORT-TERM and REVERSIBLE changes: Think of a Snapshot as a way to “pause” the current state, try something new, and easily revert after a short period (a few hours to a few days). Examples include operating system upgrades, new application installations, or network configuration changes. Remember, snapshots are not backups and will impact performance if left for too long.
- Use Clones for CREATING INDEPENDENT COPIES and NEW DEPLOYMENTS: When you need a completely new virtual machine, independent of the original, use Clone. The purpose could be expanding infrastructure, creating separate dev/test environments, or making a “golden image” for duplication.
An effective strategy I often apply is: Create a “standard” virtual machine (golden image), pre-install essential software, and configure basic settings. Then, use the Clone feature to create new virtual machines from this “golden image” for various purposes. On each new cloned VM, before making significant changes, I Snapshot it to ensure safety. After the changes are successful, I delete that snapshot to avoid performance impact.
These insights are all derived from real-world operations and management of a VMware cluster with 8 ESXi hosts at my company. Mastering and proficiently using Snapshot and Clone has not only helped me and my team work more efficiently but also enhanced the stability and security of the entire system. I hope this article provides you with a clear overview and practical guidance that you can immediately apply to your work. Wishing you success!

