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



  1. Optimize-VHD
  2. Compact Linux guest virtual hard disk
Tagged with:

2 Responses to Compact a Linux vhdx for Hyper-V via PowerShell

  1. Brett says:

    Kimmy you are awesome! Huge +1! Finally a real working solution to the Linux compact VHDX issue..


Leave a Reply to Kimmy Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.