sudo apt-get install virtualbox-guest-dkms virtualbox-guest-utils virtualbox-guest-x11This is fairly large. And restart the VM. Now, when you restart the window of the VM, Ubuntu will also resize! (But only after you login) If you're using Vmware, I read the equivalent is:
sudo apt-get open-vm-tools open-vm-tools-desktopBut I have not tried this.