[Bug 721545] Re: Grub font file should be in /boot, not /usr

Marcus Tomlinson marcus.tomlinson at canonical.com
Thu Mar 5 12:35:06 UTC 2020


This release of Ubuntu is no longer receiving maintenance updates. If
this is still an issue on a maintained version of Ubuntu please let us
know.

** Changed in: grub2 (Ubuntu)
       Status: Triaged => Incomplete

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to grub2 in Ubuntu.
https://bugs.launchpad.net/bugs/721545

Title:
  Grub font file should be in /boot, not /usr

Status in grub2 package in Ubuntu:
  Incomplete

Bug description:
  Good morning everyone.

  Having some  troubleshoot with the internal HD of my laptop, I installed Ubuntu 10.10 on a usb drive (in ext4) in /dev/sdb2 - (hd1,msdos2).
  The /boot is actually /dev/sda - (hd0,msdos1) formated in ext because the first 32 MB of my internal hard drive are still accessible and it avoids my to need a boot CD. Grub2 is on the mbr of the internal HD. Version 1.98 ubuntu 3.1 but I tried 1.99 has the same problem.

  When Grub2 boots. I have a message stating that grub2 cannot get C/H/S
  of partition  (hd1,msdos2), which is normal since there is no BIOS
  support in my (old) laptop but it finally boots after some seconds
  waiting on the error message (or show me the menu if I press shift)
  without any problem since it loads the kernel and initrd from internal
  HD, then recognizes the USB with the kernel/module and uses it as
  root.

  After investigation, i found that in /boot/grub/grub.cfg, I have:

  --------------------------------------------------------

  #
  # DO NOT EDIT THIS FILE
  #
  # It is automatically generated by grub-mkconfig using templates
  # from /etc/grub.d and settings from /etc/default/grub
  #

  ### BEGIN /etc/grub.d/00_header ###
  if [ -s $prefix/grubenv ]; then
    set have_grubenv=true
    load_env
  fi
  set default="0"
  if [ "${prev_saved_entry}" ]; then
    set saved_entry="${prev_saved_entry}"
    save_env saved_entry
    set prev_saved_entry=
    save_env prev_saved_entry
    set boot_once=true
  fi

  function savedefault {
    if [ -z "${boot_once}" ]; then
      saved_entry="${chosen}"
      save_env saved_entry
    fi
  }

  function recordfail {
    set recordfail=1
    if [ -n "${have_grubenv}" ]; then if [ -z "${boot_once}" ]; then save_env recordfail; fi; fi
  }

  function load_video {
    insmod vbe
    insmod vga
  }

  insmod part_msdos
  insmod ext2
  set root='(hd1,msdos2)'
  search --no-floppy --fs-uuid --set c9083da5-8561-4189-9e7e-d0ef9eed3e55
  if loadfont /usr/share/grub/unicode.pf2 ; then
    set gfxmode=640x480
    load_video
    insmod gfxterm
  fi
  terminal_output gfxterm
  insmod part_msdos
  insmod ext2
  set root='(hd0,msdos1)'
  search --no-floppy --fs-uuid --set 8812973d-eff0-4248-8007-852e543290c6
  set locale_dir=($root)/grub/locale
  set lang=fr
  insmod gettext
  if [ "${recordfail}" = 1 ]; then
    set timeout=-1
  else
    set timeout=10
  fi
  ### END /etc/grub.d/00_header ###

  ### BEGIN /etc/grub.d/05_debian_theme ###
  set menu_color_normal=white/black
  set menu_color_highlight=black/light-gray
  ### END /etc/grub.d/05_debian_theme ###

  ### BEGIN /etc/grub.d/10_linux ###

  ETC ETC.

  -----------------------------------------------------------

  As you can see, after the load_video function, there is:

  insmod part_msdos
  insmod ext2
  set root='(hd1,msdos2)'
  search --no-floppy --fs-uuid --set c9083da5-8561-4189-9e7e-d0ef9eed3e55
  if loadfont /usr/share/grub/unicode.pf2 ; then
    set gfxmode=640x480
    load_video
    insmod gfxterm
  fi

  
  which of course cannot work since the Usb HD is not accessible yet.

  These lines come from the execution of 00_header:

  if [ "x$gfxterm" = x1 ]; then
      # Make the font accessible
      prepare_grub_to_access_device `${grub_probe} --target=device "${GRUB_FONT_PATH}"`

      cat << EOF
  if loadfont `make_system_path_relative_to_its_root "${GRUB_FONT_PATH}"` ; then
    set gfxmode=${GRUB_GFXMODE}
    load_video
    insmod gfxterm
  fi

  ------------------------------------------

  which uses /usr/lib/grub/grub-mkconfig_lib function's:

  
  is_path_readable_by_grub ()
  {
    path=$1

    # abort if path doesn't exist
    if test -e $path ; then : ;else
      return 1
    fi

    # abort if file is in a filesystem we can't read
    if ${grub_probe} -t fs $path > /dev/null 2>&1 ; then : ; else
      return 1
    fi

    return 0
  }

  
  and also prepare_grub_to_access_device() which creates the incriminated text put in grub.cfg.
  It seems this function replies positively whereas the fs is not accessible at boot time because the filesystem is of a recognized type and the path exists to the system.

  Strange thing, the first time I installed 10.10 it was working but after a while & reinstalling not anymore.
  May be the gfx sceen was disabled for some reason so it did not execute this part of the code. I don't see any option and anyway that would just be a workaround.
  I tried using --root-directory=/boot manually for grub-install. No effect.


  1. Everything needed for grub2 should just be copied in /boot to ensure it is accessible and no reference to anything else should be made (outside of a personal script for some reasons).
  2. So the system does not detect that some disk is not available at boot time before the kernel is loaded. If impossible to detect automatically what is available to the Bios, the configuration screen of grub2 should ask (when asking for where to install grub2) for it.
  3. No Usb disk driver for grub2 ? I saw some tries on the net but I should just be included in grub2 if it works.

  I can read some script but not very familiar with, so I could not fix it myself but if someone is involved, I could help but make it go slower than an expert alone !
  Thanks in advance, If we can fix all these stuff, the system will be perfect and grub2 is very powerful.
  Bye

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/721545/+subscriptions



More information about the foundations-bugs mailing list