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:-

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

Discuss This / Comments

comments

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..

    Thanks!

Leave a Reply

Set your Twitter account name in your settings to use the TwitterBar Section.