Hello!
I'm trying to figure out what exactly and when space reclamation kicks in on thin provisioning after removing file from debian 13 with qcow2 disk.
Setup:
- test system: Debian 13 (system installed on ext4)
- additional disk inside debian: 100 GB (.qcow2, partition inside system formated with ext4)
- VM's SCSI Controller: VirtIO SCSI single
- datastore: NFS 4.1 and NFS 4.2 (created from TrueNAS)
- QEMU Guest Agent: Disabled
- qcow2 option: discard=on
Test: 1
1. Create file with dd:
2. Check size of .qcow2 file from proxmox node side:
3. Check space on datastores from proxmox node side:
4. Delete test file:
5. Perform filesystem trim with (triggered multiple times - just to be sure):
(at that point system says, it managed to trim the space ~10 GiBs)
6. Check again .qcow2 file from proxmox node side:
7. Check again space on datastores from proxmox node side:
Result:
No changes in terms of size of .qcow2 file or from datastore point of view. In general, size of that virtual disk should go down to just a few MiBs which is NOT happening.
... as additional:
8. Migrate test virtual disk to different datastore:
Result:
Again nothing...
Above test has been performed on NFS version 3, version 4.1 and version 4.2 and virtual disks have been moved around several times.
... as additional:
9. Enable QEMU Guest Agent in VM's "Options"
10. Perform fstrim -av
11. Migrate test virtual disk to different datastore
Result:
Finally - size of the virtual disk went down to few MiBs.
The best part starts now - after recreating the file with dd inside debian, removing it again, performing fstrim and migrating VM's disk to different datastore, this time, space reclamation hasn't kicked in - and I've reply that test multiple times.
I was also NOT able to reclaim that space after deleting the test file WITHOUT moving virtual disk to different datastore - which from operational point of view is NOT the best scenario - we cannot ask users to inform us everytime they delete something from insidie of the system so that we could move VM around, to reclaim the space on datastore.
Sometimes that space reclamation works but somtimes it doesn't.
... as additional:
12. After enabling QEMU Guest Agent and deleting the test file from inside of the debian, I've tried to run "qm guest cmd 102 fstrim" but that doesn't help.
In the end, I've managed to reclaim that space from datastore point of view, but it is NOT predictable of how to do it.
Q:
Do I have to move VM's disk to reclaim that space every time?
Q:
Is it possible to reclaim that space without moving VM's disk?
I'm trying to figure out what exactly and when space reclamation kicks in on thin provisioning after removing file from debian 13 with qcow2 disk.
Setup:
- test system: Debian 13 (system installed on ext4)
- additional disk inside debian: 100 GB (.qcow2, partition inside system formated with ext4)
- VM's SCSI Controller: VirtIO SCSI single
- datastore: NFS 4.1 and NFS 4.2 (created from TrueNAS)
- QEMU Guest Agent: Disabled
- qcow2 option: discard=on
Test: 1
1. Create file with dd:
Code:
dd if=/dev/urandom of=thick_test_random.img bs=1M count=10000 status=progress
2. Check size of .qcow2 file from proxmox node side:
Code:
qemu-img info vm-102-disk-1.qcow2
3. Check space on datastores from proxmox node side:
Code:
pvesm status
4. Delete test file:
Code:
rm thick_test_random.img
5. Perform filesystem trim with (triggered multiple times - just to be sure):
Code:
fstrim -av
(at that point system says, it managed to trim the space ~10 GiBs)
6. Check again .qcow2 file from proxmox node side:
Code:
qemu-img info vm-102-disk-1.qcow2
7. Check again space on datastores from proxmox node side:
Code:
pvesm status
Result:
No changes in terms of size of .qcow2 file or from datastore point of view. In general, size of that virtual disk should go down to just a few MiBs which is NOT happening.
... as additional:
8. Migrate test virtual disk to different datastore:
Code:
qm move-disk 102 scsi1 <TARGET_DATASTORE> --format qcow2 --delete
Result:
Again nothing...
Above test has been performed on NFS version 3, version 4.1 and version 4.2 and virtual disks have been moved around several times.
... as additional:
9. Enable QEMU Guest Agent in VM's "Options"
10. Perform fstrim -av
11. Migrate test virtual disk to different datastore
Result:
Finally - size of the virtual disk went down to few MiBs.
The best part starts now - after recreating the file with dd inside debian, removing it again, performing fstrim and migrating VM's disk to different datastore, this time, space reclamation hasn't kicked in - and I've reply that test multiple times.
I was also NOT able to reclaim that space after deleting the test file WITHOUT moving virtual disk to different datastore - which from operational point of view is NOT the best scenario - we cannot ask users to inform us everytime they delete something from insidie of the system so that we could move VM around, to reclaim the space on datastore.
Sometimes that space reclamation works but somtimes it doesn't.
... as additional:
12. After enabling QEMU Guest Agent and deleting the test file from inside of the debian, I've tried to run "qm guest cmd 102 fstrim" but that doesn't help.
In the end, I've managed to reclaim that space from datastore point of view, but it is NOT predictable of how to do it.
Q:
Do I have to move VM's disk to reclaim that space every time?
Q:
Is it possible to reclaim that space without moving VM's disk?
Last edited: