[SOLVED] VM disk usage discrepancy between host and guest

mikeboiko

Member
Feb 10, 2020
5
0
21
35
Hi everybody,

My proxmox host shows that I have used much more disk space than when I check from within the VM. I'm hoping somebody has an easy fix for this issue.

PVE host shows 81% disk usage for VM-103:
Code:
root@pve:~# lvs
  LV            VG  Attr       LSize    Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  data          pve twi-aotz-- <795.77g             60.81  3.18
  root          pve -wi-ao----   96.00g
  swap          pve -wi-ao----    7.00g
  vm-103-disk-0 pve Vwi-aotz--  600.00g data        80.65

Within VM-103 - only 28% disk usage on /dev/sda1:
Code:
╭─mike@backup ~
╰─➤  df -h
Filesystem      Size  Used Avail Use% Mounted on
dev             2.7G     0  2.7G   0% /dev
run             2.7G  664K  2.7G   1% /run
/dev/sda1       591G  156G  411G  28% /
tmpfs           2.7G     0  2.7G   0% /dev/shm
tmpfs           4.0M     0  4.0M   0% /sys/fs/cgroup
tmpfs           2.7G     0  2.7G   0% /tmp
tmpfs           544M     0  544M   0% /run/user/1000

I should also mention that I'm using local-lvm storage in Proxmox.

Thanks!
Mike
 
Last edited:
Hi,
do you have the discard option set on your disk? You'll also need to run fstrim in the guest to reclaim the free space. See here for more information.
 
  • Like
Reactions: mikeboiko
Hi Fabian,

Yep, this solved my problem! For anybody else reading this post, I will provide my exact steps:

1. I shutdown the guest VM
2. From the Proxmox web interface, I checked the Discard checkbox. It is unchecked by default.
1605551395812.png
3. I started the VM and ran the following command on the guest
Code:
╭─mike@backup ~
╰─➤  sudo fstrim -av
/: 430.3 GiB (462063333376 bytes) trimmed on /dev/sda1
4. Now, when I check the disk usage on the host - it matches the disk usage on the guest
Code:
root@pve:/var/lib/vz# lvs
  LV            VG  Attr       LSize    Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  data          pve twi-aotz-- <795.77g             21.30  1.27                       
  root          pve -wi-ao----   96.00g                                               
  swap          pve -wi-ao----    7.00g                                               
  vm-103-disk-0 pve Vwi-aotz--  600.00g data        28.25

Now, I will just need to set up either periodic or continues trimming on the guest. A good reference in the arch wiki: https://wiki.archlinux.org/index.php/Solid_state_drive#Continuous_TRIM

Thank you so much for your help!
Mike