VirtualBox 4.0 got a very cool new feature that allows you to easily resize a hard disk in just a few seconds. Previously, you had to install Gparted to do this and the procedure was quite slow.
In VirtualBox 4.0+ (see how to install VirtualBox 4.0.x in Ubuntu), to resize a VirtualBox hard disk image (.VDI) firstly locate the folder where the .vdi you want to resize is located - this should be under~/VirtualBox VMs or~/.VirtualBox/HardDisks. Then open a terminal, navigate to that folder ("cd /FOLDER/PATH") and run the following command to resize the .VDI:
VB