I am running Ubuntu Lucid on my workstation at home, but sometimes I still need to go back to Windows to get something done that I haven't quite figured out how to do in Linux yet. For that I am running VirtualBox on the workstation from which I spin up a Windows 7 VM.
I initially created the VM with 32 GB of hard drive space. That turned out to be too little and after the base Win7 OS and a few applications I was using over 15 GB. So I figured that I needed more hard disk space and I thought that I could just enlarge the pesky VDI file for the Win7 VM (it stands for Virtual Desktop Image and that's the default VM image file format used by VBox).
Well, it turns out that in nature you can't really pick up a hard disk, open it up, and throw in a new platter. In a virtual world, however, you get to play God and manipulate it any way you choose. All you have to do is clone and modify your original VDI file. Here's what you need:
- VirtualBox. Read this to install it on a Debian-based Linux distro.
- Windows 7... But any other OS ISO image or disk will do.
- GParted, the Gnome partition editor.
Assuming that you already downloaded the GParted ISO, installed VirtualBox and created some VM of which you want to resize the VDI file, here's how you do it:
- Open a terminal (we'll be using the command line for this).
- Find the VDI file you want to resize. This is usually under
Now clone the VDI by issuing the following command:
VBoxManage clonevdi Win7_64bit.vdi Win7_64bit_Larger.vdi
Where the first file name is the input file and the second file name the output.
Then resize the VDI (I grew mine from 32 to 64 GB):
VBoxManage modifyvdi Win7_64bit_Larger.vdi --resize 65536
Where the first parameter is the input file name and the resize parameter takes the new size in megabytes.
In the graphical VirtualBox manager, create a new VM using the cloned and expanded VDI file. I would pay special attention to use the same setting as the original VM that you cloned from.
- Now boot the new VM using the GParted ISO image that you downloaded earlier. We will use it to resize the partition inside the VDI.
- On the boot screen you will want to choose to boot using the Live GParted instance. We will use it to resize the partition in the VDI.
Once the live CD has booted up and the GParted application is running, select the partition you want to resize by clicking on it and then click the resize button.
Then select the handle at the end of the partition and slide it to fill up the entire unused space area. Click the resize button.
Next click the apply button on the GParted toolbar and watch the magic happen. Once done, click close and reboot the VM.
The first time you boot after performing the steps above, Windows will likely want to check the disk for consistency. Let it happen and Windows will reboot itself.
After this process, my Windows 7 VM was able to see a much larger drive. Let me know in the comments if you have questions or suggestions about how to improve this process.