Page 1 of 1

How to reduce the size of a Win XP guest's par tition?

Posted: 23. Oct 2009, 05:52
by Cajita
Recently converted a machine into Virtualbox.
Unfortunately the disk was 80GB but with only about 5 used.
The problem is my VDI is about 10GB (kinda useless since the data is 5GB only)

What is the easiest way to shrink the partition inside the VDI?

Re: How to reduce the size of a Win XP guest's par tition?

Posted: 23. Oct 2009, 08:27
by MarkCranness
You have two choices:
1) Periodic compact: (optional) Defrag, Zero free space, VBoxManage modifyhd ... --compact. (Do these steps in the VM:)
2) Repartition, followed by periodic compact as above
  • Backup!
  • (Optional, can help with defragmentation) Delete the USN Journal:

    Code: Select all

    fsutil usn deletejournal /n c:
  • (Optional) Compact/Defrag the disk, to push all free space to the end.
  • Clear all free space to zero (this helps greatly with VB compaction of standard=Dynamically sized VDIs).

    Code: Select all

    sdelete -c c:
  • Use EASUS Partition Manager to resize the partition.
    http://www.partition-tool.com/easeus-pa ... tition.htm
    (You probably won't be able to repartition the currently booted partition, so either attach the hard disk to a VM as a non-boot disk and run partition manager from there, or use a UBCD4Win ISO (http://www.ubcd4win.com/), which includes EASUS Partition Manager as part of its download.)
  • Boot the VM, and let it do an AutoChk/ChkDsk (it it does not, then manually CHKDSK /f the drive).

Re: How to reduce the size of a Win XP guest's par tition?

Posted: 23. Oct 2009, 13:38
by Etepetete
Hey Mark, you've helped me often in the past, of which I'm grateful. I believe your code is incorrect. With sdelete switches are preceded with a dash and not a slash i.e. sdelete -z C:

Another thing, -z is for cleansing and empty space is overwritten with random data, not zeros (As I understand the information published on the SysInternals Website). The correct command would be sdelete -c C:. One more thing, to run sdelete within the VM, the previous command didn't work for me, only sdelete -c works.

Best regards,

Re: How to reduce the size of a Win XP guest's par tition?

Posted: 24. Oct 2009, 05:29
by MarkCranness
Etepetete wrote:I believe your code is incorrect.
Thank you for correcting me!

After some investigation, I have found the following:
  • -z writes random data (3 times) to clean a disk, as you say (I have corrected my post above).
  • -c writes zero data (1 times) to zero a disk, very useful for compressing a disk.
  • sdelete accepts either /x style options or -x style options.
  • The sdelete doc says "sdelete [-p passes] [-z|-c] [drive letter]", BUT the ':' character after the drive letter is required.
... -Z Cleaning and -C Zeroing (swapped) I thought must have been a documentation mistake!