3

I have a very old virtual box with ubuntu 14 guest installed. Its currently taking up over 50GB and I just deletect 35GB of data on this virtualbox, but since the hard drive is Dynamically allocated the vmdk file is still its original huge size. What is an easy way to compact / shrink this vmdk file? I'm on Windows 10 as host.

1 Answer 1

6

The virtual disk image is a VMDK file or VDI file?

VBoxManage only shrinks VDI file based disk images.

To do that...

First, zero fill your virtual disk. Boot the VM and run:

sudo dd if=/dev/zero of=/bigemptyfile bs=4096k status=progress
sudo rm -f /bigemptyfile

Shut down the VM and VirtualBox.

Then on the host run:

vboxmanage modifymedium x:\path\to\disk.vdi --compact

Note: You'll have to specify the path of vboxmanage (generally 'C:\Program Files\Oracle\VirtualBox').

8
  • its my vmdk file that is over 50GB. so i'm out of luck? Commented Aug 21, 2018 at 17:37
  • You can convert VMDK to VDI using the command: vboxmanage clonehd --format VDI x:\path\to\disk.vmdk x:\path\to\disk.vdi
    – Kanchu
    Commented Aug 22, 2018 at 2:00
  • Does zero fill my virtual disk would require me to fill it up to my max capacity of 500GB? that is what I have set. But my SSD is only 500GB and I only have 20gb free right now. Commented Aug 22, 2018 at 3:11
  • screenshot: prntscr.com/klgl74 Commented Aug 22, 2018 at 3:18
  • 2
    @kanchu, the syntax changed slightly over the time, now it's: vboxmanage clonemedium disk x:\path\to\disk.vmdk x:\path\to\disk.vd --format VDI
    – Anton Krug
    Commented Nov 9, 2023 at 23:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .