5

I'm having a VM with a small Debian 7 server inside a VMware Player VM. The Disc has a maximum size of 55 GB, the virtual machine properties show a current size of 46.5 GB.

No other discs/volumes are mounted on the device, debian tells me the disc is only used for 16 GB, how can the actual vm disc file be almost 3x the size?!

root@websrv:~# df -hT
Filesystem                                             Type      Size  Used Avail Use% Mounted on
...
/dev/disk/by-uuid/ac9f2318-3e32-4b50-9178-20e5362013b0 ext4       48G   16G   30G  36% /
...

PS: The vm has no snapshots, just 2 network devices and nothing else configured, just a plain little webserver system.

Wad Cheber
  • 103
  • 2
peipst9lker
  • 173
  • 1
  • 6

2 Answers2

8

Any block on the virtual disk that you have ever used will count towards your VHD size, deleting files in the filesystem does not free the blocks in the VHD. There is no "TRIM" equivalent mechanism for virtual disk files.

noitsbecky
  • 606
  • 3
  • 13
  • 5
    Actually, TRIM *does* work under some circumstances. I regularly use fstrim on my KVM guests to keep the size of their VirtIO disk images under control. – thkala Jul 03 '15 at 22:15
7

The first reason is that maybe your VM's disk has been provisioned as "fixed size" or "thick provision", the variant that allocates the whole amount of disk space prior to formatting. The second variant (which is more likely) is that because formatting a disk in ext4 file system creates FS structures across entire disk, which causes VMware Player to allocate the whole space for the vdisk file. The most probable cause of allocating the entire size is the superblock location(s) in ext4, this file system duplicates its superblock in several places highly spaced throughout the disk, and VMware Player might not be able to support sparse VHDs, thus will allocate the entire size of the VHD on the disk.

About why the size is 48G and the VHD size is 55G - there are certain data structures in the ext4 file system that occupy raw disk space which is effectively reduced when you look at df output. To determine the actual size of a disk device from within your guest OS, use either solution from this question, either cat /proc/partitions or blockdev --getsize64 (device).

Vesper
  • 754
  • 1
  • 9
  • 29