I’m preparing Ubuntu image for the course. After installation of required software and datasets, the system image grew a lot. I have decided to shrink its size by disabling swap and removing unused data. But the system image didn’t shrink automatically after removal of the files. You need to do it manually:
- Run your system from LiveCD
- Install zerofree and free unused space
- In the host system, release and remove the image from VirtualBox (but keep it in the filesystem!)
- And compact image size
- Finally, you will have to add .vdi image back to VirtualBox machine.
sudo apt-get install zerofree # 10min sudo zerofree -v /dev/sda1
VBoxManage modifyhd Ubuntu1404/Ubuntu1404.vdi --compact</code>
In my case, the .vdi image shrunk from 7.2G to 6.2G (exactly the released size under Ubuntu), so I think it’s worth the effort.
Inspired by AskUbuntu.