VMware snapshots: Or, vmsd's, vmsn's, CID chains, and what happens when you press delete all

Source: Internet
Author: User

I had to use the information below when I inadvertently relocated a VM from one ESX Server to another without first checking to see if it had snapshots. you see, if you ever move a VM with snapshots you will break the links between the vmdk and snapshot
Delta files and will have to manually recreate them as described in the article below (information sourced from

Here ).

VMware snapshots: Or, vmsd's, vmsn's, CID chains, and what happens when you press delete all

Have you ever had a problem with snapshots in VMware? Sometimes it's enough just to know someone else feels your pain. most of the time of course, it's not. so, if you're in that situation here are some things you shoshould know about snapshots before you're
Required to troubleshoot them.

The first thing I'll mention is that if you look at a datastore through VI client you'll see Virtual Disks represented like this:

Server. vmdk

Via putty they'll appear as two separate files:

Server. vmdk
Server-flat.vmdk

Server. vmdk is a text file that describes the disk, whereas server-flat.vmdk is the actual file containing the disk's data.

If you have a server called 'server' stored on a datastore with the friendly name of 'san _ 0000_1 ', you can view the text file via putty as follows (once you 've ve logged in)

CD/vmfs/volumes/san_0000_1/Server
VI server. vmdk

Here you'll note some interesting things.

Cid = ab1234cd <-this is a randomly generated string, but it's quite important as you'll see in just a second.

Parentcid = ffffffff

The parentcid is the next disk up in the chain. A value of ffffff denotes that this disk is the 'original' disk.

You'll also find information here on adapter type, geometry, etc.

So, using our earlier example, we have a server called 'server' with one vmdk of 30 GB. We then create a snapshot called test.

If you doLsOn/Vmfs/volumes/san_0000_1/ServerWe'll now see the following files (there'll be more obviously, but these are the ones we're interested in ):

Server. vmdk
Server-flat.vmdk
Server-000001.vmdk
Server-000001-delta.vmdk

If you runVI server-000001.vmdkYou'll notice something about the CID values, namely this:

Cid = <another random string>

Parentcid = ab1234cd (I. e. the value of the CID attribute for the base disk)

This relates the snapshot's disk to the flat file. if the snapshot's parentcid and the base disk's CID values don't match, you won't be able to apply the snapshot until you manually edit the files so that this CID relationship exists.

If you added another snapshot (so, you had server-000002.vmdk) This disk wowould have a parentcid equal to the CID of server-000001.vmdk

One more attribute in the snapshot's vmdk file is of interest:

Parentfilenamehint = "server. vmdk"

If the snapshot relates to a disk on another Lun this value will contain in a full path. It's possible you'll need to amend this if disk or snapshot files have been moved around.

Another file worth knowing about is server-Snapshot #. vmsn (where # denotes the number of times a server has been snapshotted ). this appears to be a text file if you use VI to look at it, but actually you won't want to alter this file.

Finally then, files wise, we have server. vmsd

This file contains a wealth of information and is basically the virtual machine's way of tracking where it is with snapshots.

It contains a complete list of snapshots for the VM, the number of disks, friendly name for the snapshot, etc.

Assume we have the same server, but it has two virtual disks, both of which have been snapshotted once. You'll see lines in the vmsd like this:

Snapshot0.disk0. filename = "server. vmdk"
Snapshot0.disk0. node = "scsi0: 0"
Snapshot0.disk1. filename = "server_1.vmdk"
Snapshot0.disk1. node = "scsi0: 1"

OK, now imagine you 've deleted that second virtual disk and you then try and delete the snapshot. you'll get an error message telling you that the virtual machine configuration has changed since the snapshot was taken.

In this instance I 've had some success with deleting the 'disk1 'lines in the vmsd and then reapplying the snapshot.

It's interesting to note that if you view the server. vmx file with VI you'll notice that the disks listed point to the snapshot files, e.g.

Scsi0: 0. Present = "true"
Scsi0: 0. filename = server-000001.vmdk"
Scsi0: 0. devicetype = "SCSI-harddisk"

Even if the CID chaining, parentfilenamehint, etc are all correct you might still have problems with deleting snapshots. by the way, 'delete' is a pretty confusing term, because to delete a snapshot actually means to merge the changes in a way that they
Are committed to the base disk (rather than to simply revert to the base disk ).

If you 've read this far, you 've almost certainly got a snapshot that won't apply (or you just like to read maybe ). either way, here are some tips for fixing this kind of issue:

As crazy as it might sound, and probably also like the last thing you 'd want to do. if the snapshot isn't showing up in VI client's snapshot manager, and yet you know the server does have a snapshot running. then Snapshot the server again. VI shoshould then
Be able to show you the new snapshot, and previous snapshots. 'delete all' will remove all the snapshots.

Seen as how I 've mentioned' Delete all', it's important that you know how this works. because, to be honest, it'll look like it's not doing anything. this is especially important when you consider that if you try a 'delete all' from VI client it will time
Out after 15 minutes (unless you changed the time out value), but will keep going.

When you select 'delete all', the last snapshot in the chain is rolled into the previous snapshot and so on, until all the data is back into the base disk. then all the snapshot files are deleted. this takes up a lot of space, and if you have a long chain
Of snapshots, or they're very big, this will make it look like nothing is happening, when actually it is (even if it takes several hours for very large VM's)

For this reason I 'd recommend you delete snapshots one at a time if you're 've got a long chain of them. also, turn off the VM if you're able, it'll speed things up. you also have the option to run a 'delete all' from the command line:

Vmkfstools/vmfs/volumes/san_0000_1/Server/server. vmx removesnapshots

There is one, last ditch effort you can make to recover a VM that's just a mess of snapshots (but you can still power it on). Specifically, you can clone the disk.

To do this, run the following command, giving the path to the last snapshot in the chain.

Vmkfstools-I/vmfs/volumes/san_1__1/Server/server-000002.vmdk/vmfs/volumes/special_spare_lun/new_server.vmdk

When it's finished cloning (this may take a while, and you can only do it when the VM is powered off) you shoshould be able to create a new VM (or edit an existing one) using this disk.

I 've been in a situation that required edits to the vmsd, vmx, and vmdk files, as well as several hours of patient waiting for the 'delete all' to finish on a critical, live server. my advice is to draw a dimo-before you start pressing buttons, check
The Cid chains, check the parentfilenamehint, check the vmx file, check the vmsd file, make a plan, then execute it. Good luck.-taken entirely from
Sysadminblog.

There is no time for translation. For more information, see. There is still a lot of knowledge about VMWare on the original webpage. Please check it out later.

Http://blog.ghai.us/bob? Cat = 5

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.