Latest News

How to Recreate VMDK File when Corrupt

Friday, May 15, 2009 , Posted by Virtualbox at 7:59 PM

On ESX 3, VirtualMachine(VM) has one or more VMDK files (extension .vmdk) and one or more flat vmdk files (last characters flat.vmdk ).In some cases, you may corrupt, lose, or accidentally delete your VMDK files. The VMDK’s contain metadata for the flat.vmdk files. Without VMDK’s, you cannot load the flat.vmdk-files.


Consequence: You cannot load the VM in VirtualCenter and cannot start the VM.

There are two ways to recreate the vmdk files (.vmdk):

I. Creating a new virtual disk.

* Create a new virtual disk of the same size as old ones for the "VM A" as vmA1-flat.vmdk which in turn will create a new vmdk descriptor file and refer that file for the old one.

Command:

#vmkfstools -c 8192m /vmfs/volumes/100GB-Tru64-EVA/vmA/vmA1.vmdk
where, 8192MB is the virtual disk size and vmA1.vmdk is the descriptor file for the newly created disk "vmA1-flat.vmdk".

Edit the VMDK’s with a text editor(vi/nano):

This will now refer to the vmA1, but it should refer to you're the old one, vmA. You need to replace the vmA1 descriptor file with the correct file names; that is, vmA.

For example:
# mv vmA1.vmdk vmA.
# vi vmA.vmdk

The file will look like:
# Disk DescriptorFile
version=1
CID=6479ab28
parentCID=ffffffff
createType="vmfs"

# Extent description

RW 4194304 VMFS "vmA1-flat.vmdk"

# The Disk Data Base
#DDB

ddb.virtualHWVersion = "4"
ddb.uuid = "60 00 C2 9a dc 6c 31 eb-81 6f f1 a1 ca 2d 7b 37"
ddb.geometry.cylinders = "261"
ddb.geometry.heads = "255"
ddb.geometry.sectors = "63"
ddb.adapterType = "lsilogic"

Edit the line: RW 4194304 VMFS "vmA1-flat.vmdk" TO RW 4194304 VMFS "vmA-flat.vmdk"

* Save the file.
* Load the VM from the VirtualCenter; that is, Power ON VM A.

2. Creating a new virtual machine.
A. Determine the hard disk sizes of your original VM. (Lets call this VM as “VM A”).
B. Create a new VM (called “VM B”) from VirtualCenter with the same number of hard disks as the old VM, and the exact same sizes.

Steps:

a) Login to VirtualCenter. Select the ESX host.
b) Select "CREATE A NEW VIRTUAL MACHINE". A "New VM wizard" will appear.Select "VM Configuration" as "Typical". Click NEXT.
c) Give a name to the VM; for eg: vmB. Click NEXT.
d) Select the datastore and click NEXT.
e) Select the Guest OS as the VM A "vmA" was installed with. Click NEXT.
f) Select the no. of virtual processors. Click NEXT.
g) Select the memory as required, click NEXT.
h) Create Network Connections as required, click NEXT.I) Select the Virtual disk size same as "VM A". Click NEXT.
j) Click FINISH.


3. After the VM B has been created, use Putty (or a similar tool) to navigate to the ESX server. Then navigate to the location/directory where your VM B is stored. For example:#cd /vmfs/volumes/100GB-Tru64-EVA/vmB


4. Copy all VMDK’s (not the flat ones, but only the metadata files) to VM A directory. The filesize of your META-data files should be a few KB. For example: # cp vmB.vmdk /vmfs/volumes/100GB-Tru64-EVA/vmA/


5. Navigate to VM A directory where the *.VMDK file/s are copied. Edit the VMDK’s with a text editor(vi/nano): They will now refer to the VM B, but they should refer to your old VM A. You should replace the VM B filenames with the correct file names; that is, VM A.

For example:
# mv vmB.vmdk vmA.vmdk
# vi vmA.vmdk

The file will look like:

# Disk DescriptorFile
version=1
CID=6479ab28
parentCID=ffffffff
createType="vmfs"
# Extent description
RW 4194304 VMFS "vmB-flat.vmdk"

# The Disk Data Base
#DDB

ddb.virtualHWVersion = "4"
ddb.uuid = "60 00 C2 9a dc 6c 31 eb-81 6f f1 a1 ca 2d 7b 37"
ddb.geometry.cylinders = "261"
ddb.geometry.heads = "255"
ddb.geometry.sectors = "63"
ddb.adapterType = "lsilogic"

Edit the line:
RW 4194304 VMFS "vmB-flat.vmdk" TO RW 4194304 VMFS "vmA-flat.vmdk"

5. Save the file. 6. Load the VM from the VirtualCenter; that is, Power ON VM A.You should now be able to Power ON the VM A and recover the data.

Currently have 1 comments:

  1. Unknown says:

    Your tips and notes is very impressive and helpful to recreate VMDK file. When VMDK file Corrupted it can be Recreate easily with many tricks it so easy. You are doing a superb job. Thank you!
    http://www.diskdoctors.net/faq/latest/deleted-email-recovery.html

Leave a Reply

Post a Comment