ThisCalculator

Everyday

VM Storage Usage: How to Check Real Used Space

Updated · Standard formula, shown below

VM Storage Usage: How to Check Real Used Space

This guide explains how to find out how much storage a virtual machine (VM) is actually using, as opposed to the size of its virtual disk file or the amount allocated to it. You’ll learn to check from inside the guest OS and from the hypervisor, and how to interpret the numbers you see. No special tools are required beyond standard OS commands and a basic understanding of your hypervisor.

What You’ll Need

  • Access to the VM (either console or SSH/RDP).
  • Administrator or root privileges on the guest OS.
  • Access to the hypervisor management interface (e.g., vSphere, Hyper-V Manager, Proxmox, or command-line tools).

Step-by-Step

  1. Check from inside the guest OS (most accurate). The guest OS knows exactly which files are on disk and how much space they occupy. This is the number that matters for capacity planning.

    • Windows: Open File Explorer, right-click the drive (e.g., C:), and select Properties. The “Used space” and “Free space” shown are the real usage. Alternatively, run fsutil volume diskfree C: in an elevated Command Prompt for a scriptable output.
    • Linux: Run df -h in a terminal. The Used column shows actual space used on each mounted filesystem. For a more detailed breakdown, use du -sh /* to see which directories consume the most.
    • macOS (if VM): Use df -h in Terminal, or About This Mac > Storage.
  2. Compare with the virtual disk file size on the host. The VM’s disk is stored as a file (or set of files) on the hypervisor. Its size can be larger than the used space inside the guest, especially if the disk is thick-provisioned (allocated fully upfront) or if deleted files haven’t been reclaimed.

    • vSphere: In the VM’s summary, look at “Provisioned Storage” and “Used Storage”. The used storage is the actual space the disk file consumes on the datastore.
    • Hyper-V: In Hyper-V Manager, right-click the VM and select Settings, then choose a hard drive. The Virtual hard disk file shows the path and size. The file size may be smaller than the max size if it’s dynamically expanding.
    • Proxmox: In the VM’s Hardware tab, note the disk size. Then on the host shell, run qemu-img info /path/to/disk.qcow2 to see the actual disk usage (the disk size field).
  3. Understand thin vs. thick provisioning. If the disk is thin-provisioned, the file size on the host grows as data is written. If it’s thick-provisioned, the file size equals the maximum size from the start, even if the guest uses only a fraction. This explains why the host file size might be much larger than the guest’s used space.

  4. Reclaim unused space (if needed). If you deleted files inside the guest but the host file didn’t shrink, the space is still marked as used by the hypervisor. To reclaim it:

    • Windows guest: Run Optimize-VHD -Path C:\path\to\disk.vhdx -Mode Full on the Hyper-V host (for VHDX). For VMware, use the vSphere Web Client to run “Storage vMotion” or use the vmkfstools -K command to punch zeroes.
    • Linux guest: Use fstrim -a (if the filesystem supports TRIM) or write zeros to free space with dd if=/dev/zero of=/tmp/zero bs=1M then delete the file. After that, the hypervisor can reclaim the space (often requires a storage vMotion or compaction).
  5. Check snapshots. Snapshots can consume significant storage. In the hypervisor, list snapshots and their sizes. Deleting old snapshots often frees space, but note that deleting a snapshot consolidates changes and may temporarily increase usage.

Common Mistakes

  • Confusing provisioned size with used size. The “disk size” shown in VM settings is the maximum, not the actual usage.
  • Ignoring swap files or pagefiles. These are counted as used space inside the guest, but they may not be essential to reclaim if you need space on the host.
  • Assuming the host file size equals guest usage. Thick provisioning and snapshots make them differ.
  • Not accounting for filesystem overhead. The guest OS shows used space, but filesystems have metadata overhead, so the actual bytes on disk might be slightly higher.
  • Forgetting to run TRIM/zeroing before checking host reclaim. Without it, the hypervisor still sees deleted blocks as allocated.

Tips

  • Use the guest OS’s own reporting as the authoritative source for application-level capacity planning. The host-level numbers are for infrastructure management.
  • Monitor both metrics over time. If guest usage stays flat but host usage grows, snapshots or log files may be the culprit.
  • For Linux guests, df shows used blocks, but du shows apparent size. Use du --apparent-size to see the logical size if you need to compare with file sizes.
  • If you’re using dynamic disks, periodically compact them after large deletions. In Hyper-V, use Optimize-VHD; in VMware, use vmkfstools -K or storage vMotion.
  • Set up alerts on both guest disk usage and host datastore usage to avoid surprises.

Troubleshooting

  • Host shows more usage than guest. Check for snapshots, thick provisioning, or a large swap file. If the guest is Windows, ensure you’ve run Optimize-VHD or the VMware equivalent after deleting files.
  • Host shows less usage than guest. This can happen if the disk is thin and the guest is using compressed or sparse files. It’s normal; the host file only stores actual allocated blocks.
  • Cannot run df or fsutil due to permissions. Use sudo or an elevated prompt. If you don’t have admin access, you can still see used space in the GUI (e.g., File Explorer or GNOME Disks).
  • Snapshot deletion fails or doesn’t free space. Ensure the VM is powered off or that you have enough free space on the datastore to perform the consolidation. Sometimes a storage vMotion is required.
  • TRIM doesn’t seem to work. Verify the filesystem is mounted with the discard option or run fstrim manually. Some hypervisors require the guest to have the latest tools installed (e.g., open-vm-tools).

Frequently Asked Questions

Q: Why is my VM’s virtual disk file larger than the used space inside the guest?
A: The disk may be thick-provisioned (allocated fully upfront), or you may have snapshots. Also, deleted files inside the guest don’t automatically shrink the host file unless you reclaim space (e.g., TRIM or zeroing).

Q: How do I see the actual storage usage of a VM in VMware vSphere?
A: In the VM’s Summary tab, look for “Provisioned Storage” and “Used Storage”. The used storage is the actual space on the datastore. You can also use vmkfstools -P /vmfs/volumes/.../disk.vmdk from the ESXi shell.

Q: Does the guest OS’s “Used Space” include swap files?
A: Yes, the guest OS counts all files on the filesystem, including swap files and pagefiles. If you want to know how much space your applications use, exclude those files.

Q: How can I shrink a virtual disk to free up host storage?
A: First, delete unnecessary files inside the guest. Then, zero out free space (on Linux use fstrim or dd; on Windows use sdelete -z). Finally, on the hypervisor, compact the disk: Hyper-V’s Optimize-VHD, VMware’s vmkfstools -K, or Proxmox’s qemu-img convert.

Q: What is the difference between used space and provisioned space?
A: Provisioned space is the maximum size the disk can grow to (as set in VM settings). Used space is the actual amount of storage the disk file occupies on the host, which can be less (thin) or equal (thick) to the provisioned size.

Q: Can I rely on the guest OS’s reported free space for capacity planning?
A: Yes, for application-level planning. However, always leave headroom for snapshots, swap, and filesystem overhead. It’s wise to monitor both guest and host metrics.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.