Friday, July 15, 2011

Resize VirtualBox disk for WinXP guest

Resizing a virtualbox virtual disk is not a trivial task. Although it has a direct method to resize the virtual disk, it involves several steps to make Windows XP guest OS realize about this change. I will show all steps needed to increase the size of a Windows XP guest OS.

Before doing any change to your disks, it is highly recommended to make a backup of your disks images. Keep in mind that I'm only listing the steps I've followed to re-size a virtual box guest disk. You may find other problems I have not had. Do it at your own risk.

I am on a Linux host machine, but commands should be the same on Windows hosts.

You will need to boot your virtual machine with a GParted Live distribution (or any other Linux Live with Gparted like Ubuntu). If you don't have the iso, start by downloading it from here (~130MB):

Store it somewhere in your host disk.

Step1 - resize your actual virtual disk

VirtualBox has a powerful command line tool: VBoxManage. I am going to use it.

Go to where you store your virtual machine disk. In my case it is called winXP.vdi. To resize it to 20GB:

VBoxManage modifyhd winXP.vdi --resize 20000

This changes your virtual disk file to be able allocate 20000MB.

Step2 - Clone your actual virtual disk

We are going to clone our actual disk to a new one cloning all the contents:

VBoxManage clonehd winXP.vdi winXP20.vdi

This will take some time depending on the amount of data of your disk.

Step3 - Replace your VM current disk with the cloned one

First you need to know your Virtual Machine name. VBoxManage has a modifier to list all virtual machines on the system:
VBoxManage list vms

Once you identify your virtual machine name or UUID (a lot of hexadecimal numbers) you can replace your current disk through command line (you can do it also through the GUI)

VBoxManage modifyvm "VirtualMachine Name" --hda none
VBoxManage modifyvm "VirtualMachine Name" --hda winXP20.vdi

Step4 - Boot with Gparted to resize partition

Through GUI, set your virtual machine CD/DVD to load the GParted Live iso you have downloaded and check that CD/DVD will be the first media to use on boot.

Boot your virtual machine and follow instructions on screen. It will appear something similar to:

Select your partition, right click on it and select resize/move:

Once selected your changes, apply them:

If next error happens, simply boot into WinXp normally, run chkdsk and then boot again into GParted to resize the partition.

If you are trying to resize main disk, WinXP will ask to perform action on reboot, as it needs unique access to HDD

To be able to boot into WinXp, select the option on Grub or simply remove the iso file from the CD/DVD.


  1. Hi,

    Good tutorial.
    My .vdi was devided in SDA1 (19.53GiB), sad2->sda5 (31.46GiB). (In Windows they are resp. C: and D:.)
    I added 50GiB. Now there is onused space of 46.6GiB.
    I want to enlarge sda5 to 77GiB, but Is is only possible to create an extra sda3 of 41GiB.
    The sda5 is disk D: in Windows, I just want to enlarge that to keep preserve links in programms to D:

  2. Worked mostly, though (Mac host, XP guest) at the end, the mousebuttons quit working so I couldn't get the Exit icon on the desktop to let go, nor did ctrl-alt-del do anything. Finally power cycled the host hardware Mac; seems like it worked.

  3. Hm, probably I'd have been OK if I'd been content to let the new large boot drive be "E" -- I tried to sort out the names and ended up with blinking between Windows splash screen and desktop, gave up on it for a while. I'll start from a fresh copy of the original some other time.

  4. Some of the problems I had were that VBox doesn't yet support resizing a .vmdk file (Mac host). So I had to do the longer routine of creating a new large drive, then booting from the ISO to run Clonezilla, then booting from the GParted ISO to resize the partition -- all of which worked but left me with the old drive as C: and the new one as E.

    On retry -- Aha. Just disconnect the older smaller drive and restart the VM; Windows (XP anyhow) reassigns the new drive as C: when it finds that's the only one available to boot from. Problem solved.

  5. Thanks for your tips Hank

  6. [...] pasos se pueden conseguir aquí, y funcionan perfectamente. El problema es que hay otros sitios que solamente muestran los primeros [...]