Fetching latest headlines…
Reclaim free space from VirtualBox VM on Windows host
NORTH AMERICA
🇺🇸 United StatesJuly 5, 2026

Reclaim free space from VirtualBox VM on Windows host

1 views0 likes0 comments
Originally published byDev.to

When you delete files in your virtualbox VM in order to free up space on the host filesystem, this space is not automatically reclaimed.
In order for the host system to see the changes you need to rewrite the free space with zeroes.
Follow the below steps to perform this operation:

  • Install zerofree package. It is needed to rewrite the free space with zeroes.
  • Mount the filesystem as "readonly". This is needed for the tool to be able to perform it's task. If you're working with the "/", easiest way to mount it as readonly is to edit the kernel parameters.
    • Edit /etc/default/grub.
    • Find the GRUB_CMDLINE_LINUX_DEFAULT line.
    • Add init=/bin/bash to it
    • reboot
  • Run zerofree -v /dev/sdX. This could run for some time, depending on the size of your disk.
  • After it's done, run exec init to finish booting up.
  • Shutdown the VM in order to be able to run the next command which requires a lock on the VDI volume.
  • On the Windows host run VBoxManage.exe modifymedium "path\to\disk.vdi" --compact

Comments (0)

Sign in to join the discussion

Be the first to comment!