Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

So if I have a dynamical storage in virtualbox guest, how can I reduce the VDI's size, if there are many unused place in the guest?

So I mean I know the virtualbox guest in reallity is about ~3 GByte's large, but the VDI file is 10 GByte, because once a while the guest was that big. But it's now only 3 GByte's big. How can I reduce the VDI's size? So that it would be only 3 GByte's big? (and no, there aren't any snapshot's about the guest)

share|improve this question
    

2 Answers 2

up vote 7 down vote accepted

Take a look at vboxmanage modifyhd: it allows you to make an image more compact.

With the --compact option, can be used to compact disk images, i.e. remove blocks that only contains zeroes. This will shrink a dynamically allocated image again; it will reduce the physical size of the image without affecting the logical size of the virtual disk. Compaction works both for base images and for diff images created as part of a snapshot.

For this operation to be effective, it is required that free space in the guest system first be zeroed out using a suitable software tool. For Windows guests, you can use the sdelete tool provided by Microsoft. Execute sdelete -c in the guest to zero the free disk space before compressing the virtual disk image. For Linux, use the zerofree utility which supports ext2/ext3 filesystems.

share|improve this answer

Be careful -- MS changed the meaning of "-c" (clean) and "-z" (zero) at some point. To be safe, run "sdelete /?" to see which option you should use:

C:\> sdelete /?

SDelete - Secure Delete v1.6
Copyright (C) 1999-2010 Mark Russinovich
Sysinternals - www.sysinternals.com

usage: sdelete [-p passes] [-s] [-q] <file or directory> ...
       sdelete [-p passes] [-z|-c] [drive letter] ...
   -a         Remove Read-Only attribute
   -c         Clean free space
   -p passes  Specifies number of overwrite passes (default is 1)
   -q         Don't print errors (Quiet)
   -s or -r   Recurse subdirectories
   -z         Zero free space (good for virtual disk optimization)
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.