Encapsulation is one of the four key benefits of VMware virtual machines. On the surface it may seem like this is a common feature across all virtualization platforms — but it’s not.
If you are a VMware ESX administrator, you know that a VMware virtual machine consists of several files, normally contained in a single directory. There is a configuration file, virtual disk files, and a few other supporting files. Having all necessary VM files in one directory is the essence of encapsulation.
Let’s say that you have a development environment — not protected by VMware HA — that experiences a host failure. You repair the host, reinstall ESX, and reattach the disk that contains your virtual machines. In order to have ESX recognize a VM, it must be registered. This is easily done with the Datastore Browser, just right-click on the .vmx file and select “Add to Inventory.”
This task can also be performed on the ESX service console (i.e., not ESXi) by using the vmware-cmd utility. Here is an easy technique, just cd into the VM directory first:
vmware-cmd -s register $PWD/whatever.vmx
After that you are ready to power on your VMs and get back to work — snapshots and all.
Recovering Hyper-V VMs
Unfortunately, with Hyper-V you need to be more proactive — unless a VM is explicitly “exported” it cannot be “imported.” There is no supported method of importing a VM from a failed host, especially if it has snapshots. Or is that checkpoints?
Don’t believe me?
For the curious, there evidently is an unsupported technique to put Humpty Dumpty a Hyper-V VM back together again — for data recovery purposes only. If making symlinks to XML files is your thing, go check it out.
When choosing a virtualization platform, don’t forget about the little things that can make a big difference.