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

Discussions about using Windows guests in VirtualBox.
Post Reply
Cajita
Posts: 3
Joined: 21. Oct 2009, 00:49
Primary OS: MS Windows 7
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: XP 7

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

Post 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?
MarkCranness
Volunteer
Posts: 875
Joined: 10. Oct 2009, 06:27
Primary OS: MS Windows 7
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows Server 2008 R2; Ubuntu 11.04; Windows 2000 Server; Windows XP

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

Post 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).
Last edited by MarkCranness on 24. Oct 2009, 05:30, edited 1 time in total.
Etepetete
Posts: 400
Joined: 7. Oct 2009, 10:19
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Slackware 14.2
Location: Berlin

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

Post 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,
MarkCranness
Volunteer
Posts: 875
Joined: 10. Oct 2009, 06:27
Primary OS: MS Windows 7
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows Server 2008 R2; Ubuntu 11.04; Windows 2000 Server; Windows XP

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

Post 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!
Post Reply