Tuesday, 26 October 2010

Calculating the RW Value in a VMDK Disk Descriptor File, and Fixing Incorrect Virtual Disk Capacity

*Update: see Formulas to Calculate Dimensionless Hard Disk Size, and a Real World Application to Extending a UFS Partition  posted 20/01/2012

Formula to find R the RW value in the disk descriptor file from G the exact GByte capacity of the disk

R = G x 2097152     {or R = Gx1024x1024x1024/512 }

If you don't know the exact GBbyte capacity of the disk, you can only roughly work it out from number of cylinders C
R = (((C+1)x512xSxH)/1024)-8)x2     {where S is the number of sectors, and H is the number of heads}


Scenario: A virtual guest server has a virtual disk with its capacity totally incorrect, preventing cloning, storage vMotion …

The virtual guest machine in question has a disk that is only 20GB in size (as seen from browsing the datastore, and in Windows,) but the VI Client (this is ESX 3.5U4) connected to either the vCenter or the host, says the disk is 10245.08GB. Investigation shows the RW value in the VMDK disk descriptor file is wrong.


[root@esx01 EXAMPLE]# cat EXAMPLE_0.vmdk

# Disk DescriptorFile
version=1
CID=76cbf27f
parentCID=ffffffff
createType="vmfs"

# Extent description
RW 21485479936 VMFS "EXAMPLE_0-flat.vmdk"

# The Disk Data Base
#DDB

ddb.virtualHWVersion = "4"
ddb.toolsVersion = "7303"
ddb.geometry.cylinders = "2612"
ddb.geometry.heads = "255"
ddb.geometry.sectors = "63"
ddb.adapterType = "lsilogic"

[root@esx01 EXAMPLE]#

The RW above should be 20 x 2097152 = 41943040 not 21485479936 (which divided by 2097152 does indeed give the 10245.08 seen via the VI client.)

How to fix:

You might think the above formulas will help, in practice they don't.

The solution:

1: Shutdown the affected machine
2: Detach the affected disk
3: Create another disk of exactly the same size
4: Edit the disk descriptor file for the new VMDK to point to the old -FLAT.VMDK
5: Re-attach the disk using the same SCSI ID as before
6: Boot the affected machine back up

See: http://www.vm-aware.com/2008/06/recreating-missing-vmdk-descriptor-files/

Also see: http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1026266

No comments:

Post a Comment