Abstract: a memo on how to compact virtualbox vdi files.
VirtualBox comes with a utility to compact vdi files which drops zero block. So the problem is how to write zero to unused blocks. If you have a windows guest, run the following command in cmd:
sdelete -c
If you have a linux guest, run this:
cat /dev/zero > zero.fill;sync;sleep 1;sync;rm -f zero.fill
And in the host run:
VBoxManage modifyvdi harddisk.vdi compact
These may reduce the size of vdi files considerably if it has been used for a long time.
Where do I run "VBoxManage modifyvdi harddisk.vdi compact"? Please answer =)
ReplyDeleteWhere you have harddisk.vdi but you got to put the directory that holds "VBoxManage.ext"(win) iin your PATH environmment variable.
ReplyDeleteOn windows platform with the latest vbox, you would want to run "C:\Windows\Program Files\Oracle\VirtualBox\VBoxManage modifyvdi harddisk.vdi compact"; while on *nix, I think the binary is already in your PATH, so you can just run the command without any problem.