Changing Ubuntu Server 12.04 console video mode

I'm running Ubuntu Server 12.04 as a virtual machine on my high-res work laptop, and got tired of the tiny 640x480 console window, so tried to figure out how to get a higher resolution for the text console.

Eventually, after much Googling, I found the solution.

Edit /etc/default/grub and add/modify these two lines:

GRUB_CMDLINE_LINUX_DEFAULT="vga=791"
GRUB_GFXMODE=1024x768

Then run update-grub and reboot. This will set both the grub menu screen and the final Linux console to be 1024x768.