I created initialized vagrant from ubuntu/trusty64 on Windows host. I realized newly created virtualbox's disk size is set to 40GB. I want to reduce this to at least 10GB. Is there any way to do this?
although right now actual size is 1.19GB i don't want it's virtual size to be this big.
thank you!
You can try to do it by
cat /dev/zero > /path/to/fill/z; sync; sleep 3; sync; rm -rf z
NOTE: Delete unwanted files within the VM before running the command above. If you have multiple partitions, logical volumes, do it on each of them.
VBoxManage modifyhd --compact /path/to/vdisk.vmdk
You'll see the progress, once finished, check its size.
Update:
If you want to resize the virtual disk, you should use VBoxManage modifyhd --resize <megabytes> /path/to/vdisk.vmdk
.
NOTE: The size of the virtual disk doesn't matter too much, it is just like a cap (max size) of the virtual disk image it can grow up to. By default the VMDK should be dynamically allocated, which mean the vmdk size will be close to the amount of data within the VM. The above method will help to reclaim spaces that has been freed up within the guest.
IMPORTANT: Growing the size of the vdisk is OK, but when reducing/shrinking you should be very careful, there is risk of losing data the new size < the actual data size within the vdisk.
On linux you can try using qemu-img resize filename [+|-]size
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With