In order to expand a hard disk in virtualbox (e.g. a windows 7 partition, in our example is called x7pro.vdi 12GB) one has to follow these steps:
- Create a new larger disk from Virtual Media Manager [VirtualBox File -> Virtual Media Manager]: e.g. w7.vdi, 70GB
- Download a stable version (the .iso file) of System Rescue CD.
- Change the settings of the currently active machine and add the newly created drive as secondary,
- add the System Rescue CD iso file as it’s CD,
- boot the virtual machine from the CD and start X windows ( at command prompt)
- It the Terminal type to start Gnome Partition Editor,
- When in Gnome Partition Editor select the device that contains the old operating system (in our example is: sda),
- Select the primary (boot) windows 7 partition (x7pro) and then select copy [if you do not have a separate boot partition then just copy the one with windows 7],
- Select the second (new) hard disk and paste,
- Accept default values when prompted for partition size etc.,
- Do the same for any other partitions that you might have,
- Click apply and then wait till it finishes up. This might take ages if your old partition is large.
- When done then select the primary partition: Manage Flags and select Boot for the newly created primary partition.
- Close gparted and power down the machine (Terminal -> )
- Change the settings of you Virtual machine to boot from the new HD, remove the System Resque CD from the CDrom list,
- Boot your virtual machine and you should have a larger HD.
.
You are right. I have realised that with win7 you need to fix your boot sector in order to boot correctly.
Indeed, the simplest solution is to repair the drive with win7 DVD.
This worked well. A couple of quick notes:
In the current iteration of VirtualBox you’ll need to prepare the partition map before copying anything over. It’ll warn you & give instructions when you go to paste the first partition.
Also, the non-System Protected partitions, however many you may have, should be resized to what you want for the new size once you paste. It doesn’t explicitly say that in the instructions though the picture shows it being resized.
As well, don’t forget to remove the original drive from VBox when removing the CD…
With Windows 7, at least, after you’ve ran this you may need to insert the Windows media (DVD or image), boot from it, and repair the drive. In my case after clicking Repair Drive it found the problem automatically and fixed it.
Finally, don’t forget to delete the old .vdi file for your old drive after everything’s done or you’ll have a lot of wasted space.
Thank you for these instructions. They worked great to expand my WinXP partition.
where exactly did it fail?
This didn’t work. None of the information on the ‘net seems to provide a solution for resizing a Virtual Box disk. This is infuriating!