As many of you know XenServer before version 5.6 has no online leaf node coalescing integrated and so you have to shut down or halt a virtual machine when you want to manually coalesce the leaf node of a virtual machine.
For those of you first time reading about coalescing and snapshots here is a short summary:
When you snapshot a virtual machine the virtual disk of this VM is set to read only (parent disk) and a additional virtual disk is chained to the read only disk (leaf node) where the VM can place additional write operations. If you create a second snapshot the first chained disk also gets read only and again a second disk is created and chained to the first snapshot disk to take the read operations of the vm after the second snapshot was taken. The last disk in this chain is called the leaf node.
When you now delete a snapshot the chain disk for this snapshot is merged into its parent disk to reduce the length of the disk chain. This can be done when the virtual machine is running excepting the last existing snapshot. For the last snapshot this is very complicated because the vdisks are online and in use of the virtual machine.
This problem is solved in XenServer 5.6 FP1 but for 5.6 and earlier read this cool workaround …
But over the time if you are working a lot with snapshots and have not the possibility to reclaim the space because of availability of the virtual machine there is an additional amount of space wasted on the storage repository which cannot be reclaimed but can be minimized to nearly zero by a simple trick:
Create a snapshot before installing the operating system into the virtual machine and delete it afterwards.
I create virtual machine with a 12 GB attached vDisk. At the end of the creation wizard select not to start the virtual machine when finished. On the storage I can see the following:
The total usage of storage is ~12 GB. Before starting the virtual machine and installing the operating system into our VM I will create a snapshot. The main disk will be inflated as expected and the additional (leaf node) disk will have a size of 12GB. The total usage of the storage is now ~12 GB for the leaf node, ~8 MB for the read only parent disk and ~8 MB for the snapshot representing disk.
So the usage of storage is approxemately 16 MB more than without a snapshot. Now I install the operating system into the virtual machine. Because of the 8 MB parent disk is read only all data will be written into the 12GB leaf node.
When I now delete the snapshot there will only be the parent node and the leaf node:
In the XenCenter management console you will not see any snapshots for the virtual machine. Just on the storage with a more of use of the 8MB.
By this usage from now you can work with snapshots in XenServer versions earlier 5.6 feature pack 1 with a minimized consumption of storage because we reduce the storage overhead to ~8 MB per virtual machine.
Also there will be no performance impact because all data is located into the leaf node and so the virtual machine will get its data with the first disk access.