How to compact / shrink a Dynamically Allocated virtual box vmdk file on a ubuntu guest after deleting a bunch of files?
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
').
Related videos on Youtube
Patoshi パトシ
MIT graduate developer living and working from Tokyo! (◠‿◠) Open to freelance opportunities in Crypto or Drupal. Supporting: https://girlswhocode.com https://www.liftcommunities.org https://www.pursuit.org https://www.womenwhocode.com
Updated on September 18, 2022Comments
-
Patoshi パトシ over 1 year
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.
-
Patoshi パトシ over 5 yearsits my vmdk file that is over 50GB. so i'm out of luck?
-
Kanchu over 5 yearsYou can convert
VMDK
toVDI
using the command:vboxmanage clonehd --format VDI x:\path\to\disk.vmdk x:\path\to\disk.vdi
-
Patoshi パトシ over 5 yearsDoes 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.
-
Patoshi パトシ over 5 yearsscreenshot: prntscr.com/klgl74
-
Kanchu over 5 yearsAfter zero filling, remove/delete the
/bigemptyfile
, shutdown the VM and then compact the disk. -
Patoshi パトシ over 5 yearsdoesn't clonehd command makes a copy of my vmdk file? which means its 2x50GB = 100GB of free space I need right?
-
Kanchu over 5 yearsYes, it does, but once it gets converted (and it works properly) you can compact it and then delete the
VMDK
, retaining theVDI
.