Sunday, 21 August 2011

How to Reattach a Snapshotted vmdk

Scenario: A server is in snapshot mode and a snapshotted drive is removed from the virtual machine. When try to reattach the DISKNAME-00000X.vmdk drive, the error “An internal error occurred in the vSphere Client. Details: Object reference not set to an instance of an object.” appears as below:


Solution:

1: View the contents of the vmdk disk descriptor file of the base disk using a tool like Veeam FastSCP

Example:

# Disk DescriptorFile
version=1
encoding="UTF-8"
CID=ca56789b
parentCID=ffffffff
isNativeSnapshot="no"
createType="vmfs"

# Extent description
RW 6291456 VMFS "W7WS00 Test II_1-flat.vmdk"

# The Disk Data Base
#DDB

ddb.adapterType = "lsilogic"
ddb.thinProvisioned = "1"
ddb.geometry.sectors = "63"
ddb.geometry.heads = "255"
ddb.geometry.cylinders = "391"
ddb.uuid = "60 00 C2 97 b0 04 94 f1-ff 58 92 07 08 21 bf 10"
ddb.longContentID = "15d423fa3c6839a450300859ca56789b"
ddb.deletable = "true"
ddb.virtualHWVersion = "7"

2: View the contents of the vmdk disk descriptor file for the latest snapshot

Example:

# Disk DescriptorFile
version=1
encoding="UTF-8"
CID=32ddb9ae
parentCID=ca56789b
isNativeSnapshot="no"
createType="vmfsSparse"
parentFileNameHint="W7WS00 Test II_1.vmdk"
# Extent description
RW 6291456 VMFSSPARSE "W7WS00 Test II_1-000001-delta.vmdk"

# The Disk Data Base
#DDB

ddb.longContentID = "5861ab1403fcff3e472f2b0732ddb9ae"

- and edit the file by entering the below lines from the original, and then save -

ddb.adapterType = ?
ddb.thinProvisioned = ?
ddb.geometry.sectors = ?
ddb.geometry.heads = ?
ddb.geometry.cylinders = ?
ddb.uuid = ?
ddb.deletable = ?
ddb.virtualHWVersion = ?

Example:

ddb.adapterType = "lsilogic"
ddb.thinProvisioned = "1"
ddb.geometry.sectors = "63"
ddb.geometry.heads = "255"
ddb.geometry.cylinders = "391"
ddb.uuid = "60 00 C2 97 b0 04 94 f1-ff 58 92 07 08 21 bf 10"
ddb.deletable = "true"
ddb.virtualHWVersion = "7"

Now the DISKNAME-00000X.vmdk file can now be reattached!

For Google search: Can you reattach a vmdk which is / was in snapshot mode / snapshotted - yes you can!

7 comments:

  1. A warning, if, like me, you mistakenly mount the base disk and it gets changed then your *-0000xx.vmdk file won't be able to be added anyway. I'm in the process of restoring a backup of the base disk now to try and correct that problem.

    ReplyDelete
  2. Hi Chris
    Thank you for the warning.
    Indeed, if the base vmdk is mounted and the server powered on, the disk blocks get changed and then it is pretty much game over for any snapshot delta vmdks that referenced the blocks on the original base vmdk - unless there is a backup the includes the original base disk.
    Good luck with the restore
    Cheers

    ReplyDelete
  3. Thanks Vidad!
    I've got files restored and my virtual machine is running with the proper data again. I'll be adding these steps to my solutions database for future reference.

    ReplyDelete
  4. i am not clear of process reattach the vmdk snapshot file.can u explain or is this explained in vmware kb?

    ReplyDelete
    Replies
    1. Hi Am_7riel, I had not seen this information in a KB, just worked this out to show that it can be done.
      The disk descriptor file for a delta vmdk does not contain any hardware information (like sectors, heads, cylinders) so all we do is copy the hardware information from the base vmdk's disk descriptor, put it in the delta vmdk's disk descriptor, and now the delta vmdk can be re-attached to a VM.
      Cheers!

      Delete
  5. Thanks...that got it going. But I had mounted the base image and changed the CID, so the disks after snapshots would not fire up. This link explains how to match them back up (if you haven't run the base image too much). I thought I'd lost an important machine....lucky!

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

    ReplyDelete
  6. Hi, We have this problem. But We have modify by error the base disk, and our backup (VMExplorer) commit the snapshots in the proccess, so that we don´t have a base disk backup.
    Is there any solution for this?
    Thanks

    ReplyDelete