Thursday, September 22, 2011

SNAPSHOT

What are snapshots:

Snapshots are the copy with latest data of the original base disk . We cant call rather a backup of the original base disk . When snapshots are taken , the original base disk no more receive any updates to the operating system disk and the snap shot disk creates a copy of the original base disk as a delta disk with vmname.00000x.vmdk. Deleting the snapshots here means the latest changes are commited to the original base disk.



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

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


SNAPSHOT

A VMware ESX virtual machine disk consists of a descriptor (ends in .vmdk) and an extent (ends in -flat.vmdk). When a virtual machine has been snapshotted, the attached virtual hard disks (otherwise known as the base disks) no longer receive guest OS modifications or writes; they are stored in separate virtual machine delta disk files (ending in -delta.vmdk). There is one delta file per base disk that is snapshotted.

With exception to thin-provisioned virtual machine disks, virtual machine disks typically have a reserved or set space requirement on a datastore. Snapshots, however, require additional space and consideration. They increase in size as further modifications or writes are stored.

For example:

  1. If 10GB of changes were completed on one snapshotted virtual machine, its delta disk file size will increase proportionally by 10GB.
  2. Creating another snapshot causes the existing snapshot delta disk to retain its current size, however the next delta disk will begin to store all forthcoming modifications and writes. The base disk is still left unmodified since inception of the first snapshot.
  3. If another 15GB of changes were performed by the guest operating system, a total of 25GB of snapshot delta has now been recorded over the respective virtual machine's two snapshot delta disk files.
  4. For versions prior to VMware ESX 4.0 Update-2, the task of consolidating all snapshots (Remove All Snapshots task) causes unique changes stored only in the second snapshot delta disk to be copied upwards through the snapshot chain and into the first snapshot, or its "parent."
  5. This effect is recursive for each preceding parent file. As a result, the first snapshot delta disk file will grow by up to 15GB, accommodating all new blocks. Any common changes stored in both snapshot levels does not require additional space, however.
  6. The end result is a datastore requiring 40GB, or 25GB + 15GB.

Notes:

  • Additional space is required if the virtual machine is running during a Remove All Snapshots task. The amount of space consumed is dependent the amount of snapshot delta information the virtual machine has to temporarily store while its consolidation process completes.
  • If the same 10GB were changed in the second snapshot, and just 5GB of unique block changes occurred, then the first snapshot will increase by 5GB during the consolidation, not the complete 15GB.
  • Opting to save virtual machine memory contents with each Create Snapshot task requires additional space from the VMFS datastore. The amount of space required is equivalent to the amount of memory assigned to the virtual machine. This requirement can apply multiple times over, if multiple snapshots including virtual machine memory contents are created.

If a datastore fills up due to delta files accumulating too much space, or the datastore runs out of space during a snapshot consolidation effort, the symptoms outlined previously will occur. Migration or removal of stored data and snapshot consolidation will be required to resolve the issue.

Creating / removing the snapshot from the esx or esxi host

On an ESXi host, to commit all snapshots using the command line:

  1. Log in to the ESXi host as root via the console or an SSH session. For more information about SSH, see see Tech Support Mode for Emergency Support (1003677) or Using Tech Support Mode in ESXi 4.1 (1017910).

    Note: The following commands can also be executed remotely using the vSphere Command Line for both ESX and ESXi hosts. For more information, see vSphere Command Line Interface documentation.
  2. Run this command to get a list of virtual machines and the VMID for each virtual machine:
    vim-cmd vmsvc/getallvms

    Output similar to the following is displayed:

    Vmid Name File Guest OS Version Annotation
    1 vm1 [datastore1] vm1/vm1.vmx windows7Server64Guest vmx-08
    3 testvm [iscsi1] testvm/testvm.vmx winNetDatacenterGuest vmx-08

    Make a note of the VMID for the specific virtual machine.
  3. To verify if the snapshot exists, run this command and check the Snapshot Name, Snapshot Created On, and Snapshot State:

    vim-cmd vmsvc/snapshot.get [VMID]

    You see an output similar to:

    Get Snapshot:
    |-ROOT
    --Snapshot Name : Test
    --Snapshot Desciption :
    --Snapshot Created On : 7/27/2011 13:49:55
    --Snapshot State : powered on
  4. Run this command to create a new snapshot:
    vim-cmd vmsvc/snapshot.create [VmId] [snapshotName] [snapshotDescription] [includeMemory] [quiesced]

    For example, to create a snapshot on VM testvm:
    vim-cmd vmsvc/snapshot.create 3 snapshot1 snapshot 0 0

    Note: You can use any name you like. The name appears in the snapshot manager.
  5. Run this command to remove all snapshots:
    vim-cmd vmsvc/snapshot.removeall [VMID]

On an ESX host, to commit all snapshots by using the command line:

1. Log in to the ESX host as root via the console or an SSH session. For more information about SSH, see Unable to connect to an ESX host using Secure Shell (SSH) (1003807).

Note: The following commands can also be executed remotely using the vSphere Command Line for both ESX and ESXi hosts. For more information, see vSphere Command Line Interface documentation.

2. Type vmware-cmd -l and press Enter.

The output appears similar to:

/vmfs/volumes/UUID/VMNAME/VMNAME.vmx

3. Type vmware-cmd /vmfs/volumes/UUID/VMNAME/VMNAME.vmx hassnapshot and press Enter to confirm that there is a snapshot. If the output displays a value of 1, a snapshot is present. If the output displays a value of 0, there is no snapshot present.

4. Type vmware-cmd /vmfs/volumes/UUID/VMNAME/VMNAME.vmx createsnapshot and press Enter to create a new snapshot.

For example, the command
vmware-cmd /vmfs/volumes/UUID/VMNAME/VMNAME.vmx createsnapshot "test" "" 0 0 makes a snapshot without memory, quiescing, or a description called test .

Note: You can use any name you like. The name appears in the snapshot manager. For more information about the syntax of the vmware-cmd command, see vSphere Command Line Interface documentation.

5. Type vmware-cmd /vmfs/volumes/UUID/VMNAME/VMNAME.vmx removesnapshots and press Enter to remove the snapshot.





The disk chain in a snap shot process.

Generally, when you create a snapshot for the first time, the first child disk is created from the parent disk. Successive snapshots generate new child disks from the last child disk on the chain. The relationship can change if you have multiple branches in the snapshot chain.

This diagram is an example of a snapshot chain. Each square represents a block of data or a grain as described above:






No comments: