Skip to content

Instantly share code, notes, and snippets.

@tonylambiris
Forked from DManavi/Guest-Commands.md
Created March 21, 2023 11:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonylambiris/138992be263e91eaaaca93028d4da3cf to your computer and use it in GitHub Desktop.
Save tonylambiris/138992be263e91eaaaca93028d4da3cf to your computer and use it in GitHub Desktop.
How to compact virtualbox disks to save space on the host machine?
This gist is about a tested procedure to free-up disk space on a virtualbox host machine.
I've struggled with the situation that 230GB of my 240GB SSD drive was full.
After doing these commands and follow the procedure, I could free-up more than 100GB of disk space.
The procedure copied from this answer on the superuser.com website.
https://superuser.com/questions/529149/how-to-compact-virtualboxs-vdi-file-size

These commands should execute on your "GUEST" OS/Your virtual machine.

If the OS is a linux, run

dd if=/dev/zero of=/var/tmp/bigemptyfile bs=4096k ; rm /var/tmp/bigemptyfile

if the OS is windows

  1. Download this application http://technet.microsoft.com/en-us/sysinternals/bb897443
  2. Run the command below.

Change C: with your own drive letter.

sdelete.exe c: -z

if your host is linux run

vboxmanage modifymedium --compact /path/to/thedisk.vdi

If your host is windows run

VBoxManage.exe modifymedium --compact c:\path\to\thedisk.vdi

If your host is MacOS run

VBoxManage modifymedium --compact /path/to/thedisk.vdi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment