I was creating a new virtual machine to install the latest Oracle SOA Suite (188.8.131.52) and, during my biased next/next/finish routine, forgot to configure the hard disk size. After installing almost everything, I realised that the VM was running out of space.
Instead of installing everything again, I’ve asked my friend Google to help me. Among a diversity of creative, complex, weird and dodgy ideas I could compile the solution described below (which can also be creative, complex, weird or/and dodgy for you!).
The procedure described below was tested with Oracle VirtualBox 4.0.2 and Ubuntu 10.04, so I’m not sure if it will work with older versions.
Because Ubuntu default installation uses a single partition layout (so you cannot “unmount” the partition to be extended), you will need the Ubuntu Live CD (installation media or image) to do the trick.
Resize VirtualBox hard disk
The following steps describe how to resize VirtualBox hard disk with Ubuntu:
1. Extend the VM hard disk file using VBoxManage.exe
Go to the VM hard disk folder and use the VBoxManage.exe tool to extend the hard disk file. For example:
“C:\Program Files\Oracle\VirtualBox\VBoxManage.exe” modifyhd testvm.vdi –resize 20480
2. Change the VM boot order
Go to the VM settings and set CD/DVD drive as the first device (make sure the CD/DVD drive for this VM is pointing to Ubuntu Live CD).
3. Choose the ‘Try Ubuntu’ and start the GParted tool
4. Remove swap partition (only if you have one)
The Ubuntu install wizard usually creates a swap partition and I couldn’t resize the main partition because the swap partition was in the middle (I am open for suggestions here!).
5. Resize partition
Right click on the partition that you want to extend and choose ‘Resize/Remove’ .
Choose the new size for your hard disk.
In this case I left 3Gb unallocated to be used by the swap partition
6. Create a swap partition
Create a extended partition with all the remaining space
Don’t forget to enable your swap partition by updating/adding the following line to the /etc/fstab file with the correct partition position. For example, if your swap partition position is /def/hda8:
/dev/hda8 none swap sw 0 0