Grub2 – Manual Configuration for Background Image

grub2

I'm trying to manually install a background image for grub on a bootable flash drive. Since the drive only boots ISO's and has no installed OS, I can't take advantage of scripts such as update-grub to do this for me and the posts regarding editing /etc/default/grub don't apply to my situation. I've seen How to put a background image on GRUB? but it doesn't apply for the reasons I've mentioned. I've managed to get all my ISO's to boot properly but I'm stuck on applying the background image. Here's the relevant section of my grub.cfg the rest is all menu entries that work properly (falling back to text mode).

set timeout=10
set default=0
set root=(hd0,msdos1)
### BEGIN background setup ###
function load_video {
  if [ x$feature_all_video_module = xy ]; then
    insmod all_video
  else
    insmod efi_gop
    insmod efi_uga
    insmod ieee1275_fb
    insmod vbe
    insmod vga
    insmod video_bochs
    insmod video_cirrus
  fi
}
load_video
insmod gfxterm
insmod part_msdos
insmod png
GRUB_TERMINAL=gfxterm
GRUB_GFXMODE=auto
GRUB_BACKGROUND="splash.png"
### END background setup ###

The background image is a 640×480 PNG file (which I scaled to size with gimp)
Using GRUB 2.02 Beta2

Further research indicates that this part:

GRUB_TERMINAL=gfxterm
GRUB_GFXMODE=auto
GRUB_BACKGROUND="splash.png"

uses variables that are used by the update scripts and belong in /etc/default/grub and don't appear in this fashion in grub.cfg so I'm certain those lines at least are wrong.

EDIT: I've made some adjustments but still no joy. Here's a pastebin of the relevant section (I excluded the irrelevant menu entries as they work fine in text mode and aren't the problem)

Best Answer

You need to add the next line to your grub.cfg before the menus. Since it is custom made and you're not going to use update-grub you shouldn't have any problem:

 background_image /boot/Your_image.png

Now, if you want to have a different background for your distros, you just need to add the line in the menu. For instance, this is the part where my menus start; as you can see I have a default background before the menus so that when grub starts it has a background, and after that each menu/submenu has its own background:

background_image /boot/SolusOS-splash.png

set color_normal=white/black
set color_highlight=black/white

submenu "Debian 8.1 -->"{
     submenu "Debian 8.1 i386 -->"{         
            background_image    /boot/DebianLava-splash.png         
            set iso=/boot/ISOs/debian-live-8.1.0-i386-gnome-desktop.iso
          ....

EDIT: Here are my search path entries (mind the uuid is my usb's ID) don't know if this might be your issue:

set boot_uuid=D042-8A53    
set root_uuid=D042-8A53

search --fs-uuid $root_uuid --set=root
search --fs-uuid $boot_uuid --set=grub_boot
if [ $boot_uuid == $root_uuid ]
then
    set grub_boot=($grub_boot)/boot
else
    set grub_boot=($grub_boot)
fi
Related Question