Usually I rarely use more than 20GB on my Linux virtual machine. However I set up Dropbox and, once it synced, I had only a few megabytes left on my VM.
These are the steps I’ve followed to resize the VM partition:
Make a backup of your VM
You can potentially destroy your VM so better safe than sorry. Make a copy of your VM.
Delete snapshots
If you have snapshots you must delete them first so changes are merged on the main disk file.
Resize the virtual disk
Run the following command:
VBoxManage.exe modifyhd ubuntu.vdi –-resize 40000
Download GParted Live CD/USB image and use it to boot the VM
You need to download GParted Once downloaded boot your VM with the GParted image.
Resize the partition
If the swap partition happens to be between the primary partition and the unallocated space, you need to remove it. Resize the primary partition and then create the swap partition back.
Be sure to write down the size of the swap partition before delete it and leave that space unallocated when resizing the primary partition.
Once you are happy with changes click apply and exit GParted. Remove it from the boot sequence and restart the VM. Enjoy the extra space.