Compact a Linux vhdx for Hyper-V via PowerShell
To compact a vhdx file via command line (PowerShell) > mount-VHD -Path c:\VM\virtual_machine.vhdx -ReadOnly > optimize-VHD -Path c:\VM\virtual_machine.vhdx -Mode Full > dismount-VHD -Path c:\VM\virtual_machine.vhdx References:- Optimize-VHD Compact Linux guest virtual hard disk