VM Disk space usage much larger in ZFS (without snaphots)

domsl

Member
May 4, 2021
3
1
8
33
Hi,

First of all, thank you for proxmox. I am learning to self host services with VMs in proxmox and it has been great so far.

Right now, I was wondering why my VM disks take up so much space in ZFS?
Much more than I would have expected with "normal" overhead.

For example lets take my VM 100:
Code:
root@xxx:~# qm config 100
boot: order=scsi0;net0
cores: 4
memory: 8046
name: fred
net0: virtio=FA:3D:FB:43:C3:72,bridge=vmbr0,firewall=1
numa: 0
ostype: l26
parent: second_snapshot
scsi0: local-zfs:vm-100-disk-0,size=100G
scsi1: local-zfs:vm-100-disk-2,size=200G
scsi2: entropool:vm-100-disk-0,backup=0,size=900G
scsihw: virtio-scsi-pci
smbios1: uuid=13102444-19d4-4767-9892-d6bb285cd69c
sockets: 1
usb0: host=1cf1:0030,usb3=1
vmgenid: 9f3c4148-40cc-463a-aaa0-3ef9c4c302fc

The second vm-100 disk lives on another zfs mirror than rpool:
Code:
root@xxx:~# zpool status -v
  pool: entropool
 state: ONLINE
  scan: scrub repaired 0B in 00:16:58 with 0 errors on Sun Jun 13 00:40:59 2021
config:

        NAME                                                STATE     READ WRITE CKSUM
        entropool                                           ONLINE       0     0     0
          mirror-0                                          ONLINE       0     0     0
            nvme-SAMSUNG_MZVLB1T0HBLR-00000_S4GJNF0N111967  ONLINE       0     0     0
            nvme-SAMSUNG_MZVLB1T0HBLR-00000_S4GJNF0N111971  ONLINE       0     0     0

errors: No known data errors

  pool: rpool
 state: ONLINE
  scan: scrub repaired 0B in 00:09:33 with 0 errors on Sun Jun 13 00:33:36 2021
config:

        NAME                                 STATE     READ WRITE CKSUM
        rpool                                ONLINE       0     0     0
          mirror-0                           ONLINE       0     0     0
            nvme-eui.0025388101b98f77-part3  ONLINE       0     0     0
            nvme-eui.0025388101b98fd0-part3  ONLINE       0     0     0

If I log into VM 100 (an Ubuntu server) and use du -hs I get
Code:
dom@fred:/mnt/entrodata$ du -hs
du: cannot read directory './lost+found': Permission denied
293G

But when I look at the zfs dataset at the host:
Code:
root@xxx:~# zfs list -o space,lused,refer,lrefer,compressratio
NAME                                    AVAIL   USED  USEDSNAP  USEDDS  USEDREFRESERV  USEDCHILD  LUSED     REFER  LREFER  RATIO
entropool                                294G   628G        0B     96K             0B       628G   653G       96K     42K  1.04x
entropool/vm-100-disk-0                  294G   616G      967M    615G             0B         0B   638G      615G    636G  1.04x
entropool/vm-100-state-first_snapshot    294G  6.59G        0B   6.59G             0B         0B  7.65G     6.59G   7.65G  1.16x
entropool/vm-100-state-second_snapshot   294G  5.63G        0B   5.63G             0B         0B  7.59G     5.63G   7.59G  1.35x
rpool                                    649G   273G        0B     96K             0B       273G   288G       96K     42K  1.06x
rpool/ROOT                               649G  2.96G        0B     96K             0B      2.96G  4.63G       96K     42K  1.64x
rpool/ROOT/pve-1                         649G  2.96G        0B   2.96G             0B         0B  4.63G     2.96G   4.63G  1.64x
rpool/data                               649G   270G        0B     96K             0B       270G   284G       96K     42K  1.05x
rpool/data/vm-100-disk-0                 649G  28.6G     6.81G   21.8G             0B         0B  34.2G     21.8G   26.2G  1.20x
rpool/data/vm-100-disk-2                 649G   167G     56.1G    111G             0B         0B   167G      111G    111G  1.00x
rpool/data/vm-120-disk-0                 649G  67.3G     26.4G   40.8G             0B         0B  74.4G     40.8G   45.7G  1.11x
rpool/data/vm-120-state-first_snapshot   649G  6.69G        0B   6.69G             0B         0B  8.32G     6.69G   8.32G  1.25x

615Gb is much more than I expected.

What is causing this? Perhaps I misconfigured the volblocksize?

Code:
root@xxx:~#  zfs get all entropool/vm-100-disk-0| sort
entropool/vm-100-disk-0  available             294G                   -
entropool/vm-100-disk-0  checksum              on                     default
entropool/vm-100-disk-0  compression           on                     inherited from entropool
entropool/vm-100-disk-0  compressratio         1.04x                  -
entropool/vm-100-disk-0  context               none                   default
entropool/vm-100-disk-0  copies                1                      default
entropool/vm-100-disk-0  createtxg             118                    -
entropool/vm-100-disk-0  creation              Wed Mar 10 18:43 2021  -
entropool/vm-100-disk-0  dedup                 off                    default
entropool/vm-100-disk-0  defcontext            none                   default
entropool/vm-100-disk-0  encryption            off                    default
entropool/vm-100-disk-0  fscontext             none                   default
entropool/vm-100-disk-0  guid                  11203998311705026805   -
entropool/vm-100-disk-0  keyformat             none                   default
entropool/vm-100-disk-0  keylocation           none                   default
entropool/vm-100-disk-0  logbias               latency                default
entropool/vm-100-disk-0  logicalreferenced     636G                   -
entropool/vm-100-disk-0  logicalused           638G                   -
entropool/vm-100-disk-0  mlslabel              none                   default
entropool/vm-100-disk-0  objsetid              139                    -
entropool/vm-100-disk-0  pbkdf2iters           0                      default
entropool/vm-100-disk-0  primarycache          all                    default
entropool/vm-100-disk-0  readonly              off                    default
entropool/vm-100-disk-0  redundant_metadata    all                    default
entropool/vm-100-disk-0  refcompressratio      1.03x                  -
entropool/vm-100-disk-0  referenced            615G                   -
entropool/vm-100-disk-0  refreservation        none                   default
entropool/vm-100-disk-0  reservation           none                   default
entropool/vm-100-disk-0  rootcontext           none                   default
entropool/vm-100-disk-0  secondarycache        all                    default
entropool/vm-100-disk-0  snapdev               hidden                 default
entropool/vm-100-disk-0  snapshot_count        none                   default
entropool/vm-100-disk-0  snapshot_limit        none                   default
entropool/vm-100-disk-0  sync                  standard               default
entropool/vm-100-disk-0  type                  volume                 -
entropool/vm-100-disk-0  used                  616G                   -
entropool/vm-100-disk-0  usedbychildren        0B                     -
entropool/vm-100-disk-0  usedbydataset         615G                   -
entropool/vm-100-disk-0  usedbyrefreservation  0B                     -
entropool/vm-100-disk-0  usedbysnapshots       967M                   -
entropool/vm-100-disk-0  volblocksize          8K                     default
entropool/vm-100-disk-0  volmode               default                default
entropool/vm-100-disk-0  volsize               900G                   local
entropool/vm-100-disk-0  written               344G                   -
NAME                     PROPERTY              VALUE                  SOURCE

Could anyone help me understand this better? Or point me in the direction, so I can read up on this?
I have been reading up in the forum (that's why I knew the posted outputs above might me helpful), but I did not know if previous posts applied to my situation.

I am quite new to VMs and zfs, so any help would be much appreciated :)
 
Based on the following output and the VM config I'd assume you just have to enable `discard` on the disk and run a TRIM in the VM.
Code:
entropool/vm-100-disk-0  used                  616G                   -
entropool/vm-100-disk-0  usedbydataset         615G                   -
entropool/vm-100-disk-0  written               344G                   -