Shrinking VDI file with NTFS partition

This is for discussing general topics about how to use VirtualBox.
Post Reply
wsun013
Posts: 19
Joined: 21. May 2007, 07:23

Shrinking VDI file with NTFS partition

Post by wsun013 »

I have a vdi file (growing) with ntfs partition of size 4GB, used up 2GB now, but takes 3GB of spaces on my host machine.

I used

Code: Select all

vditool SHRINK ntfs.vdi
but it didn't seem shrinking at all.

I De-registed the vdi file before shrinking, but it didn't help either

any idea ?
achimha
Volunteer
Posts: 217
Joined: 10. May 2007, 09:24

Post by achimha »

You need to zero out the freespace before applying the command. This requires some 3rd party utility for Windows.
wsun013
Posts: 19
Joined: 21. May 2007, 07:23

Post by wsun013 »

By the means of "zero-out", are you saying "de-fragment" ?
klaus
Oracle Corporation
Posts: 1115
Joined: 10. May 2007, 14:57

Post by klaus »

No, zero out free space just means that the free space must be filled with zeroes. There are several tools which can do this, e.g. SDelete (http://www.microsoft.com/germany/techne ... elete.mspx), for which you need to specify the parameter -z to zero out free space.
wsun013
Posts: 19
Joined: 21. May 2007, 07:23

Post by wsun013 »

Thank you all.

I have tried SDelete from

Code: Select all

http://www.microsoft.com/technet/sysinternals/Security/SDelete.mspx
Extract it, run it within the guest OS with -c instead of -z:

Code: Select all

sdelete -c c:
and shutdown the guest OS and virtualbox
then

Code: Select all

vditool SHRINK ntfs.vdi
and it works.

Thanks again.
mustali
Posts: 1
Joined: 18. Jun 2007, 20:31

vditool can be downloaded from here

Post by mustali »

In case you thought vditool was installed with VirtualBox our thoughts match!

vditool is available for download here (choose Save As):
http://www.virtualbox.org/download/testcase/vditool

thanks to thedarkmaster:
http://thedarkmaster.wordpress.com/2007 ... on-how-to/
Post Reply