How to change the size of a virtual hard disk with VirtualBox

How to change the size for a VirtualBox harddisk image file 
Used VirtualBox version 4.1.8 on OS X 10.7.2
 
Open a terminal and navigate to the directory containing the vdi file.
Enter the following command
 
VBoxManage modifyhd 'Windows Server 2009.vdi' --resize 40960
 
After changing the size of the vdi file you should resize the harddisk from within your guest operating system.