Short answer? You can’t.
But what you can do is just treat your virtual system as a real system, and do what you’d do to transfer your windows C drive to a new hard disk.
I decided a while back to try out windows XP on a virtual machine on my Ubuntu 8.04 Hardy system. I have a decent processor and a lot of RAM, so why not?
I made the mistake of making a disk that was too small to allow a full XP install and an update to SP3. 4GB just doesn’t cut it.
I looked around online, and there is no native method to resize a virtual hard disk in VirtualBox.
So here’s what I did.
NOTE: This is using VirtualBox 2.02 on Ubuntu Hardy 8.04, with a fresh install of Windows XP SP2 (only added iTunes). This VirtualBox install includes the guest OS additions which allow dynamic desktop resizing, fullscreen view, and USB devices. YMMV with other systems.
This was done with a legitimate copy of Windows, re-validated by phone. Assuming you have a legit product key, you can revalidate your windows anonymously.
I would suggest backing up your disk image before doing this, and of course, don’t do this on a production machine without extensive backups and get-out-of-trouble cards.
This how-to assumes a certain level of competency with windows systems and basic hardware setups.
1. Make a new, blank disk in your VirtualBox disk manager. I made a 10Gb expanding disk.
2. Attach it to your Virtual system and boot it.
3. Because this is a raw, unformatted disk, I went to control panel>performance and maintenance>administrative tools>computer management>disk management and created a primary partition and formatted it.
4. Shut down the system.
5. Download a HDD cloning program. I used HDClone from http://www.miray.de because the free version comes with an ISO image for a bootable CD.
6. Mount the bootable ISO as your CD/DVD image in the VirtualBox settings. Make sure you boot from CD.
7. Boot your system and wait for HDClone software to start
This took around 15 minutes for me. It will also ask if you want to expand the filesystem to fit, choose yes.
There was also something at the end about something else, I didn’t pay attention but I didn’t bother with it.
Shutdown the system.
8. Not done yet. Change your drive settings to swap the Primary Master and Slave to the opposite of what they were.
Then boot the system.
9. Hopefully at this point your system has started. If you check your drives, you’ll notice drive C is still the small one. Doh. But the system will have booted from the large drive. Yay.
First thing, in your control panel, change the location of the page file from C: to E: (it was E: for me, may be different for you.)
10. Go to http://support.microsoft.com/kb/223188 and follow the instructions to change your system drive letter. Shutdown.
11. Remove the small drive from VirtualBox settings and boot. It actually took me a couple of reboots to settle the system, but now it’s rock solid. Well, as rock solid as windows can be, anyway.
And you’re done. Hopefully that all worked out for you. It did for me, so I posted it. There may be steps you can skip, but this is what I did.
Let me know how it turned out for you, or if you have a better idea!









4 Responses to “How-To: Resize a VirtualBox Hard Disk”
Leave a Reply