I'm using a vagrant with virtualbox for my development environment but the disk size grows in size for no reason. When I first create the box and provision it, the disk size is about 4GB but after 3 months of use, the disk size is about 18GB even I didn't install anything new all that time. I just can't explain what takes all those gigs.
Any idea why this happens or any solution? Having multiple boxes just eats up a lot of my disk space for no reason.
Thanks!
VirtualBox is basically inception for your computer. You can use VirtualBox to run entire sandboxed operating systems within your own computer. Vagrant is software that is used to manage a development environment.
Getting Started With Vagrant Before you start, make sure you already have a virtualization solution on your system. Solutions that work with Vagrant include VirtualBox, VMware, Docker, Hyper-V, and custom solutions.
The first thing you would need to do is to check how much space is really consumed in your VM. VirtualBox (as well as VMWare) uses dynamic size allocation so they will grow your file size when needed but they never free up the space unless you specifically ask for it.
run df -m
to check how much space is really used by each partition, if you believe a partition has too much space, go on the mount point and clean some files.
save space of unallocated block on the VM
$ dd if=/dev/zero of=/EMPTY bs=1M || echo "dd exit code $? is suppressed"
$ rm -f /EMPTY
now back on your host, you will need to claim the free space
$ VBoxManage modifyhd <name>.vdi --compact
This option runs only for vdi
format, if you have vmdk
you will need to convert into vdi
first
$ VBoxManage clonehd <name>.vmdk <name>.vdi --format vdi
$ VBoxManage modifyhd <name>.vdi --compact
$ rm <name>.vmdk
$ VBoxManage clonehd <name>.vdi <name>.vmdk --format vmdk
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