容量可変タイプの Hyper-V 仮想ディスク を最適化(圧縮)する方法のメモ。
手順
- PowerShell を管理者で起動。
- 次のコマンドを順番に実行。
PS> $targetvhd = "VHD(X)のフルパス"
PS> Mount-VHD $targetvhd -Readonly
PS> Optimize-VHD $targetvhd -Mode Quick
PS> Optimize-VHD $targetvhd -Mode Quick
PS> Dismount-VHD $targetvhd
メモ
- 事前準備は不要。
- Optimize-VHD コマンドを2回実行するといいらしい。
- 圧縮されないから手順や環境に間違いがあると思ってた・・・。