[SOLVED] VirtualBox – how to reduce virtual disk size

[SOLVED] VirtualBox – how to reduce virtual disk size

This guide shows you how to free up memory used by VirtualBox machines.

I. [Optional] Remove unnecessary data from the virtual machine

Run the virtual machine and remove unnecessary data. You can use tools like WinDirStat (Windows) or baobab (aka “Disk Usage Analyser” – for Linux).


II. [Optional] Fill unused disk space by zeros

Linux guest OS

There is a tool for Linux(called zerofree) that fills unused disk space by zeros which can be free up in the next step.

First you have to install zerofree  by:

Then reboot the machine and run linux in safemode (press ESC  key on BIOS screen and choose Advanced -> Recovery Mode in Grub menu). Then run:

After all shutdown the machine:


Windows Guest OS

Run virtual machine and then run Disk Defragmenter  for all disks.


III. Compact VirtualBox disk

Go to the VirtualBox installation directory. Default location is:

  • Windows: C:\Program Files\Oracle\VirtualBox;
  • Linux: /usr/share/virtualbox/ –  /usr/bin/VBoxManage  is linked to /share/virtualbox/VBox.sh.

and run the following command to get the location of disk you are interested in:

Here is my result:


Compact chosen disk by the following command:



Leave a Reply

Notify of
Close Menu