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

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

2 thoughts on “Compact a Linux vhdx for Hyper-V via PowerShell”

Leave a Reply

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