Windows Server: Resolve VHDX Shrink Issue

Windows Server

As you probably know, starting Windows Server 2012 it’s possible made hot shrink of VHDX disks, also for Operating System in case you have configured the virtual machine in Generation 2. For those that don’t know what is it Shrink, is the possibility to reduce the volume space to optimize resource, in particular when there is an over-dimension.

 

Sometime can happen that this operation not working fine. In my case I’ve a virtual machine, based on Windows Server 2016, with 26GB occupied, as showed in figure 1, but the VHDX file was over 70GB, as showed in figure 2.

 

2016_11_27_vhdx-01

Figure 1 – Virtual Volume

 

2016_11_27_vhdx-02

Figure 2 – VHDX File

 

I tried the procedure many times without success, checked the procedure twice. What happened? Probably there was some block locked at the end of VHDX, that deny the reallocation and the right shrink to optimize the space. To resolve the issue, I mounted the VHDX from my hypervisor, in Read-Only, as showed in figure 3.

 

2016_11_27_vhdx-03

Figure 3 – VHDX Mount

 

After the dismount, I re-run the Shrink and the result is the right one, as showed in figure 4.

 

2016_11_27_vhdx-04

Figure 4 – VHDX After Shrink

Easy, right?

S