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
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
').
-
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
toVDI
using the command:vboxmanage clonehd --format VDI x:\path\to\disk.vmdk x:\path\to\disk.vdi
– KanchuCommented 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
-
-
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
Commented Nov 9, 2023 at 23:57