How VHDs are created/merged when creating/removing VM checkpoints in Hyper-V
Contents
TLDR
Removing a checkpoint that has one child checkpoint:
Removing a checkpoint that has multiple child checkpoints:
And this is what happens when we get rid of branching in the checkpoints tree:
Continue reading if you want to see how to check it by yourself in Hyper-V.
Creating a checkpoint
First let’s see what happens with VHDs when checkpoints are created. We have a virtual machine named SRV01 that has no checkpoints:
This VM has one VHD:
Let’s visualize it:
Now let’s create a checkpoint:
This is what happened with the VHD of the VM when when the checkpoint was created:
-
a differencing VHD SRV01...DB.avhdx was created and connected to this VM:
PS C:\> (Get-VM SRV01).HardDrives.Path.Split("\")[-1] SRV01_4960DD5A-FA60-49D3-9F75-D85ABF8430DB.avhdx
-
SRV01...DB.avhdx has SRV01.avhdx as its parent:
PS C:\> Get-VHD "E:\VMs\SRV01\Virtual Hard Disks\SRV01_4960DD5A-FA60-49D3-9F75-D85ABF8430DB.avhdx" ` >> | FL VhdType, Path, ParentPath VhdType : Differencing Path : e:\vms\srv01\virtual hard disks\srv01_4960dd5a-fa60-49d3-9f75-d85abf8430db.avhdx ParentPath : E:\VMs\SRV01\Virtual Hard Disks\SRV01.vhdx
-
a checkpoint was created and it “points” at the VHD SRV01.vhdx:
PS C:\> Get-VMCheckpoint SRV01 | FT Name, @{ N = "Disk"; E = { $_.HardDrives.Path.Split("\")[-1] } } Name Disk ---- ---- Checkpoint1 SRV01.vhdx
Let’s visualize it again:
Now we know what happens with VHDs when checkpoints are created. In the following sections we will see what happens with VHDs when checkpoints are removed. There are two situations that may occur when a checkpoint is removed:
- Checkpoint being removed has only one child checkpoint.
- Checkpoint being removed has multiple child checkpoints.
We will take a look at both.
Removing a checkpoint with one child checkpoint
Let’s take a VM with checkpoints created sequentially one after the other, so that each checkpoint has one child checkpoint:
Each checkpoint has its VHD:
So, this is what we have:
Now let’s remove Checkpoint2 from this sequence:
And see how the VHD chain was changed:
So, the following happened:
- Checkpoint2 was removed;
-
SRV01...0D.avhdx was merged into SRV01...DB.avhdx:
- VM state, that before merging was stored on SRV01...DB.avhdx, was lost (that is, state in Checkpoint2 was lost);
- VM state, that before merging was stored on SRV01...0D.avhdx, was preserved (that is, state in Checkpoint3 was preserved);
- SRV01...44.avhdx now has SRV01...DB.avhdx as its parent;
- Checkpoint3 now “points” at SRV01...DB.avhdx.
Let’s show these changes on our diagram:
Removing a checkpoint with multiple child checkpoints
Now let’s see what happens when the checkpoints tree has branching:
Let’s remove Checkpoint2. This checkpoint has two child checkpoints, and VHDs of that child checkpoints can’t be merged into SRV01...79.avhdx.
Again, let’s see the changes of the VHD chains:
We see that:
- Checkpoint2 was removed;
- SRV01...79.avhdx has no checkpoints associated with it;
- all VHDs are on their places — none of them was removed and VHDs chains were not changed.
And the diagram is:
Finally, let’s see one more example: what will happen if we remove branching by removing Checkpoint3B. By doing so we will remove SRV01...E5.avhdx, and nothing should prevent SRV01...23.avhdx from merging into SRV01...79.avhdx:
The updated diagram:
We see that after SRV01...E5.avhdx had been removed, SRV01...23.avhdx was merged into SRV01...79.avhdx.