2015年6月27日星期六

Display background image for Grub2 under LFS system

1. Install Unicode Font file (PF2 format)

Download the Unicode font file (BDF format) from GNU Unifont Glyphs and then run the following command to generate a Unicode Font file (PF2 format, the output font size is set to 16, output file name is “unicode.pf2” and the input file name is “unifont.bdf”)

grub-mkfont –s 16 –o unicode.pf2 unifont.bdf

Then copy the output file (unicode.pf2) to “/boot/grub/fonts” directory.

(If grub-mkfont is not found, add the option "--enable-grub-mkfont" when you re-build the grub tool.)

2. Setup grub.cfg

In the grub.cfg, add the following codes to display the background image (in this example, the image file is “/boot/grub/bg.png”):

if loadfont unicode; then
  set gfxmode=auto
  insmod vbe
  insmod vga
  insmod gfxterm
  set locale_dir=/boot/grub/locale
  set lang=en_US
  insmod gettext
  terminal_output gfxterm

  insmod png
  background_image /boot/grub/bg.png
fi

Then the grub2 should display the image file.

If your system uses Plymouth after grub2, you can add the line "set gfxpayload=keep" in the grub.cfg so the image file will be kept until plymouth is running.
(Warning: Do not add this line if plymouth or X window system is not ran automatically because you will not get the terminal in text mode)

沒有留言: