Inside the VM (VM ID: 4006), the storage usage appears to be only 48GB when using the ‘df -h’ command.
However, in OpenNebula, the VM storage usage is reported as 263GB.
I’ve checked the OpenNebula sunstone console and verified that the host datastore also shows the VM disk size as 263GB.
Why is this happening, and how can I resolve this discrepancy?
Any insights or suggestions would be greatly appreciated!
Thanks in advance!
TL;DR: Generally you should research what is trim/discard and is your setup capable of handling it.
Most probably the data discarded by the guest filesystem is not propagated to the storage on the host.
There are several things that should be stacked to achieve space reduction on the storage:
- Discards enabled for the VM disks in the VM configuration
- Use virtio disk type that support discards. The propagation of the discards for the virtio-block backend (the /dev/vd* disks) is relatively a “new thing” so maybe not yet supported by the packages provided by the OS distribution. The virtio-scsi backend works.
- the filesystem in the guest OS should be configured to issue discards to the storage layer
So, you should check/research:
? Are the VM instances having a configuration that support discards?
? Is your storage supporting discard calls?
? Inside the VM(s) - is the filesystem mounted to issue discards to the disks -or- are there periodic discards trggered by a timer?
Hope this helps,
Thanks for your reply in detail, Anton.
Could you please suggest how to check
- if discards are enabled for the VM disks in the VM configuration?
- If not enabled, then how to enable it?
disk must be qcow2 format to support trim
1st you must enable discard on opennebula
<qemu:commandline> <qemu:arg value='-set'/> <qemu:arg value='device.virtio-disk0.discard_granularity=512'/> </qemu:commandline>
2nd. check if it is enabled inside vm by running command
if you received something like this - it is enabled
NAME DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO
vda 0 512B 2G 0
3rd - turn on discard on fs inside VM in file
discard option. reboot vm.
PS. to force trim right now run command