Skip to main content

Merge AVHDX Hyper-V Checkpoints

When you create a snapshot of a virtual machine in Microsoft Hyper-V, a new file is created with the .avhdx file extension. The name of the file begins with the name of its parent VHDX file, but it also has a GUID following that, uniquely representing that checkpoint (sometimes called snapshots). You can see an example of this in the Windows Explorer screenshot below.
Windows Explorer - VHDX AVHDX File
Creating lots of snapshots will result in many .avhdx files, which can quickly become unmanageable. Consequently, you might want to merge these files together. If you want to merge the .avhdx file with its parent .vhdx file, it’s quite easy to accomplish.

PowerShell Method

Windows 10 includes support for a Merge-VHD PowerShell command, which is incredibly easy to use. In fact, you don’t even need to be running PowerShell “as Administrator” in order to merge VHDX files that you have access to. All you need to do is call Merge-VHD with the -Path parameter, pointing to the .avhdx file, and the -DestinationPath parameter pointing to its parent .vhdx file.
Here’s a simple example that uses PowerShell Splatting [YouTube] to pass in parameters to the Merge-VHD command:
$Merge = @{
  Path = 'c:\artofshell\client01_670A3C15-3E10-425E-A60E-A6F93DF13E20.avhdx'
  DestinationPath = 'c:\artofshell\client01.vhdx'
}
Merge-VHD @Merge
If you don’t have the Merge-VHD command available, you might receive an error message similar to the following:
Merge-VHD : The term 'Merge-VHD' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
If you get this error message, then you’ll need to install the Hyper-V PowerShell module that’s included with Windows 10. To install this module, simply launch an elevated PowerShell session, and run this command:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-Management-PowerShell
After installing the Hyper-V PowerShell module, go back and run the Merge-VHD command again.

Hyper-V Console Method

You can also use the Hyper-V console in Windows 10 to perform the merge operation. The first thing you’ll want to do is open the Hyper-V console. Next, right-click the Hyper-V host and click Edit Disk.
Hyper-V Console - Edit Disk

After clicking Edit Disk, you’ll be presented with a wizard, where you’ll point Hyper-V to the .avhdx file that you want to merge.
IMPORTANT: Select the .avhdx file, and not the .vhdx file, otherwise you won’t see the Merge operation available!
Hyper-V Edit Disk - Locate Virtual Hard Disk

On the next wizard screen, select the Merge action.
Hyper-V Edit Disk - Merge Action

Next, you’ll need to choose the destination for the merge operation. In most cases, you’ll choose the To the parent virtual hard disk option.
Hyper-V Edit Disk - Select Parent
Finally, on the Summary page of the disk editing wizard, just complete the wizard, and it will merge your disks for you. That’s all there is to it!
Hyper-V Edit Disk - Complete Wizard

Comments

Popular posts from this blog

Zabbix, AWS and Auto Registration

One of the things I love the most with AWS is  auto-scaling . You choose an AMI, set some parameters and AWS will spin instances up and down whenever a threshold is breached. But with all these instances spinning up and down there are some unknowns. For example, what is the IP address of the new instance? Its host name? This can be critical when other components of your infrastructure are dependent on knowing these parameters. I had this problem when I started to use  Zabbix  as the monitoring system. At first it seemed like a complicated one, but Zabbix has a wonderful feature called  Auto Registration  which can be used exactly for this situation. I will try to show how to configure auto registration both on the client (EC2 instance running Ubuntu 14.04) and on the Zabbix server (Zabbix Server 2.4.2). Zabbix-agent Installation and Configuration Let’s start with installing zabbix-agent on the Ubuntu client: 1 2 $ sudo apt-get update $ sud...

SIPp cheatsheet

SIPp  is a free test tool and traffic generator for the SIP protocol. It uses XML format files to define test scenarios. General usage: sipp remote_host[:remote_port] [options] Some important command-line options: -sf filename Load test scenario from specified file. -inf filename Use CSV file to insert data substituted for [field0], [field1], etc into XML scenario. First line of file describes order of inserting field sets (SEQUENTIAL/RANDOM/USE). -sn name Use one of the embedded, predefined scenarios like "uac", "uas". -r rate Scenario execution rate, default value = 10 times per period, default period = 1000 ms. -rp period Scenario execution period [ms], combined with execution rate. Execution rate is combined of rate and period parameters, i.e. if period = 3500 and rate = 7 there will be 7 calls in 3.5 s. -t transport mode Set the transport mode: "u1" - UDP, one socket (default), "un" - UDP, one socket per call, other modes (...