Skip to content

Modify and adjust VHD/VHDX virtual disk size

Original link: https://www.itylq.com/resize-vhd-vhdx-virtual-files.html

Release date: 2023-08-25 Migration time: 2026-03-21

Due to early planning, we often face the embarrassing situation that the VHD/VHDX virtual disk capacity is set too large or not enough. How to adjust the VHD/VHDX virtual disk size and capacity? This article briefly records how to use third-party tools to make modifications.

1 Increase the VHD/VHDX virtual disk capacity

It is relatively simple to increase the capacity, just use the Bootice tool.

Double-click to open Bootice, switch to the "Disk Image" menu, load the target VHD/VHDX file, click "VHD File Information", "Reset Capacity (Expand/Reduce)...", and enter the adjusted capacity size in "New Capacity".

2 VHD/VHDX virtual disk capacity reduction/compression

According to the Bootice tool menu interface, it is theoretically supported to reduce or compress the VHD/VHDX file size, but in actual operation, there will be a risk warning that the data may be truncated (Failed to resize vhd: The requested resize operation cannot be completed because it may truncate the user data located on the virtual disk), see Figure 2 below.

Why might data be truncated? It turns out that the data written to the VHD/VHDX virtual disk file is not strictly sorted by the storage address increment, and a small number of files may fill the entire virtual disk space. By default, the capacity compression of the Bootice tool starts from the end of the storage space, so there is a risk that some disordered and scattered small files will be completely erased. Such an unsafe operation is not recommended.

Therefore, if you want to compress/reduce the size of the VHD/VHDX virtual disk file, you need to use a clumsy way to work around it: Create a new blank VHD/VHDX virtual disk file of suitable capacity, then load the VHD, and use disk management tools such as AOMEI Assistant and Diskgenius to clone the hard disk/copy the data, as shown in Figure 3 below:

3 more

In addition to resizing the VHD/VHDX virtual disk through third-party tools, you can also use the resize command directly in the powershell command line tool. However, you need to enable the hyper-v function first and then install some components, which may be a little complicated. . .

Resize VHD/VHDX files to specified size:

Resize -VHD -Path ‘D:\XXX.vhdx’ -SizeBytes 60GB

Automatically compress VHD/VHDX file size:

Resize -VHD -Path ‘D:\XXX.vhdx’ -ToMinimumSize


This article was moved from WordPress to MkDocs