Rebuilding a VMware VMDK from Scratch

Published:
This type of situation occurs when you either accidently delete a vmdk and have only a xxxx-flat.vmdk file or if you had a second machine attached to a disk and delete that machine it details the details of the disk. You cannot mount a xxxx-flat.vmdk file to any virtual machine because the machine has no idea how to manage the disk. So you can no longer attach the disk or boot the VM it is attached too. The very first step is to remove the original disk from the machine so there is no way to power on or essentially damage the files. Verify you can still boot the VM successfully but minus the disk (if it was not the primary disk). If you have no disk space to re-create a mirror of this disk (in order to copy the vmdk settings into the problematic file) disk to pull the .vmdk file from and point it to the xxxx-flat.vmdk file so you can create an any size virtual disk on the specified machine and attached it to the xxxx-flat.vmdk and then calculate the the Cylinders, Sectors, and Heads for the original  xxxx-flat.vmdk. I found a excellent website to assist the calculations:

This website will give you the calculations you need.
http://sanbarrow.com/vmdk/diskgeometrietable2.html

This example is of a 510gb disk that was deleted and used a 40gb disk to recreate the xxxx.vmdk I needed. From here I was able to re-create the .VMDK file for the virtual disk as follows (the original):

version=1
                      CID=ed3d02ab
                      parentCID=ffffffff
                      createType= vmfs 
                      RW 83886080 VMFS old-server-flat.vmdk 
                      #DDB
                      ddb.virtualHWVersion = 43
                      ddb.uuid = 60 00 C2 90 c2 f2 8d d4-0f 36 a2 46 de 22 61 6e 
                      ddb.geometry.cylinders = 52213
                      ddb.geometry.heads = 2553
                      ddb.geometry.sectors = 633
                      ddb.adapterType = buslogic 

Open in new window


The new .VMDK file:
version=1
                      CID=ed3d02ab
                      parentCID=ffffffff
                      createType= vmfs 
                      RW 1069547520 VMFS exisiting-server-flat.vmdk 
                      #DDB
                      ddb.virtualHWVersion = 43
                      ddb.uuid = 60 00 C2 90 c2 f2 8d d4-0f 36 a2 46 de 22 61 6e 
                      ddb.geometry.cylinders = 665763
                      ddb.geometry.heads = 2553
                      ddb.geometry.sectors = 633
                      ddb.adapterType = buslogic

Open in new window


You can see that the geomotry of the disk changed to reflect the actual listed in VMware when referring to the machine and its attached disks. The most important part is to update the pointer to reflect the xxxx-flat.vmdk file that was the problem. You will notice if you look at the datastore now that the xxxx-flat.vmdk is now hidden and only the xxxx.vmdk is showing. This means you corrected the problem and now you can attach the disk back to the virtual machine. Either complete this step while the machine is running or turn it off and mount it. Anyway you do it, you will be happy that you restored your disk.
1
6,643 Views

Comments (0)

Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.