VM recovery is a process where users can restore the original virtual machine session without losing data. But it entails having a backup file that can be used as a Guest to restore the host session. With a flat VMDK in place, the user first restores the descriptor file and then uses the restored VMDK to recover the original VM session. It is possible because a VM is essentially another software running on an OS that can get backed up. While there are other methods to back up and restore a VM, such as a Snapshot, the following article will explore the VM restoration process using a flat VMDK file.
What is a Flat VMDK file?
VMDK, short for Virtual Machine Disk, is a format for VM disk image files. As such, any VMDK file, in itself, is a complete and independent VM. Typically, users can install any Guest OS on a virtual disk, making the VD equivalent of a traditional hard disk or SSD. Doing so also makes the VM installed on such a disk ready to use. And VMDK is the format users can back up or save said virtual disks.
Thus, a user can simply use the VMDK file as a VM if needed. And that is why it is also possible to restore a VM with the help of a VMDK file. The following method uses the flat VMDK to restore the VMDK descriptor file, which acts as the VM, and replace it, so the VM can boot properly.
Note that if you are using a virtualization tool such as VMWare Virtual Box, you can simply restore a VirtualBox Snapshot to get back to the previous working state of your machine.
VM recovery process using a Flat VMDK file:
Step 1. First, Open the ESXi host command line.
Step 2. Then login as a root user using SSH.
Step 3. Now locate the flat.vmdk file in the data store using the command:
Step 4. After that, take a note of the actual size of the flat file.
ls -l vmdisk0-flat.vmdk
Step 5. Here, users are needed to create a new VMDK file. Thus, use the vmkfstools command:
vmkfstools -c (Size of the file) -d thin temp.vmdk
Step 6. Now two temp files will get created: temp.vmdk and temp-flat.vmdk.
Step 7. The user can delete the temp-flat.vmdk file, as it is no longer needed.
Step 8. Finally, run the following command to recover the VM:
rm -i temp-flat.vmdk
Step 9. Users should also rename the temp.vmdk file to match the original VM name.vmdk.
mv -i temp.vmdk orignalvmname().vmdk
Step 10. And then, edit the orignalvmname.vmdk for the line “RW, and you can replace it with file temp.vmdk to originalvmname.vmdk.”
Step 11. Lastly, boot up the Virtual Machine to see whether it is working perfectly or not.