0

I have an ubuntu 16.04 VM on a Server 2012 R2 Hyper-V server.

The VHDX (dynamically expanding VHD) size is 1.8TB but the VM inside reports that only 3% of the disk is used.

I don't understand why HV thinks that the disk is full. What can the be related to?

user2629636
  • 752
  • 5
  • 19
  • 38

3 Answers3

1

The virtual disk emulates any size you set for it, which is what the guest will report.

If physical storage backing it fills up, writes must stop or corruption is certain. Guest file system use does not necessarily indicate when this happens, due to deleted files or other writes to "free" space. This is a classic sparse file or thin provisioning problem.

John Mahowald
  • 30,009
  • 1
  • 17
  • 32
0

So here's what I tried, semi-successfully:

https://helgeklein.com/blog/2016/11/faster-trimming-compacting-hyper-v-ubuntu-vms/

sudo fstrim -v / -> On the VM

gci -File -Filter *.vhd* -Path D:\VMs -Recurse | % {Mount-VHD $_.FullName -ReadOnly; Optimize-VHD $_.FullName -Mode full; Dismount-VHD $_.FullName} --> On the HV Host

The VHDX sized went down by about 1.5 TB, which is great. But I can't let this happen all the time, there are several servers with the same/similar job and I don't see this behavior on any one of them. Will update later.

user2629636
  • 752
  • 5
  • 19
  • 38
  • Sorry, this is not an answer to your own question. You do not ask how to shrink it - but why it is so big. Totally different question. – TomTom Jul 21 '17 at 21:10
  • Chill out man, I wanted to share one possible fix if anybody searches for something similar. Did not even mark it as answer. – user2629636 Jul 22 '17 at 22:00
-1

Logic?

  • It was once full and the content got deleted.
  • The OS is allocating always new blocks (copy on write strategy) thus blowing up the VHDX size.
  • Someone ran some cleaning tool in the VM randomly overwriting the whole disc

Stuff like that.

Hyper-V does not think the disc is full. It allocates new blocks as they are written - and then does not care about them anymore at all. This is logically a small difference to actually tracking whether the disc is full or not.

TomTom
  • 50,857
  • 7
  • 52
  • 134
  • Yeah sorry about not giving more details. What you say makes sense and is how Hyper-V works but the VM is 1 week old and very lightly used if at all. There is no way 2 TB data has been written and deleted. By "hyper-v thinks the disk is full", I meant to say that the VHDX file exceeds the total storage of the physical volume it's on and setting the state of the machine to "paused-critical". – user2629636 Jul 21 '17 at 20:50
  • That is not thinks it is full - it is full. – TomTom Jul 21 '17 at 21:10