Enable frambeuffer on Ubuntu Karmic Koala using grub2

I usually develop and test my webpages on various VirtualBox virtual machines and since I am doing a lot of console work I use a framebuffer which enables using larger resolutions than the default console. Until now I was using Ubuntu 8.04 LTS virtual machines, but recently I upgraded to 9.10. Ubuntu 9.10 (Karmic Koala) is using grub2 so the simple adding of vga=791 or similar value to boot options won't work. Here's how to enable the framebuffer on virtual consoles:

1. Enable kernel modules

{-sYnTaXhIgHlIgHtEr- class="brush:bash"}$ sudo nano /etc/initramfs-tools/modules{/-sYnTaXhIgHlIgHtEr-}

Add two lines at the end of the file enabling two kernel modules:

{-sYnTaXhIgHlIgHtEr- class="brush:xml"}vesafb fbcon{/-sYnTaXhIgHlIgHtEr-}

Prevent blacklisting the vesafb module:

{-sYnTaXhIgHlIgHtEr- class="brush:bash"}$ sudo nano /etc/modprobe.d/blacklist-framebuffer.conf{/-sYnTaXhIgHlIgHtEr-}

Look for the line blacklist vesafb and comment it out:

{-sYnTaXhIgHlIgHtEr- class="brush:bash"}#blacklist vesafb{/-sYnTaXhIgHlIgHtEr-}

2. Modify grub configuration

{-sYnTaXhIgHlIgHtEr- class="brush:bash"}$ sudo nano /etc/default/grub{/-sYnTaXhIgHlIgHtEr-}

Remove the comment from the GRUB_GFXMODE line and set the desired resolution: {-sYnTaXhIgHlIgHtEr- class="brush:bash"}GRUB_GFXMODE=1024x768{/-sYnTaXhIgHlIgHtEr-}

There's no need to set bit depth, just the screen resolution. Then open the very first config file in /etc/grub.d

{-sYnTaXhIgHlIgHtEr- class="brush:bash"}$ sudo nano /etc/grub.d/00_header{/-sYnTaXhIgHlIgHtEr-}

Look for the code set gfxmode=${GRUB_GFXMODE} and insert one line after it so the code looks like this:

{-sYnTaXhIgHlIgHtEr- class="brush:bash"} if loadfont make_system_path_relative_to_its_root $(){GRUB_FONT_PATH} ; then set gfxmode=${GRUB_GFXMODE} set gfxpayload=keep insmod gfxterm insmod ${GRUB_VIDEO_BACKEND} {/-sYnTaXhIgHlIgHtEr-}

3. Update your boot configuration

{-sYnTaXhIgHlIgHtEr- class="brush:bash"}$ sudo update-grub2

$ sudo update-initramfs -u{/-sYnTaXhIgHlIgHtEr-}

That's it! Now reboot and watch your enhanced virtual console with the framebuffer.