This post summaries a procedure I used to recover a corrupt VM.
The VM had 15 snapshots when we looked at the disks, however VMware did not show any.
Disk consolidation did not work, it ended in an error. Using vmkfstools to clone the disk also ended with an error.
Storage VMotion also did not work…
So we tried to come up with an solution to regenerate the VM (which was running fine) but with normal single VMDK disks.
One solution is to start the VM, stop the application services and use the VMware Converter to import this “physical” server.
This solution uses a running machine, this was not my preferred method.
Someone suggested using the GParted Live CD to copy the partition to a new disk and creating a new VM using the vmx file and the new copied VMDK.
We downloaded the GParted Live CD. We used the amd64 edition.
I always have this ISO with me, but never used it for copy actions.
Download link: http://gparted.sourceforge.net/download.php
Here is the procedure we used:
- Power off the corrupt VM
- Attach the ISO to the corrupt VM
- We set the Bios splash screen timeout to 10 seconds (http://kb.vmware.com/kb/1004129).
- Add a new harddisk to the VM. This wil become your new disk. Make sure it is at least the same size.
- Power on the VM and press ESC to access the boot options menu and select CD/DVD drive
- GParted is started
Select the new disk on the top right, it is probably named /dev/sdb or /dev/sdc. It should be empty so easy to recognize.
- We create a new partition table on this disk (msdos type)
- Select the source disk again (this is the corrupted one).
Richt click on the 1st partition and select copy.
- Select the new empty target disk, right click and select paste.
Press apply in the toolbar to start the copy process.
Do this step for each partition, started at the beginning of the disk. With Windows 2008 R2, also copy the small 100 MB partition.
- Check if the partition flags are equal, not all flags are copied. I needed to set the ‘boot’ flag on the small 100 MB partition.
- After you have copied all partitions, quit from GParted by pressing the red button on the top left and select shutdown.
During the shutdown process it will ask you to disconnect/eject the CD.
- I logged on the the VMware CLI interface and copied the vmx and the newly created disk to a new directory.
Rename the disk according to the Vmware standards for the first disk.
Also adjust the vmx file to refelct the disk name changes
- Register the VM in VirtualCenter
- Check the disk configuration of the VM, when in doubt, remove from config and add the disk again.
- Power on your VM
It would have been nice if this was the end, but the VM would not start…
We received a message that windows could not boot.
The solution was quite easy once we found the correct MS KB article: http://support.microsoft.com/kb/2261423/en-us
Start the VM from the Windows DVD and select “repair your computer”. Once started select the command prompt.
Microsoft has created a utility to check the startup configuration and repairs any problems found.
Start this utility from the X-drive: cd \sources\recovery\StartRep.exe
This utility repaired my startup configuration and the VM booted and worked fine!