Sunday, April 24, 2011

Cleaning up Grub2 boot menu.


I mentioned some time ago that my Grub2 boot menu page was of very poor quality after upgrading to Ubuntu Natty. The background image looked of very low resolution and the fonts, although large enough, were difficult to read because of being somewhat transparent.
Strangely, I did not have this problem when I upgraded Ubuntu to Natty on my other Dell (Dim9200) where the boot menu background was as sharp as ever. Note that in this latter case, I had done a straight upgrade rather than the clean install I had done on the Dell E520.
The problem was indeed a low resolution boot menu background.

Fixing the Resolution
To fix this, as explained here, edit the file /etc/default/grub and add the line

GRUB_GFXMODE=1280x1024_32

Note that you must find out which resolutions your grub menu will support by going to a grub prompt while on the menu page (IOW during a boot) and typing 'c' (without quotes) and then typing 'vbeinfo'.
This should produce a whole list of supported resolutions. Choose whichever you want and include it in the GRUB_GFXMODE line above.
Now choose a suitable background image of the EXACT size used in the GRUB_GFXMODE line (I used Gimp to scale my selected image) and add it to /boot/grub/ (as explained here). Then run 'sudo update-grub'.
Next time you boot, your boot menu should look a lot better. However, you will probably find that your fonts are annoyingly small.

Increase boot menu font size
How this is done is outlined in point #7 of the first post here.
This involves running the following command:
sudo grub-mkfont --output=/boot/grub/DejaVuSansMono.pf2 --size=24 /usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono.ttf

then editing /etc/default/grub and adding the line
GRUB_FONT=/boot/grub/DejaVuSansMono.pf2

Now, update-grub as usual and reboot to see your new fonts.
Of course, you could choose whatever font is available on your system rather than what's included in the above commands. However, this font worked very well for me.
Nevertheless, although the background looked great and the fonts were of an ideal size, readability was still a problem because of the font color.

Change boot menu font color.
To do this in Grub1.99 is different from the method used in earlier versions of Grub2.
The details are provided in post #4 of this thread and involves editing /etc/grub.d/05_debian_theme.
First find the line
echo "if background_image `make_system_path_relative_to_its_root "${1}"`; then"

Then, between this line and the line
if [ -n "${2}" ]; then

add these lines which should incorporate your own choice of colors:
echo " set color_normal=yellow/black"
echo " set color_highlight=green/black"


The result
What I got is shown in the screenshot (which is a camera shot as screenshots are not possible in the boot menu).

Edit (23/04/2012): See this update for some useful additional comments.

No comments:

Post a Comment