Open ycanty opened 5 years ago
I would love to have this too. But maybe it can be an optional feature? TRIM might cause unexpected behavior down the line, especially since it changes the disk to appear to be an SSD. (which it might not be)
Sure, it could be an option. I don’t know Ruby much so adding an option is not trivial for me. I wouldn’t mind trying if first I could get this PR merged. :-)
However, I’m not sure an option would be that useful as in a VM the hardware is virtualized so as far as I know it doesn’t matter what the physical disk type actually is, the OS in the VM will think it’s an SSD and virtualbox will handle writing to the virtual hard disk, which is just a file on the real file system.
Well, using windows as an example, if the disk type is HDD, it will run defragmenter every week, if SSD, it will run TRIM. So it does change the behavior of the VM.
This allows to shrink the .vdi file on the host when disk space is reclaimed in the guest OS.
For some reason VirtualBox doesn't expose this feature on its GUI. It's only available in VBoxManage when attaching a virtual hard disk. So this plugin is the perfect place to enable this feature.
More information about this feature here: https://www.virtualbox.org/manual/ch08.html
Look at the
storageattach --discard
option.I've been using it for many months on my Ubuntu guest VMs with no ill side-effects.