Virtualbox Zerofree Windows

Last Updated: May. 8th 2022 at 11:01am Tags: blog virtualbox

How to zerofree your virtualbox client on windows.

In this article we are going to shrink the diskspace that a Linux Virtualbox client uses on a windows host. Tested on Ubuntu 20.04.

Preparing the client

First boot into your linux virutalbox client.

make sure you have zerofree installed:

sudo apt-get update -y && sudo apt-get install -y zerofree

Edit /etc/default/grub:

GRUB_TIMEOUT_STYLE=menu
GRUB_TIMEOUT=10
#GRUB_TIMEOUT_STYLE=hidden
#GRUB_TIMEOUT=0

apply changes: sudo update-grub

Reboot and drop to a root terminal in rescue mode

Running Zerofree

The first three steps below unmount the volume.  Fourth line tells you what disk  you want to use in the zerofree parameter.

swapoff -a
echo "u" > /proc/sysrq-trigger mount /dev/mapper / -o remount,ro df to find disk zerofree -v /dev/sda5

Next reboot, you can revert your grub file with the opposite of the steps above.

Virtualbox Compact Disk

vboxmanage.exe list hdds

cd C:\Program FIles\Oracle\Virtualbox
VBoxManage.exe modifymedium disk "C:\Users\nic\VirtualBox\ubuntu\ubuntu.vdi" --compact

Conclusion

This has a huge impact on diskspace if you are running a large amount of data.  Definalty worth the time.

Comments

You need to login to comment.