Hello,
I’m trying to compact customized Ubuntu 22.04 image but the resulting VHDX file size is still much bigger then it should be.

I have started with official Ubuntu image for Hyper-V, mounting it to another VM, chrooted into it and customize the kernel version, adding some default apps (vim, backup tools etc), resize the root partition from 12GB to 30GB, customize the policies and then just un-mount it. Original image has aprox. 6.2GB (2.3GB compressed with zip) and my image has 10-11GB (aprox 4.2GB zipped). Space used on root partition is 7GB so I have around 4GB floating around just taking up the space. I have tried “zeroing” the space and use Hyper-V compact without luck.

Any idea how to make Hyper-V to reclaim unused space and make the VHDX image smaller? I guess that creator of original image had to use some technique to trim the space used by image down… :thinking:

Thanks