Linux VHDX size on Hyper-V
Asked Answered
I

1

0

I use Hyper-V on Windows 2016 Server and the problem is with size of Linux Virtual Machine's VHDX files. They are growing up in light speed. For instance I have Linux Mint and In Disk Usage Utility I see 125,4 GB available/133,7 GB total. The vhdx file is 40GB.

What I tried: - shrink in Hyper-V, - use e4defrag in VM, - use dd if=/dev/zero of=wipefile bs=1M; sync; rm wipefile in VM.

After above instead 39GB I have 40GB. Any suggestions? What should I do?

Iives answered 28/2, 2020 at 8:17 Comment(0)
I
3

After couple of hours I found the solution.

  1. First login to your guest OS (in my case Linux Mint) and clean the filesystem (delete cache/thumbnails files, apt-get clean, etc.).
  2. Run these commands: cat /dev/zero > zero.file sync rm zero.file
  3. Shutdown the machine.

  4. Open command prompt on Hyper-V machine and type: diskpart select vdisk file="D:\Hyper-V\somedisk.vhdx" attach vdisk readonly compact vdisk detach vdisk exit Voila! The VHDX file is reduced in my case from 40GB to 18GB.

Iives answered 28/2, 2020 at 10:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.