After exporting hyper-v vmcx, vhdx avhdx will not be automatically merged

Tim 0 Reputation points
2025-08-07T03:16:11.6933333+00:00

I use root\virtualization\v2 ExportSystemDefinition, and I have the following settings:

exportSettingData["CopySnapshotConfiguration"] = 1;
exportSettingData["CopyVmRuntimeInformation"] = false;
exportSettingData["CopyVmStorage"] = false;
exportSettingData["CreateVmExportSubdirectory"] = true;
exportSettingData["CaptureLiveState"] = 0;

Once I successfully export, any checkpoints taken after that and deleted will not be merged until I shut down the virtual machine or Restart-Service vmms. Can anyone help me? Thank you very much.

Windows for business | Windows Server | Storage high availability | Virtualization and Hyper-V
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. HenryMai-3878 6,585 Reputation points Independent Advisor
    2025-08-07T15:32:05.57+00:00

    Hello Tim, I am Henry and I want to share my insight about your issue

    The behavior you're seeing is by design. When you run ExportSystemDefinition with CopyVmStorage = false, Hyper-V intentionally places a temporary lock on the VM's disk chain. This is done to guarantee the consistency of the exported configuration and its associated checkpoints. This lock, however, is what prevents the live merge process from running.

    My recommendation to handle this without restarting the VM or the service is to isolate the lock to a temporary checkpoint that you create and then immediately delete.

    1. Create a Temporary Checkpoint: Before running your export script, create a new checkpoint for the VM. Let's call it "TempExportCheckpoint".
      1. PowerShell: Checkpoint-VM -Name "MyVM" -SnapshotName "TempExportCheckpoint"
    2. Run Your Export Script: Execute your existing C# code as-is. The export will now reference the state of the VM at the moment "TempExportCheckpoint" was created. The persistent lock is placed on the chain including this new checkpoint.
    3. Delete the Temporary Checkpoint: Immediately after the export is complete, delete the "TempExportCheckpoint".
      1. PowerShell: Remove-VMSnapshot -VMName "MyVM" -Name "TempExportCheckpoint"

    Because the export's lock was tied to the temporary checkpoint you just deleted, the lock is cleanly released from the running VM. Any other checkpoint deletions you perform after this will trigger their live merges correctly without any delay.

    I hope this information is helpful.


  2. Tharindu De Zoysa 0 Reputation points
    2025-08-07T16:25:54.78+00:00

    Hi Tim,

    Based on your description, you're experiencing an issue where checkpoint (AVHDX) files aren't automatically merging after deletion when using the ExportSystemDefinition method with your current settings.

    Root Cause Analysis

    The behavior you're seeing is expected with your current configuration because:

    1. You've set CopyVmStorage to false, which means the export isn't creating full copies of your VHDX files
    2. When you delete checkpoints after export, the merge operation requires exclusive access to the virtual disks
    3. The VM's running state prevents the merge from occurring immediately

    Recommended Solution

    Modify Export Settings

    Try adjusting your export settings to include storage:

    exportSettingData["CopyVmStorage"] = true; 
    

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.