Tuesday, 25 June 2013

Extending a Windows XP partition in VirtualBox

The Problem

My desktop computer runs Ubuntu Linux (on a Mac Mini!), but sometimes I am forced to use Microsoft Word to edit a document that LibreOffice/OpenOffice Writer can't handle, or use iTunes (ech.) to fix the kids' iPad. To do this I use the excellent VirtualBox software to run an Windows XP virtual machine within Ubuntu. I originally created a 10GB virtual disk image, but soon realised that wasn't enough space if I wanted to also backup the 64GB iPad completely. Fortunately, VDI disk images can be increased in size, but my Googling resulted in a variety of methods which were all a bit confusing, so this post summarises what I had to do for my exact situation, which I didn't come across anywhere else.


My Situtation

  • Aim: Grow my disk image storage from 10GB to 80GB
  • Partition type: NTFS
  • Host operating system: Ubuntu 13.04
  • Virtual operating system: Windows XP SP3

How to do it


  1. Locate the disk image: On Ubuntu, VirtualBox stores your machine data in "$HOME/VirtualBox VMs" by default. In there find the appropriate .VDI file. Mine was called "WinXP.vdi".
  2. Expand the VDI image: 
    On Ubuntu you use the "VBoxManage" command to do this. You do not need to "sudo" or be root as the files are all owned by you. This is the command I used to increase it to ~80GB:
    VBoxManage modifyhd "$HOME/VirtualBox VMs/WinXP.vdi" 81920
  3. Extend the NTFS partition: Although you've extended the physical disk image, Windows XP still only thinks it has 10GB because the original partition on the disk was 10GB. We need to extend the NTFS partition into the new space we made. Because I only have one partition which has the operating system and all my data, you can't do this from within Windows XP itself. You need to boot something else to modify the partition. I downloaded the free GParted Live CD ISO image and attached it to my virtual machine using the Settings and Storage menu on Virtual Box. I also made sure the virtual CD-ROM was in the boot order before the VDI image.
    After starting the machine, the GParted interface eventually booted. I could see my 80GB disk with a 10GB NTFS partition on it. I chose the partition, and clicked "Resize" and typed in the full size of the disk (81920 MB). After clicking extend, it only took a few seconds to complete.
  4. Reboot Windows:
    I shut down the machine, removed the ISO image from the Storage menu, and restarted it. Windows XP started up "
    chkdsk" as it noticed something had changed :-) I had no errors or issues, and examination of drive C: showed it was now 80GB in size.  Done!

Conclusion

Virtual machines and virtual disk images are awesome. I'm glad to be finished with meddling with multi-boot and repartitioning real disks. I hope this post was helpful to you.

3 comments:

  1. Useful post!
    I also used a VM to boot windows for such things, but recently I thought I should give a try to running windows apps under Wine.
    MS Office 2010 runs flawless in Ubuntu 13.04, as many other windows games (some quite resource consuming), just after installing two dependencies through wine.
    No more VMs or dual-boot for me :)

    ReplyDelete
  2. I had problems running MS Office 97 and 2003 under Wine, and did not try it again. But maybe things have improved the last few years. I will try it again soon. Thank you for the informations, as Wine is much simpler than VMs.

    ReplyDelete