virtual machine hd size

rafafell

Renowned Member
Sep 24, 2016
64
2
73
38
Hi,

When I delete HD data from the virtual machine, the raw/qcow2 file does not reduce, correct? Is there any way you can do this?

For example,
(1) I created the virtual machine and put a HD 500 GB, the qcow2 file appeared with 50 MB - OK
(2) then I put 100 GB (data) and the qcow2 file appeared with 100 GB - OK
(3) then I deleted the 100 GB, but the qcow2 file kept the size of 100 GB - (??)

(??) - Is there any way to get back to seeing the 50 MB and keeping the HD limit at 500 GB?
 
How do I leave default by linux: When deleting files or directories to zero out your disk for any user?

If multiple users put and delete files in different places it will be difficult to use dd and rm



Thanks!
 
You need to mount the disk in Linux with discard, this can be set in the fstab file.

Then the VM will automatically call a fstrim on any delete/change command, however this is a high overhead to this, hence it is best left with a weekly cronjob as built into most Linux OS's.