sprotheroe / vagrant-disksize

Vagrant plugin to resize disks in VirtualBox
MIT License
478 stars 51 forks source link

Re-attach resized disk with SSD TRIM feature enabled. #28

Open ycanty opened 5 years ago

ycanty commented 5 years ago

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.

noaho commented 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)

ycanty commented 5 years ago

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.

noaho commented 5 years ago

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.